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;
}
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");
}
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));
}
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));
}
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));
}
Aggregations