/**
* Builds the response
- *
+ *
* @param transaction the input transactions
* @param results the response of all of he operations
* @return TansactionResponse obj representing the result of the transaction
/**
* Generate one DBRequest per BulkOperation
- *
+ *
* @param headers request headers
* @param transId transaction id
* @param bulkOperations operations to convert
/**
* Sets the uriquery for each bulk operation
- *
+ *
* @param bulkOperations operations to generate queries for
* @param dbEngine engine for query builder generation
* @throws AAIException thrown for issues with generating uri query
/**
* Sets the introspector for each bulk operation. requires that uriquery is set per operation
- *
+ *
* @param bulkOperations operations to generate introspector for
* @param loader Loader for generating introspector
* @throws AAIException thrown for issues with generating introspector
}
bulkOperation.setIntrospector(obj);
}
+ } catch (AAIException e) {
+ throw new AAIException(e.getCode(), "Error with operation " + i + ": " + e.getMessage());
} catch (UnsupportedEncodingException e) {
throw new AAIException("AAI_3000", String.format(objectUnMarshallMsg, i, bulkOperation.getRawReq()));
}
* - Integer.MAX_VALUE if override limit is configured
* - Property in aaiconfig
* - 30 by default
- *
+ *
* @param headers request header
*/
private void setOperationCount(HttpHeaders headers) {
/**
* Converts the request transaction into a list of bulk operations
- *
+ *
* @param transaction transaction to extract bulk operations from
* @return list of bulk operations
*/
/**
* Map action to httpmethod
- *
+ *
* @param action action to be mapped
* @param uri uri of the action
* @return HttpMethod thats action/uri maps to
* - action is provided and correct.
* - uri exists
* - body exists
- *
+ *
* @param transaction parsed payload
* @throws AAIException with the violations in the msg
*/
assertEquals("Request success", Response.Status.CREATED.getStatusCode(), response.getStatus());
}
+ @Test
+ public void invalidNodeCreationPaylodTest() throws IOException {
+ String payload = getBulkPayload("single-transaction/put-complex-with-missing-properties")
+ .replaceAll("<methodName>", name.getMethodName());
+ Response response = executeRequest(payload);
+
+ assertEquals("Request fails with 400", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertThat("Response contains correct index of failed operation.", response.getEntity().toString(),
+ containsString("Error with operation 0"));
+ assertThat("Response contains information about missing properties.", response.getEntity().toString(),
+ containsString("Missing required property:"));
+ }
+
protected Response executeRequest(String finalPayload) {
MockHttpServletRequest mockReq = new MockHttpServletRequest(HttpMethod.POST, "http://www.test.com");