use of org.cloudfoundry.credhub.request.DefaultCredentialGenerateRequest in project credhub by cloudfoundry-incubator.
the class CredentialsControllerTypeSpecificGenerateTest method generatingACredential_validatesTheRequestBody.
@Test
public void generatingACredential_validatesTheRequestBody() throws Exception {
MockHttpServletRequestBuilder request = createGenerateNewCredentialRequest();
DefaultCredentialGenerateRequest requestBody = mock(DefaultCredentialGenerateRequest.class);
Mockito.doThrow(new ParameterizedValidationException("error.bad_request")).when(requestBody).validate();
doReturn(requestBody).when(objectMapper).readValue(anyString(), any(Class.class));
mockMvc.perform(request).andExpect(status().isBadRequest()).andExpect(content().json("{\"error\":\"The request could not be fulfilled because the request path or body did not meet expectation. Please check the documentation for required formatting and retry your request.\"}"));
}
Aggregations