Merge "update the release docs"
authorByung-Woo Jun <byung-woo.jun@est.tech>
Wed, 3 Jun 2020 11:47:10 +0000 (11:47 +0000)
committerGerrit Code Review <gerrit@onap.org>
Wed, 3 Jun 2020 11:47:10 +0000 (11:47 +0000)
26 files changed:
adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/pom.xml
adapters/mso-catalog-db-adapter/pom.xml
adapters/mso-openstack-adapters/pom.xml
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java [new file with mode: 0644]
adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java
adapters/mso-requests-db-adapter/pom.xml
adapters/mso-sdnc-adapter/pom.xml
adapters/so-appc-orchestrator/pom.xml
asdc-controller/pom.xml
asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/WorkflowResourceTest.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java
bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/InstnaceResourceListTest.java
bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/avpn/dmaap/beans/AVPNDmaapBeansTest.java
bpmn/MSOCommonBPMN/src/test/resources/__files/InstanceResourceList/InstanceResourceList.json
bpmn/mso-infrastructure-bpmn/pom.xml
bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationService.java [new file with mode: 0644]
bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingIT.java
bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java [new file with mode: 0644]
bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/activity/DeployActivitySpecsTest.java
docs/conf.py
mso-api-handlers/mso-api-handler-infra/pom.xml
pom.xml
so-simulator/pom.xml

index 8735f98..5b3038f 100644 (file)
@@ -39,6 +39,9 @@
         <executions>
           <execution>
             <id>extract-docker-file</id>
+            <configuration>
+              <skip>false</skip>
+            </configuration>
           </execution>
         </executions>
       </plugin>
index 53af40c..933077b 100644 (file)
     <finalName>${project.artifactId}-${project.version}</finalName>
 
     <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-dependency-plugin</artifactId>
-      </plugin>
       <plugin>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
         <executions>
           <execution>
             <id>extract-docker-file</id>
+            <configuration>
+              <skip>false</skip>
+            </configuration>
           </execution>
         </executions>
       </plugin>
         <executions>
           <execution>
             <id>original</id>
-            <configuration>
-              <skip>false</skip>
-            </configuration>
+            <phase>package</phase>
           </execution>
         </executions>
       </plugin>
index 2f7155b..8cdd37d 100644 (file)
@@ -21,7 +21,6 @@
 
 package org.onap.so.adapters.tasks.audit;
 
-import java.util.Optional;
 import org.onap.so.objects.audit.AAIObjectAudit;
 import org.onap.so.objects.audit.AAIObjectAuditList;
 import org.onap.so.utils.ExternalTaskUtils;
@@ -37,8 +36,6 @@ public abstract class AbstractAuditService extends ExternalTaskUtils {
 
     private static final Logger logger = LoggerFactory.getLogger(AbstractAuditService.class);
 
-
-
     protected static final String UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI =
             "Unable to find all VServers and L-Interaces in A&AI";
 
@@ -52,29 +49,27 @@ public abstract class AbstractAuditService extends ExternalTaskUtils {
     }
 
     /**
-     * @param auditHeatStackFailed
      * @param auditList
      * @return
      */
-    protected boolean didCreateAuditFail(Optional<AAIObjectAuditList> auditList) {
-        if (auditList.get().getAuditList() != null && !auditList.get().getAuditList().isEmpty()) {
+    protected boolean didCreateAuditFail(AAIObjectAuditList auditList) {
+        if (isAuditListNotNullAndNotEmpty(auditList)) {
             if (logger.isInfoEnabled()) {
-                logger.info("Audit Results: {}", auditList.get().toString());
+                logger.info("Audit Results: {}", auditList.toString());
             }
-            return auditList.get().getAuditList().stream().filter(auditObject -> !auditObject.isDoesObjectExist())
-                    .findFirst().map(v -> true).orElse(false);
+            return auditList.getAuditList().stream().filter(auditObject -> !auditObject.isDoesObjectExist()).findFirst()
+                    .map(v -> true).orElse(false);
         } else {
             return false;
         }
     }
 
     /**
-     * @param auditHeatStackFailed
      * @param auditList
      * @return
      */
     protected boolean didDeleteAuditFail(AAIObjectAuditList auditList) {
-        if (auditList.getAuditList() != null && !auditList.getAuditList().isEmpty()) {
+        if (isAuditListNotNullAndNotEmpty(auditList)) {
             if (logger.isInfoEnabled()) {
                 logger.info("Audit Results: {}", auditList.toString());
             }
@@ -84,4 +79,9 @@ public abstract class AbstractAuditService extends ExternalTaskUtils {
             return false;
         }
     }
+
+    private boolean isAuditListNotNullAndNotEmpty(AAIObjectAuditList auditList) {
+        return auditList != null && auditList.getAuditList() != null && !auditList.getAuditList().isEmpty();
+    }
+
 }
index 010475c..c06460c 100644 (file)
@@ -67,7 +67,7 @@ public class AuditCreateStackService extends AbstractAuditService {
                 auditListOpt.get().setHeatStackName(auditInventory.getHeatStackName());
                 GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
                 variables.put("auditInventoryResult", objectMapper.getMapper().writeValueAsString(auditListOpt.get()));
-                success = !didCreateAuditFail(auditListOpt);
+                success = !didCreateAuditFail(auditListOpt.get());
             }
         } catch (Exception e) {
             logger.error("Error during audit of stack", e);
index bbabd7f..32cd92d 100644 (file)
@@ -59,7 +59,6 @@ import org.onap.aai.domain.yang.VfModule;
 import org.onap.aai.domain.yang.Vlan;
 import org.onap.aai.domain.yang.Vlans;
 import org.onap.aai.domain.yang.Vserver;
-import org.onap.logging.filter.base.ErrorCode;
 import org.onap.aaiclient.client.aai.AAIObjectType;
 import org.onap.aaiclient.client.aai.AAIResourcesClient;
 import org.onap.aaiclient.client.aai.AAISingleTransactionClient;
@@ -69,6 +68,7 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
 import org.onap.aaiclient.client.graphinventory.entities.uri.Depth;
 import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed;
+import org.onap.logging.filter.base.ErrorCode;
 import org.onap.so.db.catalog.beans.CloudIdentity;
 import org.onap.so.db.catalog.beans.ServerType;
 import org.onap.so.heatbridge.constants.HeatBridgeConstants;
@@ -263,7 +263,9 @@ public class HeatBridgeImpl implements HeatBridgeApi {
             lIf.setInterfaceId(port.getId());
             lIf.setInterfaceName(port.getName());
             lIf.setMacaddr(port.getMacAddress());
-            lIf.setNetworkName((String) port.getProfile().get("physical_network"));
+            if (port.getProfile() != null && port.getProfile().get("physical_network") != null) {
+                lIf.setNetworkName((String) port.getProfile().get("physical_network"));
+            }
             lIf.setIsPortMirrored(false);
             lIf.setIsIpUnnumbered(false);
             lIf.setInMaint(false);
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java
new file mode 100644 (file)
index 0000000..c70e60e
--- /dev/null
@@ -0,0 +1,51 @@
+package org.onap.so.adapters.tasks.audit;
+
+import org.junit.Test;
+import org.onap.so.objects.audit.AAIObjectAudit;
+import org.onap.so.objects.audit.AAIObjectAuditList;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class AbstractAuditServiceTest extends AbstractAuditService {
+
+    private AAIObjectAuditList getAuditListWithObjectWithExistenceStateOf(boolean existenceState) {
+        AAIObjectAudit auditObject = new AAIObjectAudit();
+        AAIObjectAuditList auditList = new AAIObjectAuditList();
+
+        auditObject.setDoesObjectExist(existenceState);
+        auditList.getAuditList().add(auditObject);
+
+        return auditList;
+    }
+
+    @Test
+    public void didCreateAuditFail_shouldReturnFalse_whenGivenNull() {
+        assertFalse(didCreateAuditFail(null));
+    }
+
+    @Test
+    public void didCreateAuditFail_shouldReturnTrue_whenGivenNotExistingObject() {
+        assertTrue(didCreateAuditFail(getAuditListWithObjectWithExistenceStateOf(false)));
+    }
+
+    @Test
+    public void didCreateAuditFail_shouldReturnFalse_whenGivenExistingObject() {
+        assertFalse(didCreateAuditFail(getAuditListWithObjectWithExistenceStateOf(true)));
+    }
+
+    @Test
+    public void didDeleteAuditFail_shouldReturnFalse_whenGivenNull() {
+        assertFalse(didDeleteAuditFail(null));
+    }
+
+    @Test
+    public void didDeleteAuditFail_shouldReturnTrue_whenGivenExistingObject() {
+        assertTrue(didDeleteAuditFail(getAuditListWithObjectWithExistenceStateOf(true)));
+    }
+
+    @Test
+    public void didDeleteAuditFail_shouldReturnFalse_whenGivenNotExistingObject() {
+        assertFalse(didDeleteAuditFail(getAuditListWithObjectWithExistenceStateOf(false)));
+    }
+
+}
index a10ab4b..78dbcd9 100644 (file)
@@ -179,13 +179,13 @@ public class AuditStackServiceDataTest extends AuditCreateStackService {
 
     @Test
     public void determineAuditResult_Test() throws Exception {
-        boolean actual = auditStackService.didCreateAuditFail(auditListOptSuccess);
+        boolean actual = auditStackService.didCreateAuditFail(auditListOptSuccess.get());
         assertEquals(false, actual);
     }
 
     @Test
     public void determineAuditResult_Failure_Test() throws Exception {
-        boolean actual = auditStackService.didCreateAuditFail(auditListOptFailure);
+        boolean actual = auditStackService.didCreateAuditFail(auditListOptFailure.get());
         assertEquals(true, actual);
     }
 }
index f9026d8..3463642 100644 (file)
         <executions>
           <execution>
             <id>original</id>
-            <configuration>
-              <skip>false</skip>
-            </configuration>
+            <phase>package</phase>
           </execution>
         </executions>
       </plugin>
         <executions>
           <execution>
             <id>extract-docker-file</id>
+            <configuration>
+              <skip>false</skip>
+            </configuration>
           </execution>
         </executions>
       </plugin>
index f54c2ec..3b76c23 100644 (file)
@@ -70,9 +70,7 @@
         <executions>
           <execution>
             <id>original</id>
-            <configuration>
-              <skip>false</skip>
-            </configuration>
+            <phase>package</phase>
           </execution>
         </executions>
       </plugin>
@@ -86,6 +84,9 @@
         <executions>
           <execution>
             <id>extract-docker-file</id>
+            <configuration>
+              <skip>false</skip>
+            </configuration>
           </execution>
         </executions>
       </plugin>
index f8d8fab..f7fc0bc 100644 (file)
@@ -40,6 +40,9 @@
         <executions>
           <execution>
             <id>extract-docker-file</id>
+            <configuration>
+              <skip>false</skip>
+            </configuration>
           </execution>
         </executions>
       </plugin>
index e7e9548..e4c50d3 100644 (file)
         <executions>
           <execution>
             <id>extract-docker-file</id>
+            <configuration>
+              <skip>false</skip>
+            </configuration>
           </execution>
         </executions>
       </plugin>
         <executions>
           <execution>
             <id>original</id>
-            <configuration>
-              <skip>false</skip>
-            </configuration>
+            <phase>package</phase>
           </execution>
         </executions>
       </plugin>
index 5a73621..4e88243 100644 (file)
@@ -124,6 +124,7 @@ public class WorkflowResourceTest extends BaseTest {
         workflow.setWorkflowActivitySpecSequence(wfss);
 
         workflowRepo.save(workflow);
+        assertNotNull(workflow);
 
     }
 
index 3a4df68..963210b 100644 (file)
@@ -109,16 +109,20 @@ public class InstanceResourceList {
         }
 
         // check if the resource contains vf-module
-        if (vnfResource != null && vnfResource.getVfModules() != null) {
+        if (isVnfResourceWithVfModule(vnfResource)) {
             sequencedResourceList.addAll(vnfResource.getVfModules());
         }
 
         return sequencedResourceList;
     }
 
+    private static boolean isVnfResourceWithVfModule(VnfResource vnfResource) {
+        return vnfResource != null && vnfResource.getVfModules() != null;
+    }
+
     private static List<Resource> getGroupResourceInstanceList(VnfResource vnfResource, JsonObject vfObj) {
         List<Resource> sequencedResourceList = new ArrayList<>();
-        if (vnfResource.getGroupOrder() != null && !StringUtils.isEmpty(vnfResource.getGroupOrder())) {
+        if (isVnfGroupOrderFilled(vnfResource)) {
             String[] grpSequence = vnfResource.getGroupOrder().split(",");
             for (String grpType : grpSequence) {
                 for (GroupResource gResource : vnfResource.getGroups()) {
@@ -150,4 +154,8 @@ public class InstanceResourceList {
         }
         return sequencedResourceList;
     }
+
+    private static boolean isVnfGroupOrderFilled(VnfResource vnfResource) {
+        return vnfResource.getGroupOrder() != null && !StringUtils.isEmpty(vnfResource.getGroupOrder());
+    }
 }
index f3233f2..19e678d 100644 (file)
@@ -8,6 +8,7 @@ import org.onap.so.bpmn.core.domain.Resource;
 import org.onap.so.bpmn.core.domain.ResourceType;
 import org.onap.so.bpmn.core.domain.VnfResource;
 import org.onap.so.bpmn.core.domain.VnfcResource;
+import org.onap.so.bpmn.core.domain.ModuleResource;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
@@ -24,7 +25,7 @@ public class InstnaceResourceListTest {
         String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json")));
         List<Resource> instanceResourceList =
                 InstanceResourceList.getInstanceResourceList(createResourceSequence(), uuiRequest);
-        Assert.assertEquals(7, instanceResourceList.size());
+        Assert.assertEquals(9, instanceResourceList.size());
         Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType());
         Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(1).getResourceType());
         Assert.assertEquals("device", instanceResourceList.get(1).getModelInfo().getModelName());
@@ -32,9 +33,12 @@ public class InstnaceResourceListTest {
         Assert.assertEquals("sitewan", instanceResourceList.get(2).getModelInfo().getModelName());
         Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(3).getResourceType());
         Assert.assertEquals("sitewan", instanceResourceList.get(3).getModelInfo().getModelName());
-        Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(4).getResourceType());
-        Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(5).getResourceType());
+        Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(4).getResourceType());
+        Assert.assertEquals("dummy", instanceResourceList.get(4).getModelInfo().getModelName());
+        Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(5).getResourceType());
         Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(6).getResourceType());
+        Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(7).getResourceType());
+        Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(8).getResourceType());
     }
 
     // Test when PK is empty
@@ -48,6 +52,63 @@ public class InstnaceResourceListTest {
         Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType());
     }
 
+    @Test
+    public void testSimpleVFResourceWithGroup() throws IOException {
+        String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json")));
+        VnfResource vnfResource = new VnfResource();
+        vnfResource.setResourceInput("{\"a\":\"ipaddress|127.0.0.1\"}");
+
+        createGroupKeyResource(vnfResource);
+
+        List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(vnfResource, uuiRequest);
+        Assert.assertEquals(2, instanceResourceList.size());
+        Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType());
+        Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(1).getResourceType());
+        Assert.assertEquals("wan", instanceResourceList.get(1).getModelInfo().getModelName());
+    }
+
+    @Test
+    public void testVFResourceWithEmptyGroup() throws IOException {
+        String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json")));
+        VnfResource vnfResource = new VnfResource();
+        vnfResource.setResourceInput("{\"a\":\"[emptygroup_list2,INDEX,name]\"}");
+
+        List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(vnfResource, uuiRequest);
+        Assert.assertEquals(1, instanceResourceList.size());
+        Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType());
+    }
+
+    @Test
+    public void testVFResourceWithModule() throws IOException {
+        String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json")));
+        VnfResource vnfResource = new VnfResource();
+        vnfResource.setResourceInput("{\"a\":\"ipaddress|127.0.0.1\"}");
+
+        // Come from package org.onap.so.bpmn.core.domain.VnfResourceTest
+        List<ModuleResource> moduleResources;
+        moduleResources = new ArrayList<>();
+        ModuleResource moduleresource = getModuleResource();
+        moduleResources.add(moduleresource);
+        vnfResource.setModules(moduleResources);
+
+        List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(vnfResource, uuiRequest);
+        Assert.assertEquals(2, instanceResourceList.size());
+        Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType());
+        Assert.assertEquals(ResourceType.MODULE, instanceResourceList.get(1).getResourceType());
+    }
+
+    private ModuleResource getModuleResource() {
+        ModuleResource moduleresource = new ModuleResource();
+        moduleresource.setVfModuleName("vfModuleName");
+        moduleresource.setHeatStackId("heatStackId");
+        moduleresource.setIsBase(true);
+        moduleresource.setVfModuleLabel("vfModuleLabel");
+        moduleresource.setInitialCount(0);
+        moduleresource.setVfModuleType("vfModuleType");
+        moduleresource.setHasVolumeGroup(true);
+        return moduleresource;
+    }
+
     // Test when PK is not empty and PK does not contain any groups
     @Test
     public void testVFWithEmptyGroupResource() throws IOException {
@@ -66,16 +127,7 @@ public class InstnaceResourceListTest {
         VnfResource vnfResource = new VnfResource();
         vnfResource.setResourceInput("{\"a\":\"[emptygroup_list,INDEX,name]\"}");
 
-        VnfcResource vnfcResource = new VnfcResource();
-        vnfcResource.setResourceInput("{\"a\":\"test|default_value\"}");
-        GroupResource groupResource = new GroupResource();
-        groupResource.setVnfcs(Arrays.asList(vnfcResource));
-        ModelInfo wanModel = new ModelInfo();
-        wanModel.setModelName("wan");
-        groupResource.setModelInfo(wanModel);
-
-        vnfResource.setGroupOrder("wan");
-        vnfResource.setGroups(Arrays.asList(groupResource));
+        createGroupKeyResource(vnfResource);
 
         List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(vnfResource, uuiRequest);
         Assert.assertEquals(2, instanceResourceList.size());
@@ -84,29 +136,34 @@ public class InstnaceResourceListTest {
         Assert.assertEquals("wan", instanceResourceList.get(1).getModelInfo().getModelName());
     }
 
+    private void createGroupKeyResource(VnfResource vnfResource) {
+        GroupResource groupResource = prepareGroupResource("{\"a\":\"test|default_value\"}", "wan");
+
+        vnfResource.setGroupOrder("wan");
+        vnfResource.setGroups(Arrays.asList(groupResource));
+    }
+
     private VnfResource createResourceSequence() {
         VnfResource vnfResource = new VnfResource();
         vnfResource.setResourceInput("{\"a\":\"[sdwansiteresource_list,INDEX,sdwansiteresource_list]\"}");
 
-        VnfcResource vnfcResource = new VnfcResource();
-        vnfcResource.setResourceInput("{\"a\":\"[sdwansitewan_list,INDEX,test]\"}");
+        GroupResource groupResource = prepareGroupResource("{\"a\":\"[sdwansitewan_list,INDEX,test]\"}", "sitewan");
+        GroupResource groupResource2 = prepareGroupResource("{\"a\":\"[sdwandevice_list,INDEX,test]\"}", "device");
+        GroupResource groupDummyResource = prepareGroupResource("{\"a\":\"[dummy,INDEX,test]\"}", "dummy");
 
-        GroupResource groupResource = new GroupResource();
-        groupResource.setVnfcs(Arrays.asList(vnfcResource));
-        ModelInfo wanModel = new ModelInfo();
-        wanModel.setModelName("sitewan");
-        groupResource.setModelInfo(wanModel);
+        vnfResource.setGroupOrder("device,sitewan,dummy");
+        vnfResource.setGroups(Arrays.asList(groupResource, groupResource2, groupDummyResource));
+        return vnfResource;
+    }
 
+    private GroupResource prepareGroupResource(String sourceInput, String modelName) {
         VnfcResource vnfcDeviceResource = new VnfcResource();
-        vnfcDeviceResource.setResourceInput("{\"a\":\"[sdwandevice_list,INDEX,test]\"}");
-        GroupResource groupResource2 = new GroupResource();
-        groupResource2.setVnfcs(Arrays.asList(vnfcDeviceResource));
+        vnfcDeviceResource.setResourceInput(sourceInput);
+        GroupResource groupResource = new GroupResource();
+        groupResource.setVnfcs(Arrays.asList(vnfcDeviceResource));
         ModelInfo deviceModel = new ModelInfo();
-        deviceModel.setModelName("device");
-        groupResource2.setModelInfo(deviceModel);
-
-        vnfResource.setGroupOrder("device,sitewan");
-        vnfResource.setGroups(Arrays.asList(groupResource, groupResource2));
-        return vnfResource;
+        deviceModel.setModelName(modelName);
+        groupResource.setModelInfo(deviceModel);
+        return groupResource;
     }
 }
index cb0d31b..61a006f 100644 (file)
@@ -45,6 +45,7 @@ public class AVPNDmaapBeansTest extends BaseTest {
     public void ensureExpectedPojoCount() {
         List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses(POJO_PACKAGE, new FilterPackageInfo());
         Affirm.affirmEquals("Classes added / removed?", EXPECTED_CLASS_COUNT, pojoClasses.size());
+        assertNotNull(pojoClasses);
     }
 
     @Test
index a111ae2..cf0f2d1 100644 (file)
@@ -79,6 +79,9 @@
             "deviceName":"vCPE",
             "portNumer":"0/0/1"
           }
+        ],
+        "emptygroup_list2": [
+
         ],
         "sdwanvpnresource_list":[
           {
                 "class":"VNF",
                 "systemIp":"20.20.20.1"
               }
-            ]
+            ],
+            "dummy":""
           },
           {
             "sdwansite_emails":"chenchuanyu@huawei.com",
                 "class":"PNF",
                 "systemIp":"20.20.20.2"
               }
-            ]
+            ],
+            "dummy":""
           }
         ]
       }
index a3d0dd5..7d88271 100644 (file)
           </execution>
           <execution>
             <id>original</id>
-            <configuration>
-              <skip>false</skip>
-            </configuration>
+            <phase>package</phase>
           </execution>
         </executions>
       </plugin>
         <executions>
           <execution>
             <id>extract-docker-file</id>
+            <configuration>
+              <skip>false</skip>
+            </configuration>
           </execution>
         </executions>
       </plugin>
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationService.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationService.java
new file mode 100644 (file)
index 0000000..fd7498f
--- /dev/null
@@ -0,0 +1,110 @@
+package org.onap.so.bpmn.common.workflow.service;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.camunda.bpm.engine.ProcessEngine;
+import org.camunda.bpm.engine.RepositoryService;
+import org.camunda.bpm.engine.RuntimeService;
+import org.camunda.bpm.engine.migration.MigrationInstruction;
+import org.camunda.bpm.engine.migration.MigrationPlan;
+import org.camunda.bpm.engine.migration.MigrationPlanExecutionBuilder;
+import org.camunda.bpm.engine.repository.ProcessDefinition;
+import org.camunda.bpm.engine.runtime.ProcessInstance;
+import org.camunda.bpm.engine.runtime.ProcessInstanceQuery;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.event.ApplicationReadyEvent;
+import org.springframework.context.event.EventListener;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Service;
+
+@Service
+public class AutoProcessInstanceMigrationService {
+
+    private static Logger logger = LoggerFactory.getLogger(AutoProcessInstanceMigrationService.class);
+
+    @Autowired
+    private Environment env;
+    @Autowired
+    protected ProcessEngine processEngine;
+
+    @Value("${migration.autoMigrationEnabled:false}")
+    private boolean autoMigrationEnabled;
+
+    private RuntimeService runtimeService;
+    private RepositoryService repositoryService;
+    private List<String> processDefinitionKeys;
+
+    @EventListener(ApplicationReadyEvent.class)
+    protected void executeAutoProcessInstanceMigrations() {
+        if (autoMigrationEnabled) {
+            runtimeService = processEngine.getRuntimeService();
+            repositoryService = processEngine.getRepositoryService();
+            for (ProcessDefinition definition : getProcessDefinitions()) {
+                for (ProcessDefinition procDefOld : getOldProcessDefinitions(definition.getKey(),
+                        definition.getVersion())) {
+                    migrate(procDefOld.getId(), definition.getId());
+                }
+            }
+        }
+    }
+
+    protected List<ProcessDefinition> getProcessDefinitions() {
+        List<ProcessDefinition> processDefinitions = new ArrayList<ProcessDefinition>();
+        processDefinitionKeys = env.getProperty("migration.processDefinitionKeys", List.class, new ArrayList<String>());
+        for (String key : processDefinitionKeys) {
+            processDefinitions.add(repositoryService.createProcessDefinitionQuery().processDefinitionKey(key)
+                    .latestVersion().singleResult());
+        }
+        return processDefinitions;
+    }
+
+    private void migrate(String sourceProcessDefinitionId, String targetProcessDefinitionId) {
+        MigrationPlan migrationPlan =
+                runtimeService.createMigrationPlan(sourceProcessDefinitionId, targetProcessDefinitionId)
+                        .mapEqualActivities().updateEventTriggers().build();
+        List<String> activityIds = new ArrayList<>();
+
+        for (MigrationInstruction instruction : migrationPlan.getInstructions()) {
+            activityIds.add(instruction.getSourceActivityId());
+        }
+        for (String activityId : activityIds) {
+            ProcessInstanceQuery activeProcessInstancesQuery = runtimeService.createProcessInstanceQuery()
+                    .processDefinitionId(sourceProcessDefinitionId).activityIdIn(activityId).active();
+            if (!activeProcessInstancesQuery.list().isEmpty()) {
+                logger.info("Migrating {} process instance(s) from {} to {}",
+                        Long.valueOf(activeProcessInstancesQuery.count()), sourceProcessDefinitionId,
+                        targetProcessDefinitionId);
+                MigrationPlanExecutionBuilder migration =
+                        runtimeService.newMigration(migrationPlan).processInstanceQuery(activeProcessInstancesQuery);
+                migration.executeAsync();
+            }
+        }
+        suspendEmptyProcessDefinition(sourceProcessDefinitionId);
+    }
+
+    private void suspendEmptyProcessDefinition(String sourceProcessDefinitionId) {
+        List<ProcessInstance> activeProcessInstances = runtimeService.createProcessInstanceQuery()
+                .processDefinitionId(sourceProcessDefinitionId).active().list();
+        if (activeProcessInstances.isEmpty()) {
+            repositoryService.suspendProcessDefinitionById(sourceProcessDefinitionId);
+        } else {
+            logger.info("Unable to migrate {} process instance(s) from {}",
+                    Integer.valueOf(activeProcessInstances.size()), sourceProcessDefinitionId);
+        }
+    }
+
+    protected List<ProcessDefinition> getOldProcessDefinitions(String key, int version) {
+        List<ProcessDefinition> processDefinitions =
+                repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).list();
+        List<ProcessDefinition> oldProcessDefinitions = new ArrayList<>();
+        for (ProcessDefinition processDef : processDefinitions) {
+            if (!processDef.isSuspended() && (processDef.getVersion() != version)) {
+                oldProcessDefinitions.add(processDef);
+            }
+        }
+        return oldProcessDefinitions;
+    }
+}
index c128f58..089d034 100644 (file)
@@ -20,6 +20,7 @@
 
 package org.onap.so.bpmn.common;
 
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.onap.so.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogDataByModelUuid;
@@ -530,6 +531,7 @@ public class OofHomingIT extends BaseIntegrationTest {
                 .contains("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback "
                         + "Response contains error: Unable to find any candidate for demand *** Response:");
         assert (errorMatch);
+        assertNotNull(businessKey);
     }
 
     @Test
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/AutoProcessInstanceMigrationServiceTest.java
new file mode 100644 (file)
index 0000000..77b3535
--- /dev/null
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.common.workflow.service;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doReturn;
+import java.util.ArrayList;
+import java.util.List;
+import org.camunda.bpm.engine.ProcessEngine;
+import org.camunda.bpm.engine.RepositoryService;
+import org.camunda.bpm.engine.repository.ProcessDefinition;
+import org.camunda.bpm.engine.repository.ProcessDefinitionQuery;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.springframework.core.env.Environment;
+
+@RunWith(MockitoJUnitRunner.class)
+public class AutoProcessInstanceMigrationServiceTest {
+
+    @Mock
+    private ProcessEngine processEngine;
+
+    @Mock
+    private ProcessDefinition outdated;
+
+    @Mock
+    private ProcessDefinition newDef;
+
+    @Mock
+    private ProcessDefinition key;
+
+    @Mock
+    private ProcessDefinition testKey;
+
+    @Mock
+    private ProcessDefinition suspendedDef;
+
+    @Mock
+    private RepositoryService repositoryService;
+
+    @Mock
+    private ProcessDefinitionQuery query;
+
+    @Mock
+    private ProcessDefinitionQuery keyQuery;
+
+    @Mock
+    private Environment env;
+
+    @Spy
+    @InjectMocks
+    private AutoProcessInstanceMigrationService migrationService;
+
+
+    @Test
+    public void getOldProcessDefinitionsTest() {
+        List<ProcessDefinition> expectedList = new ArrayList<>();
+        expectedList.add(outdated);
+
+        List<ProcessDefinition> defList = new ArrayList<>();
+        defList.add(outdated);
+        defList.add(newDef);
+        defList.add(suspendedDef);
+
+        doReturn(query).when(repositoryService).createProcessDefinitionQuery();
+        doReturn(query).when(query).processDefinitionKey("test");
+        doReturn(defList).when(query).list();
+        doReturn(3).when(outdated).getVersion();
+        doReturn(4).when(newDef).getVersion();
+        doReturn(true).when(suspendedDef).isSuspended();
+        List<ProcessDefinition> outdatedList = migrationService.getOldProcessDefinitions("test", 4);
+
+        assertEquals(expectedList, outdatedList);
+    }
+
+    @Test
+    public void getProcessDefinitionsTest() {
+        List<ProcessDefinition> expected = new ArrayList<ProcessDefinition>();
+        expected.add(testKey);
+        expected.add(key);
+
+        List<String> processDefinitionKeys = new ArrayList<String>();
+        processDefinitionKeys.add("testKey");
+        processDefinitionKeys.add("key");
+
+        doReturn(processDefinitionKeys).when(env).getProperty("migration.processDefinitionKeys", List.class,
+                new ArrayList<String>());
+
+        doReturn(query).when(repositoryService).createProcessDefinitionQuery();
+        doReturn(query).when(query).processDefinitionKey("testKey");
+        doReturn(query).when(query).latestVersion();
+        doReturn(testKey).when(query).singleResult();
+
+        doReturn(keyQuery).when(query).processDefinitionKey("key");
+        doReturn(keyQuery).when(keyQuery).latestVersion();
+        doReturn(key).when(keyQuery).singleResult();
+
+        List<ProcessDefinition> actualProcessDefinitions = migrationService.getProcessDefinitions();
+
+        assertEquals(expected, actualProcessDefinitions);
+    }
+}
index 64c0e54..27ae7ba 100644 (file)
@@ -49,6 +49,7 @@ public class DeployActivitySpecsTest extends BaseBPMNTest {
         when(clientMock.execute(any(HttpPost.class))).thenReturn(response);
         String[] args = new String[] {HOSTNAME};
         DeployActivitySpecs.main(args);
+        assertNotNull(HOSTNAME);
     }
 
     @Test
index 8f40e8b..5371015 100644 (file)
@@ -12,4 +12,4 @@ intersphinx_mapping = {}
 html_last_updated_fmt = '%d-%b-%y %H:%M'
 
 def setup(app):
-    app.add_stylesheet("css/ribbon_onap.css")
+    app.add_stylesheet("css/ribbon.css")
index 7d6bbc4..7e891f1 100644 (file)
         <executions>
           <execution>
             <id>extract-docker-file</id>
+            <configuration>
+              <skip>false</skip>
+            </configuration>
           </execution>
         </executions>
       </plugin>
         <executions>
           <execution>
             <id>original</id>
-            <configuration>
-              <skip>false</skip>
-            </configuration>
+            <phase>package</phase>
           </execution>
         </executions>
       </plugin>
diff --git a/pom.xml b/pom.xml
index 5e4cadc..f19e3f2 100644 (file)
--- a/pom.xml
+++ b/pom.xml
                 <goal>unpack</goal>
               </goals>
               <configuration>
+                <skip>true</skip>
                 <artifactItems>
                   <artifactItem>
                     <groupId>org.onap.so</groupId>
           <executions>
             <execution>
               <id>original</id>
-              <phase>package</phase>
+              <phase>none</phase>
               <goals>
                 <goal>jar</goal>
               </goals>
               <configuration>
-                <skip>true</skip>
                 <classifier>${originalClassifier}</classifier>
                 <includes>
                   <include>**</include>
index a92664a..006a6fa 100644 (file)
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>original</id>
+            <phase>package</phase>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>