Search in sources :

Example 1 with RequirementAssignments

use of org.onap.sdc.toscaparser.api.RequirementAssignments in project so by onap.

the class ToscaResourceInstallerTest method testProcessVNFCGroupSequence.

@Test
public void testProcessVNFCGroupSequence() {
    List<Group> groupList = new ArrayList<>();
    Group group1 = mock(Group.class);
    NodeTemplate node1 = mock(NodeTemplate.class);
    List<NodeTemplate> nodeList1 = new ArrayList<>();
    nodeList1.add(node1);
    doReturn("VfcInstanceGroup..0").when(group1).getName();
    doReturn(nodeList1).when(group1).getMemberNodes();
    doReturn("deviceV3").when(node1).getName();
    Group group2 = mock(Group.class);
    NodeTemplate node2 = mock(NodeTemplate.class);
    List<NodeTemplate> nodeList2 = new ArrayList<>();
    nodeList2.add(node2);
    doReturn("VfcInstanceGroup..1").when(group2).getName();
    doReturn(nodeList2).when(group2).getMemberNodes();
    RequirementAssignments requirements2 = mock(RequirementAssignments.class);
    RequirementAssignment requirement2 = mock(RequirementAssignment.class);
    List<RequirementAssignment> requirementCollection2 = new ArrayList<>();
    requirementCollection2.add(requirement2);
    doReturn(requirementCollection2).when(requirements2).getAll();
    doReturn("deviceV3").when(requirement2).getNodeTemplateName();
    doReturn("SiteV2").when(node2).getName();
    Group group3 = mock(Group.class);
    NodeTemplate node3 = mock(NodeTemplate.class);
    List<NodeTemplate> nodeList3 = new ArrayList<>();
    nodeList3.add(node3);
    doReturn("VfcInstanceGroup..2").when(group3).getName();
    doReturn(nodeList3).when(group3).getMemberNodes();
    RequirementAssignments requirements3 = mock(RequirementAssignments.class);
    RequirementAssignment requirement3 = mock(RequirementAssignment.class);
    List<RequirementAssignment> requirementCollection3 = new ArrayList<>();
    requirementCollection3.add(requirement3);
    doReturn(requirementCollection3).when(requirements3).getAll();
    doReturn("SiteV2").when(requirement3).getNodeTemplateName();
    doReturn("siteWanV2").when(node3).getName();
    groupList.add(group1);
    groupList.add(group2);
    groupList.add(group3);
    doReturn(csarHelper).when(toscaResourceStructure).getSdcCsarHelper();
    ToscaResourceInstaller installer = new ToscaResourceInstaller();
    Method[] methods = installer.getClass().getDeclaredMethods();
    Method testMethod = null;
    for (Method method : methods) {
        String name = method.getName();
        if (name.equals("processVNFCGroupSequence")) {
            method.setAccessible(true);
            testMethod = method;
        }
    }
    if (null != testMethod) {
        try {
            Object seqResult = testMethod.invoke(installer, toscaResourceStructure, groupList);
            if (seqResult instanceof List) {
                String resultStr = ((List<String>) seqResult).stream().collect(Collectors.joining(","));
                assertEquals(((List<String>) seqResult).size(), 3);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
Also used : Group(org.onap.sdc.toscaparser.api.Group) ArrayList(java.util.ArrayList) RequirementAssignments(org.onap.sdc.toscaparser.api.RequirementAssignments) Method(java.lang.reflect.Method) LockAcquisitionException(org.hibernate.exception.LockAcquisitionException) ExpectedException(org.junit.rules.ExpectedException) ArtifactInstallerException(org.onap.so.asdc.client.exceptions.ArtifactInstallerException) RequirementAssignment(org.onap.sdc.toscaparser.api.RequirementAssignment) NodeTemplate(org.onap.sdc.toscaparser.api.NodeTemplate) List(java.util.List) ArrayList(java.util.ArrayList) BaseTest(org.onap.so.asdc.BaseTest) Test(org.junit.Test)

Aggregations

Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 LockAcquisitionException (org.hibernate.exception.LockAcquisitionException)1 Test (org.junit.Test)1 ExpectedException (org.junit.rules.ExpectedException)1 Group (org.onap.sdc.toscaparser.api.Group)1 NodeTemplate (org.onap.sdc.toscaparser.api.NodeTemplate)1 RequirementAssignment (org.onap.sdc.toscaparser.api.RequirementAssignment)1 RequirementAssignments (org.onap.sdc.toscaparser.api.RequirementAssignments)1 BaseTest (org.onap.so.asdc.BaseTest)1 ArtifactInstallerException (org.onap.so.asdc.client.exceptions.ArtifactInstallerException)1