@Test public void handleShouldStoreProcessDefinitionAndProcessModel() { ProcessDefinitionImpl eventProcess = new ProcessDefinitionImpl(); eventProcess.setId(UUID.randomUUID().toString()); eventProcess.setKey("myProcess"); eventProcess.setName("My Process"); eventProcess.setDescription("This is my process description"); eventProcess.setFormKey("formKey"); eventProcess.setVersion(2); CloudProcessDeployedEventImpl processDeployedEvent = new CloudProcessDeployedEventImpl(eventProcess); processDeployedEvent.setAppName("myApp"); processDeployedEvent.setAppVersion("2.1"); processDeployedEvent.setServiceFullName("my.full.service.name"); processDeployedEvent.setServiceName("name"); processDeployedEvent.setServiceType("runtime-bundle"); processDeployedEvent.setServiceVersion("1.0"); processDeployedEvent.setProcessModelContent("<model/>"); handler.handle(processDeployedEvent); ArgumentCaptor<ProcessDefinitionEntity> processDefinitionCaptor = ArgumentCaptor.forClass(ProcessDefinitionEntity.class); verify(processDefinitionRepository).save(processDefinitionCaptor.capture()); ProcessDefinitionEntity storedProcess = processDefinitionCaptor.getValue(); assertThat(storedProcess) .hasId(eventProcess.getId()) .hasKey(eventProcess.getKey()) .hasName(eventProcess.getName()) .hasDescription(eventProcess.getDescription()) .hasFormKey(eventProcess.getFormKey()) .hasVersion(eventProcess.getVersion()) .hasAppName(processDeployedEvent.getAppName()) .hasAppVersion(processDeployedEvent.getAppVersion()) .hasServiceFullName(processDeployedEvent.getServiceFullName()) .hasServiceName(processDeployedEvent.getServiceName()) .hasServiceType(processDeployedEvent.getServiceType()) .hasServiceVersion(processDeployedEvent.getServiceVersion()); ArgumentCaptor<ProcessModelEntity> processModelCaptor = ArgumentCaptor.forClass(ProcessModelEntity.class); verify(processModelRepository).save(processModelCaptor.capture()); assertThat(processModelCaptor.getValue()) .hasProcessModelContent("<model/>"); }
@Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessDeployedEvent processDeployedEvent = (CloudProcessDeployedEvent) event; ProcessDefinition eventProcessDefinition = processDeployedEvent.getEntity(); LOGGER.debug("Handling process deployed event for " + eventProcessDefinition.getKey()); ProcessDefinitionEntity processDefinition = new ProcessDefinitionEntity(processDeployedEvent.getServiceName(), processDeployedEvent.getServiceFullName(), processDeployedEvent.getServiceVersion(), processDeployedEvent.getAppName(), processDeployedEvent.getAppVersion()); processDefinition.setId(eventProcessDefinition.getId()); processDefinition.setDescription(eventProcessDefinition.getDescription()); processDefinition.setFormKey(eventProcessDefinition.getFormKey()); processDefinition.setKey(eventProcessDefinition.getKey()); processDefinition.setName(eventProcessDefinition.getName()); processDefinition.setVersion(eventProcessDefinition.getVersion()); processDefinition.setServiceType(processDeployedEvent.getServiceType()); processDefinitionRepository.save(processDefinition); ProcessModelEntity processModelEntity = new ProcessModelEntity(processDefinition, processDeployedEvent.getProcessModelContent()); processModelEntity.setId(processDefinition.getId()); processModelRepository.save(processModelEntity); }
ProcessDeployedEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessDeployedEvent processDeployedEvent = (CloudProcessDeployedEvent) event; ProcessDefinition eventProcessDefinition = processDeployedEvent.getEntity(); LOGGER.debug("Handling process deployed event for " + eventProcessDefinition.getKey()); ProcessDefinitionEntity processDefinition = new ProcessDefinitionEntity(processDeployedEvent.getServiceName(), processDeployedEvent.getServiceFullName(), processDeployedEvent.getServiceVersion(), processDeployedEvent.getAppName(), processDeployedEvent.getAppVersion()); processDefinition.setId(eventProcessDefinition.getId()); processDefinition.setDescription(eventProcessDefinition.getDescription()); processDefinition.setFormKey(eventProcessDefinition.getFormKey()); processDefinition.setKey(eventProcessDefinition.getKey()); processDefinition.setName(eventProcessDefinition.getName()); processDefinition.setVersion(eventProcessDefinition.getVersion()); processDefinition.setServiceType(processDeployedEvent.getServiceType()); processDefinitionRepository.save(processDefinition); ProcessModelEntity processModelEntity = new ProcessModelEntity(processDefinition, processDeployedEvent.getProcessModelContent()); processModelEntity.setId(processDefinition.getId()); processModelRepository.save(processModelEntity); } }
ProcessDeployedEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessDeployedEvent processDeployedEvent = (CloudProcessDeployedEvent) event; ProcessDefinition eventProcessDefinition = processDeployedEvent.getEntity(); LOGGER.debug("Handling process deployed event for " + eventProcessDefinition.getKey()); ProcessDefinitionEntity processDefinition = new ProcessDefinitionEntity(processDeployedEvent.getServiceName(), processDeployedEvent.getServiceFullName(), processDeployedEvent.getServiceVersion(), processDeployedEvent.getAppName(), processDeployedEvent.getAppVersion()); processDefinition.setId(eventProcessDefinition.getId()); processDefinition.setDescription(eventProcessDefinition.getDescription()); processDefinition.setFormKey(eventProcessDefinition.getFormKey()); processDefinition.setKey(eventProcessDefinition.getKey()); processDefinition.setName(eventProcessDefinition.getName()); processDefinition.setVersion(eventProcessDefinition.getVersion()); processDefinition.setServiceType(processDeployedEvent.getServiceType()); processDefinitionRepository.save(processDefinition); ProcessModelEntity processModelEntity = new ProcessModelEntity(processDefinition, processDeployedEvent.getProcessModelContent()); processModelEntity.setId(processDefinition.getId()); processModelRepository.save(processModelEntity); } ProcessDeployedEventHandler(ProcessDefinitionRepository processDefinitionRepository,
                                       ProcessModelRepository processModelRepository); }
ProcessDeployedEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessDeployedEvent processDeployedEvent = (CloudProcessDeployedEvent) event; ProcessDefinition eventProcessDefinition = processDeployedEvent.getEntity(); LOGGER.debug("Handling process deployed event for " + eventProcessDefinition.getKey()); ProcessDefinitionEntity processDefinition = new ProcessDefinitionEntity(processDeployedEvent.getServiceName(), processDeployedEvent.getServiceFullName(), processDeployedEvent.getServiceVersion(), processDeployedEvent.getAppName(), processDeployedEvent.getAppVersion()); processDefinition.setId(eventProcessDefinition.getId()); processDefinition.setDescription(eventProcessDefinition.getDescription()); processDefinition.setFormKey(eventProcessDefinition.getFormKey()); processDefinition.setKey(eventProcessDefinition.getKey()); processDefinition.setName(eventProcessDefinition.getName()); processDefinition.setVersion(eventProcessDefinition.getVersion()); processDefinition.setServiceType(processDeployedEvent.getServiceType()); processDefinitionRepository.save(processDefinition); ProcessModelEntity processModelEntity = new ProcessModelEntity(processDefinition, processDeployedEvent.getProcessModelContent()); processModelEntity.setId(processDefinition.getId()); processModelRepository.save(processModelEntity); } ProcessDeployedEventHandler(ProcessDefinitionRepository processDefinitionRepository,
                                       ProcessModelRepository processModelRepository); @Override void handle(CloudRuntimeEvent<?, ?> event); @Override String getHandledEvent(); }
ProcessDeployedEventHandler implements QueryEventHandler { @Override public void handle(CloudRuntimeEvent<?, ?> event) { CloudProcessDeployedEvent processDeployedEvent = (CloudProcessDeployedEvent) event; ProcessDefinition eventProcessDefinition = processDeployedEvent.getEntity(); LOGGER.debug("Handling process deployed event for " + eventProcessDefinition.getKey()); ProcessDefinitionEntity processDefinition = new ProcessDefinitionEntity(processDeployedEvent.getServiceName(), processDeployedEvent.getServiceFullName(), processDeployedEvent.getServiceVersion(), processDeployedEvent.getAppName(), processDeployedEvent.getAppVersion()); processDefinition.setId(eventProcessDefinition.getId()); processDefinition.setDescription(eventProcessDefinition.getDescription()); processDefinition.setFormKey(eventProcessDefinition.getFormKey()); processDefinition.setKey(eventProcessDefinition.getKey()); processDefinition.setName(eventProcessDefinition.getName()); processDefinition.setVersion(eventProcessDefinition.getVersion()); processDefinition.setServiceType(processDeployedEvent.getServiceType()); processDefinitionRepository.save(processDefinition); ProcessModelEntity processModelEntity = new ProcessModelEntity(processDefinition, processDeployedEvent.getProcessModelContent()); processModelEntity.setId(processDefinition.getId()); processModelRepository.save(processModelEntity); } ProcessDeployedEventHandler(ProcessDefinitionRepository processDefinitionRepository,
                                       ProcessModelRepository processModelRepository); @Override void handle(CloudRuntimeEvent<?, ?> event); @Override String getHandledEvent();  }