List of usage examples for org.springframework.restdocs.operation.preprocess Preprocessors prettyPrint
public static OperationPreprocessor prettyPrint()
From source file:com.netflix.genie.web.controllers.CommandRestControllerIntegrationTests.java
/** * Test to make sure we can update the dependencies for an command after it is created. * * @throws Exception on configuration problems *//* w ww . j a v a 2 s. c o m*/ @Test public void canUpdateDependenciesForCommand() throws Exception { Assert.assertThat(this.jpaCommandRepository.count(), Matchers.is(0L)); this.createConfigResource( new Command.Builder(NAME, USER, VERSION, CommandStatus.ACTIVE, EXECUTABLE, CHECK_DELAY).withId(ID) .build(), null); final RestDocumentationResultHandler updateResultHandler = MockMvcRestDocumentation.document( "{class-name}/{method-name}/{step}/", Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), Preprocessors.preprocessResponse(Preprocessors.prettyPrint()), Snippets.CONTENT_TYPE_HEADER, // Request header Snippets.ID_PATH_PARAM, // Path parameters PayloadDocumentation.requestFields(Snippets.DEPENDENCIES_FIELDS) // Request fields ); this.canUpdateElementsForResource(COMMANDS_API + "/{id}/dependencies", ID, updateResultHandler); }
From source file:com.netflix.genie.web.controllers.ApplicationRestControllerIntegrationTests.java
/** * Test to make sure we can delete the configurations for an application after it is created. * * @throws Exception on configuration problems *//*from w w w . j av a 2s . c o m*/ @Test public void canDeleteConfigsForApplication() throws Exception { Assert.assertThat(this.jpaApplicationRepository.count(), Matchers.is(0L)); this.createConfigResource( new Application.Builder(NAME, USER, VERSION, ApplicationStatus.ACTIVE).withId(ID).build(), null); final RestDocumentationResultHandler deleteResultHandler = MockMvcRestDocumentation.document( "{class-name}/{method-name}/{step}/", Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), Preprocessors.preprocessResponse(Preprocessors.prettyPrint()), Snippets.ID_PATH_PARAM // Path parameters ); this.canDeleteElementsFromResource(APPLICATIONS_API + "/{id}/configs", ID, deleteResultHandler); }
From source file:com.netflix.genie.web.controllers.ClusterRestControllerIntegrationTests.java
/** * Test to make sure we can delete the tags for a cluster after it is created. * * @throws Exception on configuration problems *//* w ww.java2s. com*/ @Test public void canDeleteTagsForCluster() throws Exception { Assert.assertThat(this.jpaClusterRepository.count(), Matchers.is(0L)); this.createConfigResource(new Cluster.Builder(NAME, USER, VERSION, ClusterStatus.UP).withId(ID).build(), null); final RestDocumentationResultHandler deleteResultHandler = MockMvcRestDocumentation.document( "{class-name}/{method-name}/{step}/", Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), Preprocessors.preprocessResponse(Preprocessors.prettyPrint()), Snippets.ID_PATH_PARAM); final String api = CLUSTERS_API + "/{id}/tags"; this.canDeleteTagsForResource(api, ID, NAME, deleteResultHandler); }
From source file:com.netflix.genie.web.controllers.ApplicationRestControllerIntegrationTests.java
/** * Test to make sure we can add dependencies to the application after it is created. * * @throws Exception on configuration problems *//*from w w w. ja v a 2 s . com*/ @Test public void canAddDependenciesToApplication() throws Exception { Assert.assertThat(this.jpaApplicationRepository.count(), Matchers.is(0L)); this.createConfigResource( new Application.Builder(NAME, USER, VERSION, ApplicationStatus.ACTIVE).withId(ID).build(), null); final RestDocumentationResultHandler addResultHandler = MockMvcRestDocumentation.document( "{class-name}/{method-name}/{step}/", Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), Preprocessors.preprocessResponse(Preprocessors.prettyPrint()), Snippets.ID_PATH_PARAM, // path params Snippets.CONTENT_TYPE_HEADER, // request header PayloadDocumentation.requestFields(Snippets.DEPENDENCIES_FIELDS) // response fields ); final RestDocumentationResultHandler getResultHandler = MockMvcRestDocumentation.document( "{class-name}/{method-name}/{step}/", Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), Preprocessors.preprocessResponse(Preprocessors.prettyPrint()), Snippets.ID_PATH_PARAM, // path params Snippets.JSON_CONTENT_TYPE_HEADER, // response headers PayloadDocumentation.responseFields(Snippets.DEPENDENCIES_FIELDS) // response fields ); this.canAddElementsToResource(APPLICATIONS_API + "/{id}/dependencies", ID, addResultHandler, getResultHandler); }
From source file:com.netflix.genie.web.controllers.CommandRestControllerIntegrationTests.java
/** * Test to make sure we can delete the dependencies for an command after it is created. * * @throws Exception on configuration problems *//* w ww . ja v a2 s.c o m*/ @Test public void canDeleteDependenciesForCommand() throws Exception { Assert.assertThat(this.jpaCommandRepository.count(), Matchers.is(0L)); this.createConfigResource( new Command.Builder(NAME, USER, VERSION, CommandStatus.ACTIVE, EXECUTABLE, CHECK_DELAY).withId(ID) .build(), null); final RestDocumentationResultHandler deleteResultHandler = MockMvcRestDocumentation.document( "{class-name}/{method-name}/{step}/", Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), Preprocessors.preprocessResponse(Preprocessors.prettyPrint()), Snippets.ID_PATH_PARAM // Path variables ); this.canDeleteElementsFromResource(COMMANDS_API + "/{id}/dependencies", ID, deleteResultHandler); }
From source file:com.netflix.genie.web.controllers.ClusterRestControllerIntegrationTests.java
/** * Test to make sure we can delete a tag for a cluster after it is created. * * @throws Exception on configuration problems *//* ww w . j a va 2 s .c o m*/ @Test public void canDeleteTagForCluster() throws Exception { Assert.assertThat(this.jpaClusterRepository.count(), Matchers.is(0L)); this.createConfigResource(new Cluster.Builder(NAME, USER, VERSION, ClusterStatus.UP).withId(ID).build(), null); final String api = CLUSTERS_API + "/{id}/tags"; final RestDocumentationResultHandler deleteResultHandler = MockMvcRestDocumentation.document( "{class-name}/{method-name}/{step}/", Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), Preprocessors.preprocessResponse(Preprocessors.prettyPrint()), Snippets.ID_PATH_PARAM .and(RequestDocumentation.parameterWithName("tag").description("The tag to remove"))); this.canDeleteTagForResource(api, ID, NAME, deleteResultHandler); }
From source file:com.netflix.genie.web.controllers.JobRestControllerIntegrationTests.java
private void checkJobCluster(final int documentationId, final String id) throws Exception { final RestDocumentationResultHandler getResultHandler = MockMvcRestDocumentation.document( "{class-name}/" + documentationId + "/getJobCluster/", Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), Preprocessors.preprocessResponse(Preprocessors.prettyPrint()), Snippets.ID_PATH_PARAM, // Path parameters Snippets.HAL_CONTENT_TYPE_HEADER, // Response Headers Snippets.getClusterResponsePayload(), // Response fields Snippets.CLUSTER_LINKS // Links );// w w w .ja v a 2 s .c o m this.mvc.perform(RestDocumentationRequestBuilders.get(JOBS_API + "/{id}/cluster", id)) .andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.jsonPath(ID_PATH, Matchers.is(CLUSTER1_ID))) .andExpect(MockMvcResultMatchers.jsonPath(CREATED_PATH, Matchers.notNullValue())) .andExpect(MockMvcResultMatchers.jsonPath(UPDATED_PATH, Matchers.notNullValue())) .andExpect(MockMvcResultMatchers.jsonPath(NAME_PATH, Matchers.is(CLUSTER1_NAME))) .andExpect(MockMvcResultMatchers.jsonPath(USER_PATH, Matchers.is(CLUSTER1_USER))) .andExpect(MockMvcResultMatchers.jsonPath(VERSION_PATH, Matchers.is(CLUSTER1_VERSION))) .andDo(getResultHandler); }
From source file:com.netflix.genie.web.controllers.CommandRestControllerIntegrationTests.java
/** * Test to make sure we can add tags to the command after it is created. * * @throws Exception on configuration problems *///from w w w. j a v a2s . co m @Test public void canAddTagsToCommand() throws Exception { Assert.assertThat(this.jpaCommandRepository.count(), Matchers.is(0L)); this.createConfigResource( new Command.Builder(NAME, USER, VERSION, CommandStatus.ACTIVE, EXECUTABLE, CHECK_DELAY).withId(ID) .build(), null); final String api = COMMANDS_API + "/{id}/tags"; final RestDocumentationResultHandler addResultHandler = MockMvcRestDocumentation.document( "{class-name}/{method-name}/{step}/", Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), Preprocessors.preprocessResponse(Preprocessors.prettyPrint()), Snippets.CONTENT_TYPE_HEADER, // Request header Snippets.ID_PATH_PARAM, // Path parameters PayloadDocumentation.requestFields(Snippets.TAGS_FIELDS) // Request fields ); final RestDocumentationResultHandler getResultHandler = MockMvcRestDocumentation.document( "{class-name}/{method-name}/{step}/", Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), Preprocessors.preprocessResponse(Preprocessors.prettyPrint()), Snippets.ID_PATH_PARAM, // Path parameters Snippets.JSON_CONTENT_TYPE_HEADER, // Response header PayloadDocumentation.responseFields(Snippets.TAGS_FIELDS)); this.canAddTagsToResource(api, ID, NAME, addResultHandler, getResultHandler); }
From source file:com.netflix.genie.web.controllers.ApplicationRestControllerIntegrationTests.java
/** * Test to make sure we can update the dependencies for an application after it is created. * * @throws Exception on configuration problems *//*from w ww . j ava 2 s. c o m*/ @Test public void canUpdateDependenciesForApplication() throws Exception { Assert.assertThat(this.jpaApplicationRepository.count(), Matchers.is(0L)); this.createConfigResource( new Application.Builder(NAME, USER, VERSION, ApplicationStatus.ACTIVE).withId(ID).build(), null); final RestDocumentationResultHandler updateResultHandler = MockMvcRestDocumentation.document( "{class-name}/{method-name}/{step}/", Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), Preprocessors.preprocessResponse(Preprocessors.prettyPrint()), Snippets.CONTENT_TYPE_HEADER, // Request header Snippets.ID_PATH_PARAM, // Path parameters PayloadDocumentation.requestFields(Snippets.DEPENDENCIES_FIELDS) // Request fields ); this.canUpdateElementsForResource(APPLICATIONS_API + "/{id}/dependencies", ID, updateResultHandler); }
From source file:com.netflix.genie.web.controllers.JobRestControllerIntegrationTests.java
private void checkJobCommand(final int documentationId, final String id) throws Exception { final RestDocumentationResultHandler getResultHandler = MockMvcRestDocumentation.document( "{class-name}/" + documentationId + "/getJobCommand/", Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), Preprocessors.preprocessResponse(Preprocessors.prettyPrint()), Snippets.ID_PATH_PARAM, // Path parameters Snippets.HAL_CONTENT_TYPE_HEADER, // Response Headers Snippets.getCommandResponsePayload(), // Response fields Snippets.COMMAND_LINKS // Links );/*from w w w . j a v a 2 s . c o m*/ this.mvc.perform(RestDocumentationRequestBuilders.get(JOBS_API + "/{id}/command", id)) .andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.jsonPath(ID_PATH, Matchers.is(CMD1_ID))) .andExpect(MockMvcResultMatchers.jsonPath(CREATED_PATH, Matchers.notNullValue())) .andExpect(MockMvcResultMatchers.jsonPath(UPDATED_PATH, Matchers.notNullValue())) .andExpect(MockMvcResultMatchers.jsonPath(NAME_PATH, Matchers.is(CMD1_NAME))) .andExpect(MockMvcResultMatchers.jsonPath(USER_PATH, Matchers.is(CMD1_USER))) .andExpect(MockMvcResultMatchers.jsonPath(VERSION_PATH, Matchers.is(CMD1_VERSION))) .andExpect(MockMvcResultMatchers.jsonPath("$.executable", Matchers.is(CMD1_EXECUTABLE))) .andDo(getResultHandler); }