### Question:
ApplicationColorDetector { public ApplicationColor detectLiveApplicationColor(DeployedMta deployedMta, String correlationId) { if (deployedMta == null) { return null; } ApplicationColor olderApplicationColor = getOlderApplicationColor(deployedMta); Operation currentOperation = operationService.createQuery() .processId(correlationId) .singleResult(); List<Operation> operations = operationService.createQuery() .mtaId(currentOperation.getMtaId()) .processType(ProcessType.BLUE_GREEN_DEPLOY) .spaceId(currentOperation.getSpaceId()) .inFinalState() .orderByEndTime(OrderDirection.DESCENDING) .limitOnSelect(1) .list(); if (CollectionUtils.isEmpty(operations)) { return olderApplicationColor; } if (operations.get(0) .getState() != Operation.State.ABORTED) { return olderApplicationColor; } String previousProcessId = operations.get(0) .getProcessId(); ApplicationColor latestDeployedColor = getColorFromHistoricProcess(previousProcessId); Phase phase = getPhaseFromHistoricProcess(previousProcessId); if (latestDeployedColor == null) { return olderApplicationColor; } return phase == Phase.UNDEPLOY ? latestDeployedColor : latestDeployedColor.getAlternativeColor(); }  ApplicationColor detectLiveApplicationColor(DeployedMta deployedMta, String correlationId); ApplicationColor detectSingularDeployedApplicationColor(DeployedMta deployedMta);  }### Answer:
@Test void detectLiveApplicationColorNullDeployedMta() { tester.test(() -> detectLiveApplicationColor(null), new Expectation(null)); }
@Test void detectLiveApplicationColorPhaseNotFound() { Expectation expectation = new Expectation(GREEN); mockOperationService(createFakeOperation(Operation.State.RUNNING, FAKE_PROCESS_ID), createFakeOperation(Operation.State.ABORTED, FAKE_BLUE_GREEN_DEPLOY_HISTORIC_PROCESS_INSTANCE_ID)); mockHistoricVariableInstanceColor(BLUE); tester.test(() -> detectLiveApplicationColor(readResource("deployed-mta-02.json", DeployedMta.class)), expectation); }
@Test void detectLiveApplicationColorMtaColoNotFound() { Expectation expectation = new Expectation(GREEN); mockOperationService(createFakeOperation(Operation.State.RUNNING, FAKE_PROCESS_ID), createFakeOperation(Operation.State.ABORTED, FAKE_BLUE_GREEN_DEPLOY_HISTORIC_PROCESS_INSTANCE_ID)); mockHistoricVariableInstancePhase(); tester.test(() -> detectLiveApplicationColor(readResource("deployed-mta-02.json", DeployedMta.class)), expectation); }
@Test void detectLiveApplicationColorNoOperations() { Expectation expectation = new Expectation(GREEN); mockOperationServiceNoOtherOperations(createFakeOperation(Operation.State.RUNNING, FAKE_PROCESS_ID)); tester.test(() -> detectLiveApplicationColor(readResource("deployed-mta-02.json", DeployedMta.class)), expectation); }