Search in sources :

Example 1 with Element

use of org.onap.namingservice.model.Element in project so by onap.

the class NamingClientIT method assignSetup.

public NameGenRequest assignSetup() throws JsonProcessingException {
    NameGenRequest request = new NameGenRequest();
    List<Element> elements = new ArrayList<>();
    Element testElement = new Element();
    testElement = requestBuilder.elementMapper("SomeUniqueValue", "SDNC_Policy.Config_MS_1806SRIOV_VNATJson.4.xml", "VNF", "nfNamingCode", "vnf_name");
    elements.add(testElement);
    request = requestBuilder.nameGenRequestMapper(elements);
    return request;
}
Also used : NameGenRequest(org.onap.namingservice.model.NameGenRequest) Element(org.onap.namingservice.model.Element) ArrayList(java.util.ArrayList)

Example 2 with Element

use of org.onap.namingservice.model.Element in project so by onap.

the class NamingServiceResourcesTest method generateInstanceGroupNameTest.

@Test
public void generateInstanceGroupNameTest() throws Exception {
    NameGenResponse name = new NameGenResponse();
    ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
    Element element = new Element();
    NameGenRequest req = new NameGenRequest();
    doReturn(element).when(MOCK_namingRequestObjectBuilder).elementMapper(isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class));
    doReturn("generatedInstanceGroupName").when(MOCK_namingClient).postNameGenRequest(isA(NameGenRequest.class));
    doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenRequestMapper(isA(List.class));
    String generatedName = namingServiceResources.generateInstanceGroupName(instanceGroup, "policyInstanceName", "nfNamingCode");
    verify(MOCK_namingClient, times(1)).postNameGenRequest(any(NameGenRequest.class));
    assertEquals(generatedName, "generatedInstanceGroupName");
}
Also used : NameGenResponse(org.onap.namingservice.model.NameGenResponse) ResponseEntity(org.springframework.http.ResponseEntity) Element(org.onap.namingservice.model.Element) NameGenRequest(org.onap.namingservice.model.NameGenRequest) List(java.util.List) Test(org.junit.Test)

Example 3 with Element

use of org.onap.namingservice.model.Element in project so by onap.

the class NamingRequestObjectTest method namingRequestObjectTest.

@Test
public void namingRequestObjectTest() {
    Element expected = new Element();
    expected.put(NamingServiceConstants.NS_EXTERNAL_KEY, externalKey);
    expected.put(NamingServiceConstants.NS_POLICY_INSTANCE_NAME, policyInstanceName);
    expected.put(NamingServiceConstants.NS_NAMING_TYPE, namingType);
    expected.put(NamingServiceConstants.NS_RESOURCE_NAME, resourceName);
    expected.put(NamingServiceConstants.NS_NF_NAMING_CODE, nfNamingCode);
    NamingRequestObject namingRequestObject = new NamingRequestObject();
    namingRequestObject.setExternalKeyValue(externalKey);
    namingRequestObject.setPolicyInstanceNameValue(policyInstanceName);
    namingRequestObject.setNamingTypeValue(namingType);
    namingRequestObject.setNfNamingCodeValue(nfNamingCode);
    namingRequestObject.setResourceNameValue(resourceName);
    HashMap<String, String> actual = namingRequestObject.getNamingRequestObjectMap();
    assertThat(actual, sameBeanAs(expected));
}
Also used : Element(org.onap.namingservice.model.Element) Test(org.junit.Test)

Example 4 with Element

use of org.onap.namingservice.model.Element in project so by onap.

the class NamingRequestObjectBuilderTest method nameGenRequestMapper.

@Test
public void nameGenRequestMapper() {
    // Expected NameGenRequest
    NameGenRequest expected = new NameGenRequest();
    List<Element> elements = new ArrayList<>();
    Element element = new Element();
    element.setExternalKey(instanceGroupId);
    element.setPolicyInstanceName(policyInstanceName);
    element.setNamingType(namingType);
    element.setResourceName(instanceGroupName);
    element.setNamingIngredientsZeroOrMore(nfNamingCode);
    elements.add(element);
    expected.setElements(elements);
    // Actual NameGenRequest
    NameGenRequest actual = mapper.nameGenRequestMapper(elements);
    assertThat(actual, sameBeanAs(expected));
}
Also used : NameGenRequest(org.onap.namingservice.model.NameGenRequest) Element(org.onap.namingservice.model.Element) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with Element

use of org.onap.namingservice.model.Element in project so by onap.

the class NamingRequestObjectBuilderTest method elementMapperTest.

@Test
public void elementMapperTest() {
    // Expected element
    Element expected = new Element();
    expected.put("external-key", instanceGroupId);
    expected.put("policy-instance-name", policyInstanceName);
    expected.put("naming-type", namingType);
    expected.put("resource-name", instanceGroupName);
    expected.put("nf-naming-code", nfNamingCode);
    // Actual element
    Element actual = mapper.elementMapper(instanceGroupId, policyInstanceName, namingType, nfNamingCode, instanceGroupName);
    assertThat(actual, sameBeanAs(expected));
}
Also used : Element(org.onap.namingservice.model.Element) Test(org.junit.Test)

Aggregations

Element (org.onap.namingservice.model.Element)9 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 NameGenRequest (org.onap.namingservice.model.NameGenRequest)3 List (java.util.List)1 Deleteelement (org.onap.namingservice.model.Deleteelement)1 NameGenResponse (org.onap.namingservice.model.NameGenResponse)1 ResponseEntity (org.springframework.http.ResponseEntity)1