Your task is to fix the health checks tool so that every command updates the data correctly and prints the correct success message or error reason. It reads the state from data/health.json, processes the check, mute and unmute commands, and writes the updated state back.
├── data/
│ └── health.json # Persistent monitor state (every service's streaks and status)
├── src/
│ ├── main/java/com/health/
│ │ ├── Commands.java # Command handlers
│ │ ├── FileIo.java # State file load and save
│ │ ├── Main.java # CLI entry point
│ │ ├── Models.java # Data models
│ │ └── Parser.java # JSON parsing
│ └── test/java/com/health/
│ └── CommandsTest.java
├── health # CLI launcher script
├── run.sh # Setup and run script
├── reset.sh # Restore data/health.json to its initial state
├── test.sh # Test script (writes junit.xml)
├── pom.xml # Maven build configuration
└── README.md
mvn -B -ntp -DskipTests packagebash run.shbash test.shRestore data/health.json to its initial state.
bash reset.shEach example below runs independently against the initial data/health.json and shows only the records it changes.
Command:
./health check api upOutput:
api up (10 in a row)
Changed records in data/health.json:
{"service":"api","status":"ok","fails_in_row":0,"passes_in_row":10,"muted":false,"alerts":2}Command:
./health check api sidewaysOutput:
Error: INVALID_RESULT
data/health.json: unchanged.
Command:
./health mute notifyOutput:
notify muted
Changed records in data/health.json:
{"service":"notify","status":"ok","fails_in_row":1,"passes_in_row":0,"muted":true,"alerts":0}Command:
./health unmute searchOutput:
search unmuted
Changed records in data/health.json:
{"service":"search","status":"alerting","fails_in_row":5,"passes_in_row":0,"muted":false,"alerts":4}Command:
./health mute ghost-serviceOutput:
Error: SERVICE_NOT_FOUND
data/health.json: unchanged.