@Test public void testWrongStateDoesNothing() { DeploymentDAO deploymentDAO = mock(DeploymentDAO.class); DeploymentEventService deploymentEventService = mock(DeploymentEventService.class); CreatedEventHandler createdEvent = new CreatedEventHandler(); createdEvent.deploymentDAO = deploymentDAO; createdEvent.deploymentEventService = deploymentEventService; DeploymentEvent deploymentEvent = new DeploymentEvent(); deploymentEvent.setDeploymentId(22); deploymentEvent.setDeploymentStatus("1111"); createdEvent.deploymentCreated(Event.wrap(deploymentEvent)); verify(deploymentDAO, never()).getById(deploymentEvent.getDeploymentId()); verify(deploymentDAO, never()).update(any(Deployment.class)); verify(deploymentEventService, never()).fireDeploymentEvent(any(DeploymentEvent.class)); }
@Selector(value="topic.deployment.status", reactor="@rootReactor") public void deploymentCreated(Event<DeploymentEvent> event) { DeploymentEvent deploymentEvent = event.getData(); if(deploymentEvent.getDeploymentStatus().equals(Dictionary.APPLICATION_STATUS_SUBMITTED)) { logger.info(" Moving deployment id: " + deploymentEvent.getDeploymentId() + " to NEGOTIATION state"); Deployment deployment = deploymentDAO.getById(deploymentEvent.getDeploymentId()); deployment.setStatus(Dictionary.APPLICATION_STATUS_NEGOTIATION); deploymentEvent.setDeploymentStatus(deployment.getStatus()); deploymentDAO.update(deployment); deploymentEventService.fireDeploymentEvent(deploymentEvent); } }
CreatedEventHandler { @Selector(value="topic.deployment.status", reactor="@rootReactor") public void deploymentCreated(Event<DeploymentEvent> event) { DeploymentEvent deploymentEvent = event.getData(); if(deploymentEvent.getDeploymentStatus().equals(Dictionary.APPLICATION_STATUS_SUBMITTED)) { logger.info(" Moving deployment id: " + deploymentEvent.getDeploymentId() + " to NEGOTIATION state"); Deployment deployment = deploymentDAO.getById(deploymentEvent.getDeploymentId()); deployment.setStatus(Dictionary.APPLICATION_STATUS_NEGOTIATION); deploymentEvent.setDeploymentStatus(deployment.getStatus()); deploymentDAO.update(deployment); deploymentEventService.fireDeploymentEvent(deploymentEvent); } } }
CreatedEventHandler { @Selector(value="topic.deployment.status", reactor="@rootReactor") public void deploymentCreated(Event<DeploymentEvent> event) { DeploymentEvent deploymentEvent = event.getData(); if(deploymentEvent.getDeploymentStatus().equals(Dictionary.APPLICATION_STATUS_SUBMITTED)) { logger.info(" Moving deployment id: " + deploymentEvent.getDeploymentId() + " to NEGOTIATION state"); Deployment deployment = deploymentDAO.getById(deploymentEvent.getDeploymentId()); deployment.setStatus(Dictionary.APPLICATION_STATUS_NEGOTIATION); deploymentEvent.setDeploymentStatus(deployment.getStatus()); deploymentDAO.update(deployment); deploymentEventService.fireDeploymentEvent(deploymentEvent); } }  }
CreatedEventHandler { @Selector(value="topic.deployment.status", reactor="@rootReactor") public void deploymentCreated(Event<DeploymentEvent> event) { DeploymentEvent deploymentEvent = event.getData(); if(deploymentEvent.getDeploymentStatus().equals(Dictionary.APPLICATION_STATUS_SUBMITTED)) { logger.info(" Moving deployment id: " + deploymentEvent.getDeploymentId() + " to NEGOTIATION state"); Deployment deployment = deploymentDAO.getById(deploymentEvent.getDeploymentId()); deployment.setStatus(Dictionary.APPLICATION_STATUS_NEGOTIATION); deploymentEvent.setDeploymentStatus(deployment.getStatus()); deploymentDAO.update(deployment); deploymentEventService.fireDeploymentEvent(deploymentEvent); } }  @Selector(value="topic.deployment.status", reactor="@rootReactor") void deploymentCreated(Event<DeploymentEvent> event); }
CreatedEventHandler { @Selector(value="topic.deployment.status", reactor="@rootReactor") public void deploymentCreated(Event<DeploymentEvent> event) { DeploymentEvent deploymentEvent = event.getData(); if(deploymentEvent.getDeploymentStatus().equals(Dictionary.APPLICATION_STATUS_SUBMITTED)) { logger.info(" Moving deployment id: " + deploymentEvent.getDeploymentId() + " to NEGOTIATION state"); Deployment deployment = deploymentDAO.getById(deploymentEvent.getDeploymentId()); deployment.setStatus(Dictionary.APPLICATION_STATUS_NEGOTIATION); deploymentEvent.setDeploymentStatus(deployment.getStatus()); deploymentDAO.update(deployment); deploymentEventService.fireDeploymentEvent(deploymentEvent); } }  @Selector(value="topic.deployment.status", reactor="@rootReactor") void deploymentCreated(Event<DeploymentEvent> event);  }