Skip to content

Commit

Permalink
fix deploy mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
LuciaM1 committed Dec 4, 2023
1 parent c35dddd commit 82cea63
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ public Uni<BpmnVersion> setDeployInfo(BpmnVersionPK key, DeployResponseDto respo
}
DeployedBPMNProcessDefinitionDto deployedProcessInfo = optionalDeployedProcessInfo.get();
bpmnVersion.setDefinitionVersionCamunda(deployedProcessInfo.getVersion());
bpmnVersion.setDeploymentId(deployedProcessInfo.getDeploymentId());
bpmnVersion.setCamundaDefinitionId(response.getId());
bpmnVersion.setDeploymentId(UUID.fromString(response.getId()));
bpmnVersion.setCamundaDefinitionId(deployedProcessInfo.getId());
bpmnVersion.setDeployedFileName(deployedProcessInfo.getName());
bpmnVersion.setDescription(deployedProcessInfo.getDescription());
bpmnVersion.setResource(deployedProcessInfo.getResource());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ public Uni<WorkflowResource> setDeployInfo(UUID uuid, DeployResponseDto response
}
DeployedBPMNProcessDefinitionDto deployedProcessInfo = optionalDeployedProcessDefinition.get();
workflowResource.setDefinitionVersionCamunda(deployedProcessInfo.getVersion());
workflowResource.setDeploymentId(deployedProcessInfo.getDeploymentId());
workflowResource.setDeployedFileName(deployedProcessInfo.getName());
workflowResource.setDescription(deployedProcessInfo.getDescription());
workflowResource.setResource(deployedProcessInfo.getResource());
workflowResource.setStatus(StatusEnum.DEPLOYED);
workflowResource.setCamundaDefinitionId(deployedProcessInfo.getId());
} else if (response.getDeployedDecisionDefinitions() != null) {
Map<String, DeployedDMNDecisionDefinitionDto> deployedDecisionDefinitions = response.getDeployedDecisionDefinitions();
Optional<DeployedDMNDecisionDefinitionDto> optionalDeployedDecisionDefinition = deployedDecisionDefinitions.values()
Expand All @@ -219,15 +219,15 @@ public Uni<WorkflowResource> setDeployInfo(UUID uuid, DeployResponseDto response
}
DeployedDMNDecisionDefinitionDto deployedDecisionDefinition = optionalDeployedDecisionDefinition.get();
workflowResource.setDefinitionVersionCamunda(deployedDecisionDefinition.getVersion());
workflowResource.setDeploymentId(deployedDecisionDefinition.getDeploymentId());
workflowResource.setDeployedFileName(deployedDecisionDefinition.getName());
workflowResource.setResource(deployedDecisionDefinition.getResource());
workflowResource.setStatus(StatusEnum.DEPLOYED);
workflowResource.setCamundaDefinitionId(deployedDecisionDefinition.getId());
} else {
workflowResource.setDeployedFileName(response.getName());
workflowResource.setStatus(StatusEnum.DEPLOYED);
}
workflowResource.setCamundaDefinitionId(response.getId());
workflowResource.setDeploymentId(UUID.fromString(response.getId()));
return this.workflowResourceRepository.persist(workflowResource);
}));
}
Expand Down Expand Up @@ -343,11 +343,11 @@ public Uni<WorkflowResource> rollback(UUID id) {
if (workflowResourceToRollBack.getStatus().getValue().equals(StatusEnum.DEPLOYED.getValue())) {
throw new AtmLayerException("Cannot rollback: the referenced resource is the latest version deployed", Response.Status.BAD_REQUEST, WORKFLOW_RESOURCE_CANNOT_BE_ROLLED_BACK);
}
String camundaId = workflowResourceToRollBack.getCamundaDefinitionId();
if (camundaId == null) {
String deploymentId = String.valueOf(workflowResourceToRollBack.getDeploymentId());
if (deploymentId.equals("null")) {
throw new AtmLayerException("CamundaDefinitionId of the referenced resource is null: cannot rollback", Response.Status.NOT_FOUND, WORKFLOW_RESOURCE_NOT_DEPLOYED_CANNOT_ROLLBACK);
}
return processClient.getDeployedResource(camundaId)
return processClient.getDeployedResource(deploymentId)
.onFailure()
.recoverWithUni(exception ->
Uni.createFrom().failure(new AtmLayerException("Error retrieving workflow resource from Process", Response.Status.INTERNAL_SERVER_ERROR, DEPLOYED_FILE_WAS_NOT_RETRIEVED)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ void testDeployOK() throws MalformedURLException {
Map<String, DeployedBPMNProcessDefinitionDto> deployedProcessDefinitions=new HashMap<>();
deployedProcessDefinitions.put("key",processInfo);
response.setDeployedProcessDefinitions(deployedProcessDefinitions);
response.setId(UUID.randomUUID().toString());
when(bpmnVersionRepoMock.findById(any(BpmnVersionPK.class))).thenReturn(Uni.createFrom().item(bpmnVersion));
when(bpmnFileStorageServiceMock.generatePresignedUrl(any(String.class))).thenReturn(Uni.createFrom().item(url));
when(processClientMock.deploy(any(String.class),eq(DeployableResourceType.BPMN.name()))).thenReturn(Uni.createFrom().item(response));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ void testRollbackOK() throws NoSuchAlgorithmException, IOException {
File expectedFile = new File("src/test/resources/Test.bpmn");
WorkflowResource expectedWorkflowResource=new WorkflowResource();
expectedWorkflowResource.setStatus(StatusEnum.UPDATED_BUT_NOT_DEPLOYED);
expectedWorkflowResource.setCamundaDefinitionId("camundaId");
expectedWorkflowResource.setDeploymentId(UUID.randomUUID());
expectedWorkflowResource.setResourceType(DeployableResourceType.BPMN);
expectedWorkflowResource.setSha256("sha256");
ResourceFile resourceFile=new ResourceFile();
Expand Down Expand Up @@ -382,7 +382,7 @@ void testRollbackNeverDeployed(){
void testRollbackProcessFailure(){
WorkflowResource expectedWorkflowResource=new WorkflowResource();
expectedWorkflowResource.setStatus(StatusEnum.UPDATED_BUT_NOT_DEPLOYED);
expectedWorkflowResource.setCamundaDefinitionId("camundaId");
expectedWorkflowResource.setDeploymentId(UUID.randomUUID());
when(workflowResourceRepository.findById(any(UUID.class))).thenReturn(Uni.createFrom().item(expectedWorkflowResource));
when(processClient.getDeployedResource(any(String.class))).thenReturn(Uni.createFrom().failure(new RuntimeException()));
workflowResourceService.rollback(UUID.randomUUID())
Expand Down

0 comments on commit 82cea63

Please sign in to comment.