re base code
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / path / BaseForwardingPathTest.java
index 5253550..0af5915 100644 (file)
@@ -22,14 +22,13 @@ import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
 import org.openecomp.sdc.be.model.DistributionStatusEnum;
 import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Resource;
 import org.openecomp.sdc.be.model.Service;
 import org.openecomp.sdc.be.model.User;
 import org.openecomp.sdc.be.model.category.CategoryDefinition;
 import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
 import org.openecomp.sdc.be.model.operations.api.IElementOperation;
 import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
-import org.openecomp.sdc.be.tosca.CapabiltyRequirementConvertor;
+import org.openecomp.sdc.be.tosca.CapabilityRequirementConverter;
 import org.openecomp.sdc.be.user.Role;
 import org.openecomp.sdc.common.util.ValidationUtils;
 import org.openecomp.sdc.exception.ResponseFormat;
@@ -39,19 +38,20 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
-public class BaseForwardingPathTest extends BeConfDependentTest implements ForwardingPathTestUtils {
+public abstract class BaseForwardingPathTest extends BeConfDependentTest implements ForwardingPathTestUtils {
+
 
     protected User user;
-    protected ForwardingPathDataDefinition forwardingPathDataDefinition;
+    private ForwardingPathDataDefinition forwardingPathDataDefinition;
 
     @Autowired
     protected TitanGraphClient titanGraphClient;
 
     @Autowired
-    protected CapabiltyRequirementConvertor capabiltyRequirementConvertor;
+    protected CapabilityRequirementConverter capabiltyRequirementConvertor;
 
     @Autowired
     protected ToscaOperationFacade toscaOperationFacade;
@@ -86,21 +86,20 @@ public class BaseForwardingPathTest extends BeConfDependentTest implements Forwa
     }
 
 
-    protected CategoryDefinition categoryDefinition;
-    protected static final String GENERIC_SERVICE_NAME = "org.openecomp.resource.abstract.nodes.service";
-    protected static final String CATEGORY_NAME = "cat_name";
-    protected static final String FORWARDING_PATH_ID = "forwarding_pathId";
-    protected static final String HTTP_PROTOCOL = "http";
-
+    private CategoryDefinition categoryDefinition;
+    private static final String CATEGORY_NAME = "cat_name";
+    static final String FORWARDING_PATH_ID = "forwarding_pathId";
+    static final String HTTP_PROTOCOL = "http";
+    private static final String INSTANTIATION_TYPE = "A-la-carte";
+    private static final String CAPABILITY_NAME_1 = "CP1";
+    private static final String CAPABILITY_NAME_2 = "CP2";
+    private static final String CAPABILITY_NAME_3 = "CP3";
+    private static final String CI_NAME_1 = "CI1";
+    private static final String CI_NAME_2 = "CI2";
+    private static final String CI_NAME_3 = "CI3";
 
-    protected Resource setupGenericServiceMock() {
-        Resource genericService = new Resource();
-        genericService.setVersion("1.0");
-        genericService.setToscaResourceName(GENERIC_SERVICE_NAME);
-        return genericService;
-    }
 
-    protected void initGraph() {
+    private void initGraph() {
         Map<GraphPropertyEnum, Object> props = new HashMap<>();
         props.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
         props.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
@@ -114,7 +113,7 @@ public class BaseForwardingPathTest extends BeConfDependentTest implements Forwa
         assertTrue(vertexTitanOperationStatusEither.isLeft());
     }
 
-    protected Service createTestService() {
+    private Service createTestService() {
         createCategory();
         createServiceCategory(CATEGORY_NAME);
         initGraph();
@@ -125,6 +124,7 @@ public class BaseForwardingPathTest extends BeConfDependentTest implements Forwa
         service.setContactId("as123y");
         service.setIcon("MyIcon");
         service.setProjectCode("414155");
+        service.setInstantiationType(INSTANTIATION_TYPE);
         ArrayList<CategoryDefinition> categories = new ArrayList<>();
         CategoryDefinition cd = new CategoryDefinition();
         cd.setName(CATEGORY_NAME);
@@ -136,12 +136,12 @@ public class BaseForwardingPathTest extends BeConfDependentTest implements Forwa
         return service;
     }
 
-    protected void createCategory() {
+    private void createCategory() {
         Either<CategoryDefinition, ActionStatus> category = elementDao.createCategory(categoryDefinition, NodeTypeEnum.ServiceNewCategory);
         assertTrue("Failed to create category", category.isLeft());
     }
 
-    protected void createServiceCategory(String categoryName) {
+    private void createServiceCategory(String categoryName) {
         GraphVertex cat = new GraphVertex(VertexTypeEnum.SERVICE_CATEGORY);
         Map<GraphPropertyEnum, Object> metadataProperties = new HashMap<>();
         String catId = UniqueIdBuilder.buildComponentCategoryUid(categoryName, VertexTypeEnum.SERVICE_CATEGORY);
@@ -158,15 +158,15 @@ public class BaseForwardingPathTest extends BeConfDependentTest implements Forwa
         assertTrue(catRes.isLeft());
     }
 
-    protected Service initForwardPath() {
+    Service initForwardPath() {
         ForwardingPathDataDefinition forwardingPathDataDefinition = createMockPath();
         Service service = new Service();
         service.setUniqueId(FORWARDING_PATH_ID);
-        assertEquals(null, service.addForwardingPath(forwardingPathDataDefinition));
+        assertNull(service.addForwardingPath(forwardingPathDataDefinition));
         return service;
     }
 
-    protected ForwardingPathDataDefinition createMockPath() {
+    private ForwardingPathDataDefinition createMockPath() {
         if (forwardingPathDataDefinition != null) {
             return forwardingPathDataDefinition;
         }
@@ -175,17 +175,16 @@ public class BaseForwardingPathTest extends BeConfDependentTest implements Forwa
         forwardingPathDataDefinition.setDestinationPortNumber("414155");
         forwardingPathDataDefinition.setProtocol(HTTP_PROTOCOL);
         org.openecomp.sdc.be.datatypes.elements.ListDataDefinition<org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition> forwardingPathElementDataDefinitionListDataDefinition = new org.openecomp.sdc.be.datatypes.elements.ListDataDefinition<>();
-        forwardingPathElementDataDefinitionListDataDefinition.add(new ForwardingPathElementDataDefinition("fromNode", "toNode", "333", "444", "2222", "5555"));
-        forwardingPathElementDataDefinitionListDataDefinition.add(new ForwardingPathElementDataDefinition("toNode", "toNode2", "4444", "44444", "4", "44"));
+        forwardingPathElementDataDefinitionListDataDefinition.add(new ForwardingPathElementDataDefinition(CI_NAME_1, CI_NAME_2, CAPABILITY_NAME_1, CAPABILITY_NAME_2, "2222", "5555"));
+        forwardingPathElementDataDefinitionListDataDefinition.add(new ForwardingPathElementDataDefinition(CI_NAME_2, CI_NAME_3, CAPABILITY_NAME_2, CAPABILITY_NAME_3, "4", "44"));
         forwardingPathDataDefinition.setPathElements(forwardingPathElementDataDefinitionListDataDefinition);
         return forwardingPathDataDefinition;
     }
 
-    protected Service createService() {
+    Service createService() {
         Either<Service, ResponseFormat> serviceCreateResult = bl.createService(createTestService(), user);
         assertTrue("Failed to create service", serviceCreateResult.isLeft());
-        Service service = serviceCreateResult.left().value();
-        return service;
+        return serviceCreateResult.left().value();
     }
 }