@Test void detectLiveApplicationColorNullDeployedMta() { tester.test(() -> detectLiveApplicationColor(null), new Expectation(null)); }
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(); }
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(); } }
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(); }  }
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); }
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);  }