use of org.onap.namingservice.model.NameGenRequest in project so by onap.
the class NamingRequestObjectBuilder method nameGenRequestMapper.
public NameGenRequest nameGenRequestMapper(List<Element> elements) {
NameGenRequest nameGenRequest = new NameGenRequest();
nameGenRequest.setElements(elements);
return nameGenRequest;
}
use of org.onap.namingservice.model.NameGenRequest in project so by onap.
the class NamingClient method postNameGenRequest.
public String postNameGenRequest(NameGenRequest request) throws BadResponseException, IOException {
String targetUrl = env.getProperty(ENDPOINT);
HttpHeaders headers = setHeaders(env.getProperty(AUTH));
logger.info("Sending postNameGenRequest to url: {}", targetUrl);
HttpEntity<NameGenRequest> requestEntity = new HttpEntity<>(request, headers);
ResponseEntity<NameGenResponse> response;
try {
response = restTemplate.postForEntity(targetUrl, requestEntity, NameGenResponse.class);
} catch (HttpStatusCodeException e) {
throw new BadResponseException(namingClientResponseValidator.formatError(e));
}
return namingClientResponseValidator.validateNameGenResponse(response);
}
use of org.onap.namingservice.model.NameGenRequest in project so by onap.
the class NamingClientIT method assignNameGenRequest.
@Test
public void assignNameGenRequest() throws BadResponseException, IOException {
wireMockServer.stubFor(post(urlPathEqualTo("/web/service/v1/genNetworkElementName")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("NamingClient/AssignResponse.json").withStatus(HttpStatus.SC_ACCEPTED)));
NameGenRequest request = assignSetup();
String response = client.postNameGenRequest(request);
assertTrue(response.equals("$vnf-name"));
}
use of org.onap.namingservice.model.NameGenRequest 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.NameGenRequest in project so by onap.
the class NamingClientIT method assignNameGenRequestError.
@Test
public void assignNameGenRequestError() throws BadResponseException, IOException {
wireMockServer.stubFor(post(urlPathEqualTo("/web/service/v1/genNetworkElementName")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("NamingClient/ErrorResponse.json").withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
thrown.expect(BadResponseException.class);
thrown.expectMessage("Error from Naming Service: External Key is required and must be unique");
NameGenRequest request = assignSetup();
client.postNameGenRequest(request);
}
Aggregations