diff options
14 files changed, 219 insertions, 209 deletions
diff --git a/.gitignore b/.gitignore index 8eeea7a8cc..79d2c94622 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ target **/.buildpath **/.factorypath **/.springBeans +**/.project +**/.classpath .idea .checkstyle .DS_Store diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java index 8207c7c589..f5464645d6 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java @@ -70,6 +70,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; +import org.springframework.web.client.HttpClientErrorException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Strings; @@ -1191,7 +1192,11 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { InfraActiveRequests request = new InfraActiveRequests(); request.setRequestId(requestId); request.setResourceStatusMessage(resourceStatusMessage); - requestDBClient.patchInfraActiveRequests(request); + try { + requestDBClient.patchInfraActiveRequests(request); + } catch (HttpClientErrorException e) { + logger.warn("Unable to update active request resource status"); + } } } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml index bb322eb1d8..977541cc16 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml +++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml @@ -91,6 +91,24 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>${project.basedir}/target/generated-sources/vnfmadapter/src/gen/java/main</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> <dependencies> diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml index a643aaa5b8..dacd5d96b6 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml +++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml @@ -132,6 +132,29 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>${project.basedir}/target/generated-sources/etsicatalog/src/gen/java/main</source> + <source>${project.basedir}/target/generated-sources/sol003-vnf-packagemanagement/src/gen/java/main</source> + <source>${project.basedir}/target/generated-sources/sol003-vnf-grant/src/gen/java/main</source> + <source>${project.basedir}/target/generated-sources/sol003-vnf-lcn/src/gen/java/main</source> + <source>${project.basedir}/target/generated-sources/sol003-vnf-lcm/src/gen/java/main</source> + + </sources> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml index c817874fb6..5d9c1a3acd 100644 --- a/bpmn/MSOCommonBPMN/pom.xml +++ b/bpmn/MSOCommonBPMN/pom.xml @@ -1,5 +1,6 @@ <?xml version="1.0"?> -<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> @@ -21,18 +22,23 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <executions> - <execution> - <id>test-compile</id> - <phase>compile</phase> - <goals> - <goal>testCompile</goal> - </goals> - <configuration> - <skip>false</skip> - </configuration> - </execution> - </executions> + <version>3.8.0</version> + <configuration> + <compilerId>groovy-eclipse-compiler</compilerId> + </configuration> + + <dependencies> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-eclipse-compiler</artifactId> + <version>3.6.0-03</version> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-eclipse-batch</artifactId> + <version>2.4.19-01</version> + </dependency> + </dependencies> </plugin> <plugin> @@ -60,64 +66,6 @@ </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-eclipse-plugin</artifactId> - <version>2.8</version> - <configuration> - <additionalProjectnatures> - <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature> - </additionalProjectnatures> - <sourceIncludes> - <sourceInclude>**/*.groovy</sourceInclude> - </sourceIncludes> - </configuration> - </plugin> - <plugin> - <artifactId>maven-antrun-plugin</artifactId> - <executions> - <execution> - <id>compile</id> - <phase>compile</phase> - <configuration> - <tasks> - <mkdir dir="${basedir}/src/main/groovy" /> - <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc"> - <classpath refid="maven.compile.classpath" /> - </taskdef> - <mkdir dir="${project.build.outputDirectory}" /> - <groovyc destdir="${project.build.outputDirectory}" srcdir="${basedir}/src/main/groovy/" - listfiles="true"> - <classpath refid="maven.compile.classpath" /> - </groovyc> - </tasks> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - <execution> - <id>test-compile</id> - <phase>test-compile</phase> - <configuration> - <tasks> - <mkdir dir="${basedir}/src/test/groovy" /> - <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc"> - <classpath refid="maven.test.classpath" /> - </taskdef> - <mkdir dir="${project.build.testOutputDirectory}" /> - <groovyc destdir="${project.build.testOutputDirectory}" srcdir="${basedir}/src/test/groovy/" - listfiles="true"> - <classpath refid="maven.test.classpath" /> - </groovyc> - </tasks> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <executions> <execution> @@ -161,8 +109,8 @@ </plugins> <pluginManagement> <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings - only. It has no influence on the Maven build itself. --> + <!--This plugin's configuration is used to store Eclipse m2e settings + only. It has no influence on the Maven build itself. --> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> @@ -173,14 +121,14 @@ <pluginExecution> <pluginExecutionFilter> <groupId> - org.apache.maven.plugins - </groupId> + org.apache.maven.plugins + </groupId> <artifactId> - maven-antrun-plugin - </artifactId> + maven-antrun-plugin + </artifactId> <versionRange> - [1.3,) - </versionRange> + [1.3,) + </versionRange> <goals> <goal>run</goal> </goals> diff --git a/bpmn/so-bpmn-infrastructure-common/pom.xml b/bpmn/so-bpmn-infrastructure-common/pom.xml index 0df3fbe704..1a4e9c6ee8 100644 --- a/bpmn/so-bpmn-infrastructure-common/pom.xml +++ b/bpmn/so-bpmn-infrastructure-common/pom.xml @@ -18,51 +18,6 @@ </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-eclipse-plugin</artifactId> - <version>2.8</version> - <configuration> - <additionalProjectnatures> - <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature> - </additionalProjectnatures> - <sourceIncludes> - <sourceInclude>**/*.groovy</sourceInclude> - </sourceIncludes> - </configuration> - </plugin> - <plugin> - <groupId>org.codehaus.gmaven</groupId> - <artifactId>gmaven-plugin</artifactId> - <version>1.5</version> - <dependencies> - <dependency> - <groupId>org.codehaus.gmaven.runtime</groupId> - <artifactId>gmaven-runtime-2.0</artifactId> - <version>1.5</version> - </dependency> - <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy</artifactId> - <version>${groovy.version}</version> - </dependency> - </dependencies> - <configuration> - <debug>false</debug> - <verbose>true</verbose> - <stacktrace>true</stacktrace> - <defaultScriptExtension>.groovy</defaultScriptExtension> - <providerSelection>2.0</providerSelection> - </configuration> - <executions> - <execution> - <goals> - <goal>testCompile</goal> - <goal>compile</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> </plugin> <plugin> @@ -77,41 +32,30 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.0</version> + <configuration> + <compilerId>groovy-eclipse-compiler</compilerId> + </configuration> + + <dependencies> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-eclipse-compiler</artifactId> + <version>3.6.0-03</version> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-eclipse-batch</artifactId> + <version>2.4.19-01</version> + </dependency> + </dependencies> + </plugin> </plugins> <pluginManagement> <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings - only. It has no influence on the Maven build itself. --> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> - <pluginExecution> - <pluginExecutionFilter> - <groupId> - org.apache.maven.plugins - </groupId> - <artifactId> - maven-antrun-plugin - </artifactId> - <versionRange> - [1.3,) - </versionRange> - <goals> - <goal>run</goal> - </goals> - </pluginExecutionFilter> - <action> - <ignore /> - </action> - </pluginExecution> - </pluginExecutions> - </lifecycleMappingMetadata> - </configuration> - </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy index ae239d9e68..bdeaec266f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy @@ -1,7 +1,6 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.so.bpmn.core.domain.AllottedResource import org.onap.aai.domain.yang.AllottedResource import static org.apache.commons.lang3.StringUtils.*; diff --git a/bpmn/so-bpmn-tasks/pom.xml b/bpmn/so-bpmn-tasks/pom.xml index 14081960e6..cffb67a968 100644 --- a/bpmn/so-bpmn-tasks/pom.xml +++ b/bpmn/so-bpmn-tasks/pom.xml @@ -78,6 +78,24 @@ <generateSupportingFiles>false</generateSupportingFiles> </configuration> </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>${project.basedir}/target/generated-sources/src/gen/java/main</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> <dependencyManagement> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index 33b60a9ed3..a162088cb2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -128,62 +128,23 @@ public class AAIUpdateTasks { /** * BPMN access method to update status of VolumeGroup to Assigned in AAI - * - * @param execution */ public void updateOrchestrationStatusAssignedVolumeGroup(BuildingBlockExecution execution) { - try { - GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); - - VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID); - CloudRegion cloudRegion = gBBInput.getCloudRegion(); - volumeGroup.setHeatStackId(""); - aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, - OrchestrationStatus.ASSIGNED); - } catch (Exception ex) { - logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusAssignedVolumeGroup", ex); - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); - } + updateOrchestrationStatusForVolumeGroup(execution, OrchestrationStatus.ASSIGNED); } /** * BPMN access method to update status of VolumeGroup to Active in AAI - * - * @param execution */ public void updateOrchestrationStatusActiveVolumeGroup(BuildingBlockExecution execution) { - try { - GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); - - VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID); - CloudRegion cloudRegion = gBBInput.getCloudRegion(); - - aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, - OrchestrationStatus.ACTIVE); - } catch (Exception ex) { - logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusActiveVolumeGroup", ex); - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); - } + updateOrchestrationStatusForVolumeGroup(execution, OrchestrationStatus.ACTIVE); } /** * BPMN access method to update status of VolumeGroup to Created in AAI - * - * @param execution */ public void updateOrchestrationStatusCreatedVolumeGroup(BuildingBlockExecution execution) { - try { - GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); - - VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID); - CloudRegion cloudRegion = gBBInput.getCloudRegion(); - - aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, - OrchestrationStatus.CREATED); - } catch (Exception ex) { - logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusCreatedVolumeGroup", ex); - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); - } + updateOrchestrationStatusForVolumeGroup(execution, OrchestrationStatus.CREATED); } /** @@ -824,4 +785,19 @@ public class AAIUpdateTasks { } } + private void updateOrchestrationStatusForVolumeGroup(BuildingBlockExecution execution, OrchestrationStatus status) { + try { + VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID); + if (status.equals(OrchestrationStatus.ASSIGNED)) { + volumeGroup.setHeatStackId(""); + } + aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, + execution.getGeneralBuildingBlock().getCloudRegion(), status); + } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks during update orchestration status to {} for " + + "volume group", status, ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java index 33c2ac80be..c43a050500 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.TimeUnit; import javax.transaction.Transactional; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -73,6 +74,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.v3.oas.annotations.OpenAPIDefinition; @@ -105,6 +107,9 @@ public class OrchestrationRequests { @Autowired private CamundaRequestHandler camundaRequestHandler; + @Autowired + private Environment env; + @GET @Path("/{version:[vV][4-8]}/{requestId}") @Operation(description = "Find Orchestrated Requests for a given requestId", responses = @ApiResponse( @@ -436,12 +441,14 @@ public class OrchestrationRequests { String retryStatusMessage = iar.getRetryStatusMessage(); String taskName = null; - if (format == null || !format.equalsIgnoreCase(OrchestrationRequestFormat.SIMPLENOTASKINFO.toString())) { - if (flowStatusMessage != null && !flowStatusMessage.equals("Successfully completed all Building Blocks") - && !flowStatusMessage.equals("All Rollback flows have completed successfully")) { - taskName = camundaRequestHandler.getTaskName(iar.getRequestId()); - if (taskName != null) { - flowStatusMessage = flowStatusMessage + " TASK INFORMATION: " + taskName; + if (daysSinceRequest(iar) <= camundaCleanupInterval()) { + if (format == null || !format.equalsIgnoreCase(OrchestrationRequestFormat.SIMPLENOTASKINFO.toString())) { + if (flowStatusMessage != null && !flowStatusMessage.equals("Successfully completed all Building Blocks") + && !flowStatusMessage.equals("All Rollback flows have completed successfully")) { + taskName = camundaRequestHandler.getTaskName(iar.getRequestId()); + if (taskName != null) { + flowStatusMessage = flowStatusMessage + " TASK INFORMATION: " + taskName; + } } } } @@ -594,4 +601,20 @@ public class OrchestrationRequests { } return infraActiveRequest; } + + protected long daysSinceRequest(InfraActiveRequests request) { + long startTime = request.getStartTime().getTime(); + long now = System.currentTimeMillis(); + + return TimeUnit.MILLISECONDS.toDays(now - startTime); + } + + protected int camundaCleanupInterval() { + String cleanupInterval = env.getProperty("mso.camundaCleanupInterval"); + int days = 30; + if (cleanupInterval != null) { + days = Integer.parseInt(cleanupInterval); + } + return days; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml index baa7af77a5..b46690f2a7 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml +++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml @@ -30,6 +30,7 @@ mso: uri: /sobpmnengine/history/activity-instance camundaURL: http://localhost:8089 camundaAuth: E8E19DD16CC90D2E458E8FF9A884CC0452F8F3EB8E321F96038DE38D5C1B0B02DFAE00B88E2CF6E2A4101AB2C011FC161212EE + camundaCleanupInterval: 30 spring: datasource: diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java index 4631b53bc0..3db2b2d96d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java @@ -29,6 +29,11 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.temporal.ChronoUnit; import javax.ws.rs.core.Response; import org.apache.commons.lang.StringUtils; import org.junit.Before; @@ -41,6 +46,7 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.apihandler.common.ResponseBuilder; import org.onap.so.apihandlerinfra.exceptions.ApiException; +import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.constants.OrchestrationRequestFormat; import org.onap.so.constants.Status; @@ -49,6 +55,7 @@ import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.serviceinstancebeans.InstanceReferences; import org.onap.so.serviceinstancebeans.Request; import org.onap.so.serviceinstancebeans.RequestStatus; +import org.springframework.core.env.Environment; @RunWith(MockitoJUnitRunner.class) public class OrchestrationRequestsUnitTest { @@ -62,6 +69,8 @@ public class OrchestrationRequestsUnitTest { private Response response; @Mock private CamundaRequestHandler camundaRequestHandler; + @Mock + private Environment env; @Rule public ExpectedException thrown = ExpectedException.none(); @InjectMocks @@ -79,6 +88,7 @@ public class OrchestrationRequestsUnitTest { private InfraActiveRequests iar; boolean includeCloudRequest = false; private static final String ROLLBACK_EXT_SYSTEM_ERROR_SOURCE = "SDNC"; + private Timestamp startTime = new Timestamp(System.currentTimeMillis()); @Before @@ -93,6 +103,7 @@ public class OrchestrationRequestsUnitTest { iar.setRollbackStatusMessage(ROLLBACK_STATUS_MESSAGE); iar.setRetryStatusMessage(RETRY_STATUS_MESSAGE); iar.setResourceStatusMessage("The vf module already exist"); + iar.setStartTime(startTime); } @Test @@ -113,6 +124,7 @@ public class OrchestrationRequestsUnitTest { expected.setInstanceReferences(instanceReferences); expected.setRequestStatus(requestStatus); expected.setRequestScope(SERVICE); + expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); iar.setOriginalRequestId(ORIGINAL_REQUEST_ID); @@ -138,6 +150,7 @@ public class OrchestrationRequestsUnitTest { expected.setInstanceReferences(instanceReferences); expected.setRequestStatus(requestStatus); expected.setRequestScope(SERVICE); + expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, OrchestrationRequestFormat.DETAIL.toString(), "v7"); @@ -161,6 +174,7 @@ public class OrchestrationRequestsUnitTest { expected.setInstanceReferences(instanceReferences); expected.setRequestStatus(requestStatus); expected.setRequestScope(SERVICE); + expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); includeCloudRequest = false; @@ -187,6 +201,7 @@ public class OrchestrationRequestsUnitTest { expected.setInstanceReferences(instanceReferences); expected.setRequestStatus(requestStatus); expected.setRequestScope(SERVICE); + expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); includeCloudRequest = false; @@ -214,6 +229,7 @@ public class OrchestrationRequestsUnitTest { expected.setInstanceReferences(instanceReferences); expected.setRequestStatus(requestStatus); expected.setRequestScope(SERVICE); + expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); includeCloudRequest = false; @@ -236,6 +252,7 @@ public class OrchestrationRequestsUnitTest { expected.setInstanceReferences(instanceReferences); expected.setRequestStatus(requestStatus); expected.setRequestScope(SERVICE); + expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); includeCloudRequest = false; @@ -259,6 +276,7 @@ public class OrchestrationRequestsUnitTest { expected.setInstanceReferences(instanceReferences); expected.setRequestStatus(requestStatus); expected.setRequestScope(SERVICE); + expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); includeCloudRequest = false; @@ -283,6 +301,7 @@ public class OrchestrationRequestsUnitTest { expected.setInstanceReferences(instanceReferences); expected.setRequestStatus(requestStatus); expected.setRequestScope(SERVICE); + expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); includeCloudRequest = false; @@ -306,6 +325,7 @@ public class OrchestrationRequestsUnitTest { expected.setInstanceReferences(instanceReferences); expected.setRequestStatus(requestStatus); expected.setRequestScope(SERVICE); + expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); includeCloudRequest = false; iar.setFlowStatus(null); @@ -348,6 +368,7 @@ public class OrchestrationRequestsUnitTest { expected.setInstanceReferences(instanceReferences); expected.setRequestStatus(requestStatus); expected.setRequestScope(SERVICE); + expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); includeCloudRequest = false; iar.setFlowStatus("Successfully completed all Building Blocks"); @@ -374,6 +395,7 @@ public class OrchestrationRequestsUnitTest { expected.setInstanceReferences(instanceReferences); expected.setRequestStatus(requestStatus); expected.setRequestScope(SERVICE); + expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT"); includeCloudRequest = false; iar.setFlowStatus("All Rollback flows have completed successfully"); @@ -431,4 +453,35 @@ public class OrchestrationRequestsUnitTest { assertFalse(required); } + @Test + public void taskNameLookup() throws ContactCamundaException { + InfraActiveRequests req = new InfraActiveRequests(); + req.setRequestId("70debc2a-d6bc-4795-87ba-38a94d9b0b99"); + Instant startInstant = Instant.now().minus(1, ChronoUnit.DAYS); + req.setStartTime(Timestamp.from(startInstant)); + when(env.getProperty("mso.camundaCleanupInterval")).thenReturn(null); + when(camundaRequestHandler.getTaskName("70debc2a-d6bc-4795-87ba-38a94d9b0b99")).thenReturn("taskName"); + + RequestStatus requestStatus = new RequestStatus(); + req.setFlowStatus("Building blocks 1 of 3 completed."); + + orchestrationRequests.mapRequestStatusAndExtSysErrSrcToRequest(req, requestStatus, null, "v7"); + assertEquals("FLOW STATUS: Building blocks 1 of 3 completed. TASK INFORMATION: taskName", + requestStatus.getStatusMessage()); + } + + @Test + public void noCamundaLookupAfterInterval() throws ContactCamundaException { + InfraActiveRequests req = new InfraActiveRequests(); + req.setRequestId("70debc2a-d6bc-4795-87ba-38a94d9b0b99"); + Instant startInstant = Instant.now().minus(36, ChronoUnit.DAYS); + req.setStartTime(Timestamp.from(startInstant)); + when(env.getProperty("mso.camundaCleanupInterval")).thenReturn("35"); + + RequestStatus requestStatus = new RequestStatus(); + req.setFlowStatus("Building blocks 1 of 3 completed."); + + orchestrationRequests.mapRequestStatusAndExtSysErrSrcToRequest(req, requestStatus, null, "v7"); + assertEquals("FLOW STATUS: Building blocks 1 of 3 completed.", requestStatus.getStatusMessage()); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json index 96fed36d45..3b2eca7ce2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json @@ -61,7 +61,7 @@ }, "requestStatus": { "requestState": "COMPLETE", - "statusMessage": "STATUS: Vf Module has been deleted successfully. FLOW STATUS: Building blocks 1 of 3 completed. TASK INFORMATION: Last task executed: BB to Execute ROLLBACK STATUS: Rollback has been completed successfully.", + "statusMessage": "STATUS: Vf Module has been deleted successfully. FLOW STATUS: Building blocks 1 of 3 completed. ROLLBACK STATUS: Rollback has been completed successfully.", "percentProgress": 100, "timestamp": "Thu, 22 Dec 2016 08:30:28 GMT" } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json index 801841313a..baddb21617 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json @@ -58,7 +58,7 @@ }, "requestStatus":{ "requestState":"PENDING", - "statusMessage":"FLOW STATUS: Building blocks 1 of 3 completed. TASK INFORMATION: Last task executed: BB to Execute RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.", + "statusMessage":"FLOW STATUS: Building blocks 1 of 3 completed. RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.", "percentProgress":0, "timestamp": "Thu, 22 Dec 2016 08:30:28 GMT" } @@ -321,7 +321,7 @@ }, "requestStatus":{ "requestState":"PENDING", - "statusMessage":"STATUS: Adding members. FLOW STATUS: Building blocks 1 of 3 completed. TASK INFORMATION: Last task executed: BB to Execute RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.", + "statusMessage":"STATUS: Adding members. FLOW STATUS: Building blocks 1 of 3 completed. RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.", "percentProgress":0, "timestamp": "Thu, 22 Dec 2016 08:30:28 GMT" } |