### Question:
AAISingleTransactionClient extends
        GraphInventoryTransactionClient<AAISingleTransactionClient, AAIBaseResourceUri<?, ?>, AAIResourceUri, AAIEdgeLabel> { protected Optional<String> locateErrorMessages(SingleTransactionResponse response) { final List<String> errorMessages = new ArrayList<>(); final ObjectMapper mapper = new ObjectMapper(); for (OperationBodyResponse body : response.getOperationResponses()) { if (Optional.ofNullable(body.getResponseStatusCode()).orElse(400) > 300) { AAIError error; try { error = mapper.readValue(mapper.writeValueAsString(body.getResponseBody()), AAIError.class); } catch (IOException e) { logger.error("could not parse error object from A&AI", e); error = new AAIError(); } AAIErrorFormatter formatter = new AAIErrorFormatter(error); String outputMessage = formatter.getMessage(); errorMessages.add(outputMessage); } } if (!errorMessages.isEmpty()) { return Optional.of(Joiner.on("\n").join(errorMessages)); } else { return Optional.empty(); } } protected  AAISingleTransactionClient(AAIResourcesClient resourcesClient, AAIClient aaiClient); @Override void execute(); @Override void execute(boolean dryRun);  }### Answer:
@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)); }
@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)); }