when(mockStatus.getContainerId()).thenReturn(mockCId);
when(mockStatus.getDiagnostics()).thenReturn(diagnostics);
when(mockStatus.getExitStatus()).thenReturn(ContainerExitStatus.PREEMPTED);
schedulerHandler.containerCompleted(mockTask, mockStatus);
Assert.assertEquals(1, mockEventHandler.events.size());
Event event = mockEventHandler.events.get(0);
Assert.assertEquals(AMContainerEventType.C_COMPLETED, event.getType());
AMContainerEventCompleted completedEvent = (AMContainerEventCompleted) event;
Assert.assertEquals(mockCId, completedEvent.getContainerId());
Assert.assertEquals("Container preempted externally. Container preempted by RM.",
completedEvent.getDiagnostics());
Assert.assertTrue(completedEvent.isPreempted());