*
* @throws Exception
*/
@Test
public void testJobStateTransition() throws Exception {
SpringXDTemplate template = ensureTemplate();
String jobName = testName.getMethodName() + "-ticktock";
String definition = String.format("timestampfile --directory=%s --format='%s' --fileExtension=%s",
DIRECTORY, DATE_FORMAT, FILE_EXTENSION);
String fileName = DIRECTORY + File.separatorChar + jobName + '.' + FILE_EXTENSION;
try {
template.jobOperations().createJob(jobName, definition, false);
verifyJobCreated(jobName);
verifyJobState(jobName, DeploymentUnitStatus.State.undeployed);
template.jobOperations().deploy(jobName, null);
verifyJobState(jobName, DeploymentUnitStatus.State.failed);
startContainer();
Map<Long, String> mapPidUuid = waitForContainers();
assertEquals(1, mapPidUuid.size());
verifyJobState(jobName, DeploymentUnitStatus.State.deployed);
template.jobOperations().launchJob(jobName, null);
assertThat(fileName, fileUpdated(System.currentTimeMillis()));
shutdownContainer(mapPidUuid.keySet().iterator().next());
waitForContainers();
verifyJobState(jobName, DeploymentUnitStatus.State.failed);