use of org.onap.namingservice.model.NameGenDeleteResponse in project so by onap.
the class NamingServiceResourcesTest method deleteInstanceGroupNameTest.
@Test
public void deleteInstanceGroupNameTest() throws Exception {
NameGenDeleteResponse name = new NameGenDeleteResponse();
ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
Deleteelement deleteElement = new Deleteelement();
deleteElement.setExternalKey(instanceGroup.getId());
NameGenDeleteRequest req = new NameGenDeleteRequest();
doReturn(deleteElement).when(MOCK_namingRequestObjectBuilder).deleteElementMapper(isA(String.class));
doReturn("").when(MOCK_namingClient).deleteNameGenRequest(isA(NameGenDeleteRequest.class));
doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenDeleteRequestMapper(isA(List.class));
namingServiceResources.deleteInstanceGroupName(instanceGroup);
verify(MOCK_namingClient, times(1)).deleteNameGenRequest(any(NameGenDeleteRequest.class));
}
use of org.onap.namingservice.model.NameGenDeleteResponse in project so by onap.
the class NamingClientResponseValidatorTest method validateNameGenDeleteResponseBadStatusTest.
@Test
public void validateNameGenDeleteResponseBadStatusTest() throws BadResponseException {
NameGenDeleteResponse name = new NameGenDeleteResponse();
ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.NOT_FOUND);
expectedException.expect(BadResponseException.class);
responseValidator.validateNameGenDeleteResponse(resp);
}
use of org.onap.namingservice.model.NameGenDeleteResponse in project so by onap.
the class NamingClientResponseValidatorTest method validateNameGenDeleteResponseSuccessTest.
@Test
public void validateNameGenDeleteResponseSuccessTest() throws BadResponseException {
NameGenDeleteResponse name = new NameGenDeleteResponse();
ResponseEntity<NameGenDeleteResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK);
String actual = responseValidator.validateNameGenDeleteResponse(resp);
assertEquals(actual, "");
}
use of org.onap.namingservice.model.NameGenDeleteResponse in project so by onap.
the class NamingClientResponseValidator method validateNameGenDeleteResponse.
public String validateNameGenDeleteResponse(ResponseEntity<NameGenDeleteResponse> response) throws BadResponseException {
if (response == null) {
logger.error(LoggingAnchor.FIVE, MessageEnum.RA_GENERAL_EXCEPTION.toString(), NO_RESPONSE_FROM_NAMING_SERVICE, "BPMN", ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_NAMING_SERVICE);
throw new BadResponseException(NO_RESPONSE_FROM_NAMING_SERVICE);
}
int responseCode = response.getStatusCodeValue();
String responseMessage = "";
NameGenDeleteResponse responseBody = response.getBody();
if (responseBody == null) {
logger.error(LoggingAnchor.FIVE, MessageEnum.RA_GENERAL_EXCEPTION.toString(), NULL_RESPONSE_FROM_NAMING_SERVICE, "BPMN", ErrorCode.UnknownError.getValue(), NULL_RESPONSE_FROM_NAMING_SERVICE);
throw new BadResponseException(NULL_RESPONSE_FROM_NAMING_SERVICE);
}
if (isHttpCodeSuccess(responseCode)) {
logger.info("Successful Response from Naming Service");
return responseMessage;
} else {
String errorMessageString = NAMING_SERVICE_ERROR;
String errorMessage = String.format(NAMING_SERVICE_ERROR, errorMessageString);
logger.error(LoggingAnchor.FIVE, MessageEnum.RA_GENERAL_EXCEPTION.toString(), errorMessage, "BPMN", ErrorCode.DataError.getValue(), errorMessage);
throw new BadResponseException(errorMessage);
}
}
use of org.onap.namingservice.model.NameGenDeleteResponse in project so by onap.
the class NamingClient method deleteNameGenRequest.
public String deleteNameGenRequest(NameGenDeleteRequest request) throws BadResponseException, IOException {
String targetUrl = env.getProperty(ENDPOINT);
HttpHeaders headers = setHeaders(env.getProperty(AUTH));
logger.info("Sending deleteNameGenRequest to url: {}", targetUrl);
HttpEntity<NameGenDeleteRequest> requestEntity = new HttpEntity<>(request, headers);
ResponseEntity<NameGenDeleteResponse> response;
try {
response = restTemplate.exchange(targetUrl, HttpMethod.DELETE, requestEntity, NameGenDeleteResponse.class);
} catch (HttpStatusCodeException e) {
throw new BadResponseException(namingClientResponseValidator.formatError(e));
}
return namingClientResponseValidator.validateNameGenDeleteResponse(response);
}
Aggregations