List of usage examples for org.springframework.restdocs.operation.preprocess Preprocessors preprocessRequest
public static OperationRequestPreprocessor preprocessRequest(OperationPreprocessor... preprocessors)
From source file:com.netflix.genie.web.controllers.CommandRestControllerIntegrationTests.java
/** * Test to make sure we can update the configurations for a command after it is created. * * @throws Exception on configuration problems *///from ww w. ja va 2 s .c o m @Test public void canUpdateConfigsForCommand() 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.CONFIG_FIELDS) // Request fields ); this.canUpdateElementsForResource(COMMANDS_API + "/{id}/configs", ID, updateResultHandler); }
From source file:com.netflix.genie.web.controllers.ClusterRestControllerIntegrationTests.java
/** * Test to make sure we can delete the dependencies for a cluster after it is created. * * @throws Exception on configuration problems *//*from w w w. ja va 2s . c om*/ @Test public void canDeleteDependenciesForCluster() 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); this.canDeleteElementsFromResource(CLUSTERS_API + "/{id}/dependencies", ID, deleteResultHandler); }
From source file:com.netflix.genie.web.controllers.CommandRestControllerIntegrationTests.java
/** * Test to make sure we can delete the configurations for a command after it is created. * * @throws Exception on configuration problems *///w w w .ja va 2 s. c o m @Test public void canDeleteConfigsForCommand() 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); this.canDeleteElementsFromResource(COMMANDS_API + "/{id}/configs", ID, deleteResultHandler); }
From source file:com.netflix.genie.web.controllers.ApplicationRestControllerIntegrationTests.java
/** * Test to make sure we can add configurations to the application after it is created. * * @throws Exception on configuration problems *//*from w w w .j av a 2 s . c om*/ @Test public void canAddConfigsToApplication() 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.CONTENT_TYPE_HEADER, // request headers Snippets.ID_PATH_PARAM, // path parameters PayloadDocumentation.requestFields(Snippets.CONFIG_FIELDS) // request payload 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 headers PayloadDocumentation.responseFields(Snippets.CONFIG_FIELDS) // response fields ); this.canAddElementsToResource(APPLICATIONS_API + "/{id}/configs", ID, addResultHandler, getResultHandler); }
From source file:com.netflix.genie.web.controllers.ClusterRestControllerIntegrationTests.java
/** * Test to make sure we can add tags to the cluster after it is created. * * @throws Exception on configuration problems *///w w w .java2s . c o m @Test public void canAddTagsToCluster() 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 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.CommandRestControllerIntegrationTests.java
/** * Test to make sure we can add dependencies to the command after it is created. * * @throws Exception on configuration problems *//*from ww w . j av a 2s. co m*/ @Test public void canAddDependenciesToCommand() 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 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(COMMANDS_API + "/{id}/dependencies", ID, addResultHandler, getResultHandler); }
From source file:com.netflix.genie.web.controllers.ApplicationRestControllerIntegrationTests.java
/** * Test to make sure we can update the configurations for an application after it is created. * * @throws Exception on configuration problems *///ww w .java2 s . c om @Test public void canUpdateConfigsForApplication() 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.CONFIG_FIELDS) // Request fields ); this.canUpdateElementsForResource(APPLICATIONS_API + "/{id}/configs", ID, updateResultHandler); }
From source file:com.netflix.genie.web.controllers.ClusterRestControllerIntegrationTests.java
/** * Test to make sure we can update the tags for a cluster after it is created. * * @throws Exception on configuration problems */// w w w .ja v a 2 s .com @Test public void canUpdateTagsForCluster() 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 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.TAGS_FIELDS) // Request fields ); this.canUpdateTagsForResource(api, ID, NAME, updateResultHandler); }
From source file:com.netflix.genie.web.controllers.JobRestControllerIntegrationTests.java
private void checkJobExecution(final int documentationId, final String id) throws Exception { final RestDocumentationResultHandler getResultHandler = MockMvcRestDocumentation.document( "{class-name}/" + documentationId + "/getJobExecution/", Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), Preprocessors.preprocessResponse(Preprocessors.prettyPrint()), Snippets.ID_PATH_PARAM, // Path parameters Snippets.HAL_CONTENT_TYPE_HEADER, // Response Headers Snippets.getJobExecutionResponsePayload(), // Response fields Snippets.JOB_EXECUTION_LINKS // Links );/*from w w w . j ava 2 s . co m*/ this.mvc.perform(RestDocumentationRequestBuilders.get(JOBS_API + "/{id}/execution", id)) .andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.jsonPath(ID_PATH, Matchers.is(id))) .andExpect(MockMvcResultMatchers.jsonPath(CREATED_PATH, Matchers.notNullValue())) .andExpect(MockMvcResultMatchers.jsonPath(UPDATED_PATH, Matchers.notNullValue())) .andExpect(MockMvcResultMatchers.jsonPath(HOST_NAME_PATH, Matchers.is(this.hostname))) .andExpect(MockMvcResultMatchers.jsonPath(PROCESS_ID_PATH, Matchers.notNullValue())) .andExpect(MockMvcResultMatchers.jsonPath(CHECK_DELAY_PATH, Matchers.is((int) CHECK_DELAY))) .andExpect( MockMvcResultMatchers.jsonPath(EXIT_CODE_PATH, Matchers.is(JobExecution.SUCCESS_EXIT_CODE))) .andDo(getResultHandler); }
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 *//*from ww w.j a va 2s . com*/ @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); }