use of org.onap.namingservice.model.NameGenRequest 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.NameGenRequest 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.NameGenRequest in project so by onap.
the class NamingServiceResourcesTest method generateServiceInstanceNameTest.
@Test
public void generateServiceInstanceNameTest() throws Exception {
NameGenRequest req = new NameGenRequest();
doReturn("generatedServiceInstanceName").when(MOCK_namingClient).postNameGenRequest(isA(NameGenRequest.class));
doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenRequestMapper(isA(List.class));
NamingRequestObject nrObject = new NamingRequestObject();
nrObject.setExternalKeyValue("testExternalKey");
nrObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE);
nrObject.setResourceNameValue(NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME);
nrObject.setPolicyInstanceNameValue(execution.getVariable("policyInstanceName"));
nrObject.setServiceModelNameValue("testServiceInstanceModelName");
nrObject.setModelVersionValue("testServiceInstanceModelVersion");
nrObject.setZoneIdValue(execution.getVariable("zoneId"));
String generatedName = namingServiceResources.generateServiceInstanceName(nrObject);
verify(MOCK_namingClient, times(1)).postNameGenRequest(any(NameGenRequest.class));
assertEquals("generatedServiceInstanceName", generatedName);
}
Aggregations