firefighterTasks = this.getFirefighterTasks();
Assert.assertTrue(firefighterTasks.isEmpty());
// Sudenly, the fire truck runs out of water
ProceduresMGMTService.getInstance().notifyProcedures(
MessageToEventConverter.convertMessageToEvent( new FireTruckOutOfWaterMessage(emergency.getId(), fireTruck.getId(),
new Date())));
Thread.sleep(5000);
//Now, the firefighter has a new task
firefighterTasks = this.getFirefighterTasks();
Assert.assertEquals(1, firefighterTasks.size());
firefighterTaskId = firefighterTasks.keySet().iterator().next();
String firefighterTaskName = firefighterTasks.values().iterator().next();
Assert.assertEquals(
"Water Refill: go to ( " + firefightersDepartment.getX() + ", "
+ firefightersDepartment.getY() + " )", firefighterTaskName);
// The firefighter completes the task
this.completeTask("firefighter", firefighterTaskId);
// No more tasks for firefighter
firefighterTasks = this.getFirefighterTasks();
Assert.assertTrue(firefighterTasks.isEmpty());
// The Fire Truck returns to the emergency
ProceduresMGMTService.getInstance().notifyProcedures(
MessageToEventConverter.convertMessageToEvent(new VehicleHitsEmergencyMessage(fireTruck.getId(),
emergency.getId(), new Date())));
Thread.sleep(5000);
// A new task for the firefighter should be there now
firefighterTasks = this.getFirefighterTasks();
Assert.assertEquals(1, firefighterTasks.size());
firefighterTaskId = firefighterTasks.keySet().iterator().next();
// The firefighter completes the task
this.completeTask("firefighter", firefighterTaskId);
// Becasuse the fire truck still got enough water, no "Water Refill"
// task exists
firefighterTasks = this.getFirefighterTasks();
Assert.assertTrue(firefighterTasks.isEmpty());
// Again, the fire truck runs out of water
ProceduresMGMTService.getInstance().notifyProcedures(
MessageToEventConverter.convertMessageToEvent(new FireTruckOutOfWaterMessage(emergency.getId(), fireTruck.getId(),
new Date())));
Thread.sleep(5000);
firefighterTasks = this.getFirefighterTasks();