List of usage examples for org.springframework.restdocs.mockmvc MockMvcRestDocumentation document
public static RestDocumentationResultHandler document(String identifier, OperationResponsePreprocessor responsePreprocessor, Snippet... snippets)
From source file:com.netflix.genie.web.controllers.ClusterRestControllerIntegrationTests.java
/** * Make sure can successfully delete all clusters. * * @throws Exception on a configuration error *//*from ww w . j av a 2s . c om*/ @Test public void canDeleteAllClusters() throws Exception { Assert.assertThat(this.jpaClusterRepository.count(), Matchers.is(0L)); this.createConfigResource(new Cluster.Builder(NAME, USER, VERSION, ClusterStatus.UP).build(), null); this.createConfigResource(new Cluster.Builder(NAME, USER, VERSION, ClusterStatus.OUT_OF_SERVICE).build(), null); this.createConfigResource(new Cluster.Builder(NAME, USER, VERSION, ClusterStatus.TERMINATED).build(), null); Assert.assertThat(this.jpaClusterRepository.count(), Matchers.is(3L)); final RestDocumentationResultHandler deleteResultHandler = MockMvcRestDocumentation.document( "{class-name}/{method-name}/{step}/", Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), Preprocessors.preprocessResponse(Preprocessors.prettyPrint())); this.mvc.perform(MockMvcRequestBuilders.delete(CLUSTERS_API)) .andExpect(MockMvcResultMatchers.status().isNoContent()).andDo(deleteResultHandler); Assert.assertThat(this.jpaClusterRepository.count(), Matchers.is(0L)); }
From source file:com.netflix.genie.web.controllers.CommandRestControllerIntegrationTests.java
/** * Make sure can successfully delete all commands. * * @throws Exception on a configuration error *//*from w w w . j av a2 s. co m*/ @Test public void canDeleteAllCommands() throws Exception { Assert.assertThat(this.jpaCommandRepository.count(), Matchers.is(0L)); this.createConfigResource( new Command.Builder(NAME, USER, VERSION, CommandStatus.ACTIVE, EXECUTABLE, CHECK_DELAY).build(), null); this.createConfigResource( new Command.Builder(NAME, USER, VERSION, CommandStatus.DEPRECATED, EXECUTABLE, CHECK_DELAY).build(), null); this.createConfigResource( new Command.Builder(NAME, USER, VERSION, CommandStatus.INACTIVE, EXECUTABLE, CHECK_DELAY).build(), null); Assert.assertThat(this.jpaCommandRepository.count(), Matchers.is(3L)); final RestDocumentationResultHandler deleteResultHandler = MockMvcRestDocumentation.document( "{class-name}/{method-name}/{step}/", Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), Preprocessors.preprocessResponse(Preprocessors.prettyPrint())); this.mvc.perform(MockMvcRequestBuilders.delete(COMMANDS_API)) .andExpect(MockMvcResultMatchers.status().isNoContent()).andDo(deleteResultHandler); Assert.assertThat(this.jpaCommandRepository.count(), Matchers.is(0L)); }
From source file:com.netflix.genie.web.controllers.ApplicationRestControllerIntegrationTests.java
/** * Make sure can successfully delete all applications. * * @throws Exception on a configuration error *//* www. ja v a 2s . c o m*/ @Test public void canDeleteAllApplications() throws Exception { Assert.assertThat(this.jpaApplicationRepository.count(), Matchers.is(0L)); this.createConfigResource(new Application.Builder(NAME, USER, VERSION, ApplicationStatus.ACTIVE).build(), null); this.createConfigResource( new Application.Builder(NAME, USER, VERSION, ApplicationStatus.DEPRECATED).build(), null); this.createConfigResource(new Application.Builder(NAME, USER, VERSION, ApplicationStatus.INACTIVE).build(), null); Assert.assertThat(this.jpaApplicationRepository.count(), Matchers.is(3L)); final RestDocumentationResultHandler deleteResultHandler = MockMvcRestDocumentation.document( "{class-name}/{method-name}/{step}/", Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), Preprocessors.preprocessResponse(Preprocessors.prettyPrint())); this.mvc.perform(MockMvcRequestBuilders.delete(APPLICATIONS_API)) .andExpect(MockMvcResultMatchers.status().isNoContent()).andDo(deleteResultHandler); Assert.assertThat(this.jpaApplicationRepository.count(), Matchers.is(0L)); }