use of org.onap.aaiclient.client.aai.entities.singletransaction.SingleTransactionResponse in project so by onap.
the class AAISingleTransactionClientTest method testFailure.
@Test
public void testFailure() throws IOException {
AAISingleTransactionClient singleTransaction = aaiClient.beginSingleTransaction();
SingleTransactionResponse expected = mapper.readValue(this.getJson("sample-response-failure.json"), SingleTransactionResponse.class);
Optional<String> errorMessage = singleTransaction.locateErrorMessages(expected);
assertThat(expected.getOperationResponses().size(), greaterThan(0));
assertThat(errorMessage.isPresent(), equalTo(true));
}
use of org.onap.aaiclient.client.aai.entities.singletransaction.SingleTransactionResponse in project so by onap.
the class AAISingleTransactionClient method execute.
/*
* (non-Javadoc)
*
* @see org.onap.aaiclient.client.aai.GraphInventoryTransactionClient#execute()
*/
@Override
public void execute() throws BulkProcessFailed {
try {
if (!this.request.getOperations().isEmpty()) {
RestClient client = aaiClient.createClient(AAIUriFactory.createResourceUri(AAIObjectType.SINGLE_TRANSACTION));
SingleTransactionResponse response = client.post(this.request, SingleTransactionResponse.class);
if (response != null) {
final Optional<String> errorMessage = this.locateErrorMessages(response);
if (errorMessage.isPresent()) {
throw new BulkProcessFailed("One or more transactions failed in A&AI. Check logs for payloads.\nMessages:\n" + errorMessage.get());
}
} else {
throw new BulkProcessFailed("Transactions acccepted by A&AI, but there was no response. Unsure of result.");
}
}
} finally {
this.request.getOperations().clear();
this.actionCount = 0;
}
}
use of org.onap.aaiclient.client.aai.entities.singletransaction.SingleTransactionResponse in project so by onap.
the class AAISingleTransactionClientTest method testSuccessResponse.
@Test
public void testSuccessResponse() throws IOException {
AAISingleTransactionClient singleTransaction = aaiClient.beginSingleTransaction();
SingleTransactionResponse expected = mapper.readValue(this.getJson("sample-response.json"), SingleTransactionResponse.class);
Optional<String> errorMessage = singleTransaction.locateErrorMessages(expected);
assertThat(expected.getOperationResponses().size(), greaterThan(0));
assertThat(errorMessage.isPresent(), equalTo(false));
}
Aggregations