Update nf_type for PNF in AAI
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / onap / so / bpmn / servicedecomposition / tasks / BBInputSetupMapperLayerTest.java
index 37f8b8b..6f09130 100644 (file)
@@ -44,6 +44,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
@@ -60,6 +61,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
 import org.onap.so.db.catalog.beans.CollectionResource;
@@ -73,13 +75,15 @@ import org.onap.so.db.catalog.beans.InstanceGroup;
 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
 import org.onap.so.db.catalog.beans.OrchestrationStatus;
 import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.beans.PnfResource;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
 import org.onap.so.db.catalog.beans.VfModuleCustomization;
 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
-import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
 import org.onap.so.db.catalog.beans.VnfcCustomization;
 import org.onap.so.serviceinstancebeans.CloudConfiguration;
 import org.onap.so.serviceinstancebeans.RequestDetails;
 import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 
@@ -87,10 +91,11 @@ public class BBInputSetupMapperLayerTest {
 
     BBInputSetupMapperLayer bbInputSetupMapperLayer = new BBInputSetupMapperLayer();
 
-    ObjectMapper mapper = new ObjectMapper();
+    ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
     private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
 
+
     @Test
     public void testMapOrchestrationStatusFromAAI() {
         OrchestrationStatus expected = OrchestrationStatus.INVENTORIED;
@@ -421,6 +426,17 @@ public class BBInputSetupMapperLayerTest {
         assertThat(actual, sameBeanAs(expected));
     }
 
+    @Test
+    public void testMapAAIPnfIntoPnf() throws IOException {
+        Pnf expected = mapper.readValue(new File(RESOURCE_PATH + "PnfExpected.json"), Pnf.class);
+        org.onap.aai.domain.yang.Pnf aaiPnf =
+                mapper.readValue(new File(RESOURCE_PATH + "aaiPnfInput.json"), org.onap.aai.domain.yang.Pnf.class);
+
+        Pnf actual = bbInputSetupMapperLayer.mapAAIPnfIntoPnf(aaiPnf);
+
+        assertThat(actual, sameBeanAs(expected));
+    }
+
     @Test
     public void testMapAAICollectionIntoCollection() throws JsonParseException, JsonMappingException, IOException {
         org.onap.aai.domain.yang.Collection aaiCollection = mapper
@@ -494,6 +510,26 @@ public class BBInputSetupMapperLayerTest {
         assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
     }
 
+    @Test
+    public void testMapCatalogPnfToPnf() throws IOException {
+        PnfResourceCustomization pnfResourceCustomization = mapper.readValue(
+                new File(RESOURCE_PATH + "PnfResourceCustomizationInput.json"), PnfResourceCustomization.class);
+
+        PnfResource pnfResource = new PnfResource();
+        pnfResource.setModelUUID("modelUuid");
+        pnfResource.setModelInvariantUUID("modelInvariantUuid");
+        pnfResource.setModelVersion("modelVersion");
+
+        pnfResourceCustomization.setPnfResources(pnfResource);
+
+        ModelInfoPnf expectedModelInfoPnf =
+                mapper.readValue(new File(RESOURCE_PATH + "ModelInfoPnfExpected.json"), ModelInfoPnf.class);
+
+        ModelInfoPnf actualModelInfoPnf = bbInputSetupMapperLayer.mapCatalogPnfToPnf(pnfResourceCustomization);
+
+        assertThat(actualModelInfoPnf, sameBeanAs(expectedModelInfoPnf));
+    }
+
     @Test
     public void testMapCatalogVfModuleToVfModule() throws JsonParseException, JsonMappingException, IOException {
         VfModuleCustomization vfResourceCustomization = mapper
@@ -572,6 +608,19 @@ public class BBInputSetupMapperLayerTest {
         assertThat(actual, sameBeanAs(expected));
     }
 
+    @Test
+    public void testMapOrchestrationContextNoRequestInfo() throws IOException {
+        OrchestrationContext expected = new OrchestrationContext();
+        expected.setIsRollbackEnabled(false);
+
+        RequestDetails requestDetails = mapper.readValue(
+                new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContextNoRequestInfo.json"), RequestDetails.class);
+
+        OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
+
+        assertThat(actual, sameBeanAs(expected));
+    }
+
     @Test
     public void testMapLocationContext() {
         CloudRegion expected = new CloudRegion();