org.springframework.restdocs.payload.PayloadDocumentation Java Examples
The following examples show how to use
org.springframework.restdocs.payload.PayloadDocumentation.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplicationRestControllerIntegrationTest.java From genie with Apache License 2.0 | 6 votes |
@Test void canUpdateDependenciesForApplication() throws Exception { this.createConfigResource( new Application.Builder(NAME, USER, VERSION, ApplicationStatus.ACTIVE).withId(ID).build(), null ); final RestDocumentationFilter updateFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", 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, updateFilter ); }
Example #2
Source File: Snippets.java From genie with Apache License 2.0 | 6 votes |
private static FieldDescriptor[] getBaseFieldDescriptors(final ConstraintDescriptions constraintDescriptions) { return new FieldDescriptor[]{ PayloadDocumentation .fieldWithPath("id") .attributes(getConstraintsForField(constraintDescriptions, "id")) .description("The id. If not set the system will set one.") .type(JsonFieldType.STRING) .optional(), PayloadDocumentation .fieldWithPath("created") .attributes(getConstraintsForField(constraintDescriptions, "created")) .description("The UTC time of creation. Set by system. ISO8601 format including milliseconds.") .type(JsonFieldType.STRING) .optional(), PayloadDocumentation .fieldWithPath("updated") .attributes(getConstraintsForField(constraintDescriptions, "updated")) .description("The UTC time of last update. Set by system. ISO8601 format including milliseconds.") .type(JsonFieldType.STRING) .optional(), }; }
Example #3
Source File: Snippets.java From genie with Apache License 2.0 | 6 votes |
private static FieldDescriptor[] getClusterFieldDescriptors() { return ArrayUtils.addAll( getConfigFieldDescriptors(CLUSTER_CONSTRAINTS), PayloadDocumentation .fieldWithPath("status") .attributes(getConstraintsForField(CLUSTER_CONSTRAINTS, "status")) .description( "The status of the cluster. Options: " + Arrays.toString(ClusterStatus.values()) ) .type(JsonFieldType.STRING), PayloadDocumentation .fieldWithPath("dependencies") .attributes(getConstraintsForField(CLUSTER_CONSTRAINTS, "dependencies")) .description("The dependencies for the cluster") .type(JsonFieldType.ARRAY) .optional() ); }
Example #4
Source File: CommandRestControllerIntegrationTest.java From genie with Apache License 2.0 | 6 votes |
@Test void canUpdateTagsForCommand() throws Exception { this.createConfigResource( new Command .Builder(NAME, USER, VERSION, CommandStatus.ACTIVE, EXECUTABLE_AND_ARGS, CHECK_DELAY) .withId(ID) .build(), null ); final String api = COMMANDS_API + "/{id}/tags"; final RestDocumentationFilter updateFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.CONTENT_TYPE_HEADER, // Request header Snippets.ID_PATH_PARAM, // Path parameters PayloadDocumentation.requestFields(Snippets.TAGS_FIELDS) // Request fields ); this.canUpdateTagsForResource(api, ID, NAME, updateFilter); }
Example #5
Source File: CommandRestControllerIntegrationTest.java From genie with Apache License 2.0 | 6 votes |
@Test void canAddTagsToCommand() throws Exception { this.createConfigResource( new Command .Builder(NAME, USER, VERSION, CommandStatus.ACTIVE, EXECUTABLE_AND_ARGS, CHECK_DELAY) .withId(ID) .build(), null ); final String api = COMMANDS_API + "/{id}/tags"; final RestDocumentationFilter addFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.CONTENT_TYPE_HEADER, // Request header Snippets.ID_PATH_PARAM, // Path parameters PayloadDocumentation.requestFields(Snippets.TAGS_FIELDS) // Request fields ); final RestDocumentationFilter getFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.ID_PATH_PARAM, // Path parameters Snippets.JSON_CONTENT_TYPE_HEADER, // Response header PayloadDocumentation.responseFields(Snippets.TAGS_FIELDS) ); this.canAddTagsToResource(api, ID, NAME, addFilter, getFilter); }
Example #6
Source File: CommandRestControllerIntegrationTest.java From genie with Apache License 2.0 | 6 votes |
@Test void canUpdateDependenciesForCommand() throws Exception { this.createConfigResource( new Command.Builder(NAME, USER, VERSION, CommandStatus.ACTIVE, EXECUTABLE_AND_ARGS, CHECK_DELAY) .withId(ID) .build(), null ); final RestDocumentationFilter updateFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", 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, updateFilter ); }
Example #7
Source File: Snippets.java From genie with Apache License 2.0 | 6 votes |
private static FieldDescriptor[] getApplicationFieldDescriptors() { return ArrayUtils.addAll( getConfigFieldDescriptors(APPLICATION_CONSTRAINTS), PayloadDocumentation .fieldWithPath("type") .attributes(getConstraintsForField(APPLICATION_CONSTRAINTS, "type")) .description("The type of application this is (e.g. hadoop, presto, spark). Can be used to group.") .type(JsonFieldType.STRING) .optional(), PayloadDocumentation .fieldWithPath("status") .attributes(getConstraintsForField(APPLICATION_CONSTRAINTS, "status")) .description( "The status of the application. Options: " + Arrays.toString(ApplicationStatus.values()) ) .type(JsonFieldType.STRING), PayloadDocumentation .fieldWithPath("dependencies") .attributes(getConstraintsForField(APPLICATION_CONSTRAINTS, "dependencies")) .description("The dependencies for the application") .type(JsonFieldType.ARRAY) .optional() ); }
Example #8
Source File: CommandRestControllerIntegrationTest.java From genie with Apache License 2.0 | 6 votes |
@Test void canUpdateConfigsForCommand() throws Exception { this.createConfigResource( new Command .Builder(NAME, USER, VERSION, CommandStatus.ACTIVE, EXECUTABLE_AND_ARGS, CHECK_DELAY) .withId(ID) .build(), null ); final RestDocumentationFilter updateFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", 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, updateFilter); }
Example #9
Source File: CommandRestControllerIntegrationTest.java From genie with Apache License 2.0 | 6 votes |
@Test void canAddConfigsToCommand() throws Exception { this.createConfigResource( new Command .Builder(NAME, USER, VERSION, CommandStatus.ACTIVE, EXECUTABLE_AND_ARGS, CHECK_DELAY) .withId(ID) .build(), null ); final RestDocumentationFilter addFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.ID_PATH_PARAM, // path params Snippets.CONTENT_TYPE_HEADER, // request header PayloadDocumentation.requestFields(Snippets.CONFIG_FIELDS) // response fields ); final RestDocumentationFilter getFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.ID_PATH_PARAM, // path params Snippets.JSON_CONTENT_TYPE_HEADER, // response headers PayloadDocumentation.responseFields(Snippets.CONFIG_FIELDS) // response fields ); this.canAddElementsToResource(COMMANDS_API + "/{id}/configs", ID, addFilter, getFilter); }
Example #10
Source File: ApplicationRestControllerIntegrationTest.java From genie with Apache License 2.0 | 6 votes |
@Test void canUpdateTagsForApplication() throws Exception { this.createConfigResource( new Application.Builder(NAME, USER, VERSION, ApplicationStatus.ACTIVE).withId(ID).build(), null ); final String api = APPLICATIONS_API + "/{id}/tags"; final RestDocumentationFilter updateFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.CONTENT_TYPE_HEADER, // Request header Snippets.ID_PATH_PARAM, // Path parameters PayloadDocumentation.requestFields(Snippets.TAGS_FIELDS) // Request fields ); this.canUpdateTagsForResource(api, ID, NAME, updateFilter); }
Example #11
Source File: ApplicationRestControllerIntegrationTest.java From genie with Apache License 2.0 | 6 votes |
@Test void canAddTagsToApplication() throws Exception { this.createConfigResource( new Application.Builder(NAME, USER, VERSION, ApplicationStatus.ACTIVE).withId(ID).build(), null ); final String api = APPLICATIONS_API + "/{id}/tags"; final RestDocumentationFilter addFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.ID_PATH_PARAM, // path params Snippets.CONTENT_TYPE_HEADER, // request header PayloadDocumentation.requestFields(Snippets.TAGS_FIELDS) // response fields ); final RestDocumentationFilter getFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.ID_PATH_PARAM, // path parameters Snippets.JSON_CONTENT_TYPE_HEADER, // response headers PayloadDocumentation.responseFields(Snippets.TAGS_FIELDS) // response fields ); this.canAddTagsToResource(api, ID, NAME, addFilter, getFilter); }
Example #12
Source File: ApplicationRestControllerIntegrationTest.java From genie with Apache License 2.0 | 6 votes |
@Test void canAddDependenciesToApplication() throws Exception { this.createConfigResource( new Application.Builder(NAME, USER, VERSION, ApplicationStatus.ACTIVE).withId(ID).build(), null ); final RestDocumentationFilter addFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.ID_PATH_PARAM, // path params Snippets.CONTENT_TYPE_HEADER, // request header PayloadDocumentation.requestFields(Snippets.DEPENDENCIES_FIELDS) // response fields ); final RestDocumentationFilter getFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", 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, addFilter, getFilter ); }
Example #13
Source File: JobRestControllerIntegrationTest.java From genie with Apache License 2.0 | 6 votes |
private void checkJobStatus(final int documentationId, final String id) { final RestDocumentationFilter getResultFilter = RestAssuredRestDocumentation.document( "{class-name}/" + documentationId + "/getJobStatus/", Snippets.ID_PATH_PARAM, // Path parameters Snippets.JSON_CONTENT_TYPE_HEADER, // Response Headers PayloadDocumentation.responseFields( PayloadDocumentation .fieldWithPath("status") .description("The job status. One of: " + Arrays.toString(JobStatus.values())) .attributes(Snippets.EMPTY_CONSTRAINTS) ) // Response fields ); RestAssured .given(this.getRequestSpecification()) .filter(getResultFilter) .when() .port(this.port) .get(JOBS_API + "/{id}/status", id) .then() .contentType(Matchers.containsString(MediaType.APPLICATION_JSON_VALUE)) .body(STATUS_PATH, Matchers.is(JobStatus.SUCCEEDED.toString())); }
Example #14
Source File: ApplicationRestControllerIntegrationTest.java From genie with Apache License 2.0 | 6 votes |
@Test void canAddConfigsToApplication() throws Exception { this.createConfigResource( new Application.Builder(NAME, USER, VERSION, ApplicationStatus.ACTIVE).withId(ID).build(), null ); final RestDocumentationFilter addFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.CONTENT_TYPE_HEADER, // request headers Snippets.ID_PATH_PARAM, // path parameters PayloadDocumentation.requestFields(Snippets.CONFIG_FIELDS) // request payload fields ); final RestDocumentationFilter getFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", 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, addFilter, getFilter); }
Example #15
Source File: JobRestControllerIntegrationTest.java From genie with Apache License 2.0 | 6 votes |
private void checkJobApplications(final int documentationId, final String id) { final RestDocumentationFilter getResultFilter = RestAssuredRestDocumentation.document( "{class-name}/" + documentationId + "/getJobApplications/", Snippets.ID_PATH_PARAM, // Path parameters Snippets.HAL_CONTENT_TYPE_HEADER, // Response Headers PayloadDocumentation.responseFields( PayloadDocumentation .subsectionWithPath("[]") .description("The applications for the job") .attributes(Snippets.EMPTY_CONSTRAINTS) ) // Response fields ); RestAssured .given(this.getRequestSpecification()) .filter(getResultFilter) .when() .port(this.port) .get(JOBS_API + "/{id}/applications", id) .then() .statusCode(Matchers.is(HttpStatus.OK.value())) .contentType(Matchers.containsString(MediaTypes.HAL_JSON_VALUE)) .body("$", Matchers.hasSize(2)) .body("[0].id", Matchers.is(APP1_ID)) .body("[1].id", Matchers.is(APP2_ID)); }
Example #16
Source File: ClusterRestControllerIntegrationTest.java From genie with Apache License 2.0 | 6 votes |
@Test void canAddConfigsToCluster() throws Exception { this.createConfigResource(new Cluster.Builder(NAME, USER, VERSION, ClusterStatus.UP).withId(ID).build(), null); final RestDocumentationFilter addFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.ID_PATH_PARAM, // path params Snippets.CONTENT_TYPE_HEADER, // request header PayloadDocumentation.requestFields(Snippets.CONFIG_FIELDS) // response fields ); final RestDocumentationFilter getFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.ID_PATH_PARAM, // path params Snippets.JSON_CONTENT_TYPE_HEADER, // response headers PayloadDocumentation.responseFields(Snippets.CONFIG_FIELDS) // response fields ); this.canAddElementsToResource(CLUSTERS_API + "/{id}/configs", ID, addFilter, getFilter); }
Example #17
Source File: Snippets.java From genie with Apache License 2.0 | 6 votes |
static ResponseFieldsSnippet resolveClustersForCommandClusterCriteriaResponsePayload() { return PayloadDocumentation .responseFields( PayloadDocumentation .fieldWithPath("[]") .attributes(EMPTY_CONSTRAINTS) .description("The list of criterion and associated resolved clusters") .type(JsonFieldType.ARRAY) .optional() ) .andWithPrefix( "[].", PayloadDocumentation .fieldWithPath("criterion") .attributes(EMPTY_CONSTRAINTS) .description("The criterion that was evaluated to yield the resources") .type(JsonFieldType.OBJECT), PayloadDocumentation .fieldWithPath("resources") .attributes(EMPTY_CONSTRAINTS) .description("The resources that were resolved by evaluating the criterion") .type(JsonFieldType.ARRAY) ) .andWithPrefix("[].criterion.", getCriterionFieldDescriptors()) .andWithPrefix("[].resources[].", getClusterFieldDescriptors()); }
Example #18
Source File: ClusterRestControllerIntegrationTest.java From genie with Apache License 2.0 | 6 votes |
@Test void canAddDependenciesToCluster() throws Exception { this.createConfigResource(new Cluster.Builder(NAME, USER, VERSION, ClusterStatus.UP).withId(ID).build(), null); final RestDocumentationFilter addFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.ID_PATH_PARAM, // path params Snippets.CONTENT_TYPE_HEADER, // request header PayloadDocumentation.requestFields(Snippets.DEPENDENCIES_FIELDS) // response fields ); final RestDocumentationFilter getFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.ID_PATH_PARAM, // path params Snippets.JSON_CONTENT_TYPE_HEADER, // response headers PayloadDocumentation.responseFields(Snippets.DEPENDENCIES_FIELDS) // response fields ); this.canAddElementsToResource(CLUSTERS_API + "/{id}/dependencies", ID, addFilter, getFilter); }
Example #19
Source File: ClusterRestControllerIntegrationTest.java From genie with Apache License 2.0 | 6 votes |
@Test void canAddTagsToCluster() throws Exception { this.createConfigResource(new Cluster.Builder(NAME, USER, VERSION, ClusterStatus.UP).withId(ID).build(), null); final String api = CLUSTERS_API + "/{id}/tags"; final RestDocumentationFilter addFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.CONTENT_TYPE_HEADER, // Request header Snippets.ID_PATH_PARAM, // Path parameters PayloadDocumentation.requestFields(Snippets.TAGS_FIELDS) // Request fields ); final RestDocumentationFilter getFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.ID_PATH_PARAM, // Path parameters Snippets.JSON_CONTENT_TYPE_HEADER, // Response header PayloadDocumentation.responseFields(Snippets.TAGS_FIELDS) ); this.canAddTagsToResource(api, ID, NAME, addFilter, getFilter); }
Example #20
Source File: Snippets.java From genie with Apache License 2.0 | 5 votes |
private static FieldDescriptor[] getConfigFieldDescriptors(final ConstraintDescriptions constraintDescriptions) { return ArrayUtils.addAll( getSetupFieldDescriptors(constraintDescriptions), PayloadDocumentation .fieldWithPath("configs") .attributes(getConstraintsForField(constraintDescriptions, "configs")) .description("Any configuration files needed for the resource") .type(JsonFieldType.ARRAY) .optional() ); }
Example #21
Source File: Snippets.java From genie with Apache License 2.0 | 5 votes |
private static FieldDescriptor[] getJobExecutionFieldDescriptors() { return ArrayUtils.addAll( getBaseFieldDescriptors(JOB_EXECUTION_CONSTRAINTS), PayloadDocumentation .fieldWithPath("hostName") .attributes(getConstraintsForField(JOB_EXECUTION_CONSTRAINTS, "hostName")) .description("The host name of the Genie node responsible for the job") .type(JsonFieldType.STRING), PayloadDocumentation .fieldWithPath("processId") .attributes(getConstraintsForField(JOB_EXECUTION_CONSTRAINTS, "processId")) .description("The id of the job client process on the Genie node") .type(JsonFieldType.NUMBER) .optional(), PayloadDocumentation .fieldWithPath("checkDelay") .attributes(getConstraintsForField(JOB_EXECUTION_CONSTRAINTS, "checkDelay")) .description("The amount of time in milliseconds between checks of the job status by Genie") .type(JsonFieldType.NUMBER) .optional(), PayloadDocumentation .fieldWithPath("timeout") .attributes(getConstraintsForField(JOB_EXECUTION_CONSTRAINTS, "timeout")) .description("The date (UTC ISO8601 with millis) when the job will be killed by Genie due to timeout") .type(JsonFieldType.STRING) .optional(), PayloadDocumentation .fieldWithPath("exitCode") .attributes(getConstraintsForField(JOB_EXECUTION_CONSTRAINTS, "exitCode")) .description("The job client process exit code after the job is done") .type(JsonFieldType.NUMBER) .optional(), PayloadDocumentation .fieldWithPath("memory") .attributes(getConstraintsForField(JOB_EXECUTION_CONSTRAINTS, "memory")) .description("The amount of memory (in MB) allocated to the job client") .type(JsonFieldType.NUMBER) .optional() ); }
Example #22
Source File: Snippets.java From genie with Apache License 2.0 | 5 votes |
static RequestFieldsSnippet setClusterCriteriaForCommandRequestPayload() { return PayloadDocumentation .requestFields( PayloadDocumentation .fieldWithPath("[]") .attributes(EMPTY_CONSTRAINTS) .description("A priority ordered list of criteria") .type(JsonFieldType.ARRAY) .optional() ) .andWithPrefix("[].", getCriterionFieldDescriptors()); }
Example #23
Source File: Snippets.java From genie with Apache License 2.0 | 5 votes |
static ResponseFieldsSnippet getClusterCriteriaForCommandResponsePayload() { return PayloadDocumentation .responseFields( PayloadDocumentation .fieldWithPath("[]") .attributes(EMPTY_CONSTRAINTS) .description("A priority ordered list of criteria") .type(JsonFieldType.ARRAY) .optional() ) .andWithPrefix("[].", getCriterionFieldDescriptors()); }
Example #24
Source File: GetGreetingDocTest.java From skeleton-ws-spring-boot with Apache License 2.0 | 5 votes |
/** * Generate API documentation for GET /api/greetings/{id}. * * @throws Exception Thrown if documentation generation failure occurs. */ @Test public void documentGetGreeting() throws Exception { // Generate API Documentation final MvcResult result = this.mockMvc .perform(RestDocumentationRequestBuilders .get("/api/greetings/{id}", "0").accept(MediaType.APPLICATION_JSON)) .andExpect(MockMvcResultMatchers.status().isOk()) .andDo(MockMvcRestDocumentation.document("get-greeting", RequestDocumentation.pathParameters( RequestDocumentation.parameterWithName("id").description("The greeting identifier.")), PayloadDocumentation.relaxedResponseFields( PayloadDocumentation.fieldWithPath("id") .description( "The identifier. Used to reference specific greetings in API requests.") .type(JsonFieldType.NUMBER), PayloadDocumentation.fieldWithPath("referenceId") .description("The supplementary identifier.").type(JsonFieldType.STRING), PayloadDocumentation.fieldWithPath("text").description("The text.") .type(JsonFieldType.STRING), PayloadDocumentation.fieldWithPath("version").description("The entity version.") .type(JsonFieldType.NUMBER), PayloadDocumentation.fieldWithPath("createdBy").description("The entity creator.") .type(JsonFieldType.STRING), PayloadDocumentation.fieldWithPath("createdAt").description("The creation timestamp.") .type(JsonFieldType.STRING), PayloadDocumentation.fieldWithPath("updatedBy").description("The last modifier.") .type(JsonFieldType.STRING).optional(), PayloadDocumentation.fieldWithPath("updatedAt") .description("The last modification timestamp.").type(JsonFieldType.STRING) .optional()))) .andReturn(); // Perform a simple, standard JUnit assertion to satisfy PMD rule Assert.assertEquals("failure - expected HTTP status 200", 200, result.getResponse().getStatus()); }
Example #25
Source File: Snippets.java From genie with Apache License 2.0 | 5 votes |
private static FieldDescriptor[] getSetupFieldDescriptors(final ConstraintDescriptions constraintDescriptions) { return ArrayUtils.addAll( getCommonFieldDescriptors(constraintDescriptions), PayloadDocumentation .fieldWithPath("setupFile") .attributes(getConstraintsForField(constraintDescriptions, "setupFile")) .description("A location for any setup that needs to be done when installing") .type(JsonFieldType.STRING) .optional() ); }
Example #26
Source File: Snippets.java From genie with Apache License 2.0 | 5 votes |
private static FieldDescriptor[] getCommonFieldDescriptors(final ConstraintDescriptions constraintDescriptions) { return ArrayUtils.addAll( getBaseFieldDescriptors(constraintDescriptions), PayloadDocumentation .fieldWithPath("name") .attributes(getConstraintsForField(constraintDescriptions, "name")) .description("The name") .type(JsonFieldType.STRING), PayloadDocumentation .fieldWithPath("user") .attributes(getConstraintsForField(constraintDescriptions, "user")) .description("The user") .type(JsonFieldType.STRING), PayloadDocumentation .fieldWithPath("version") .attributes(getConstraintsForField(constraintDescriptions, "version")) .description("The version") .type(JsonFieldType.STRING), PayloadDocumentation .fieldWithPath("description") .attributes(getConstraintsForField(constraintDescriptions, "description")) .description("Any description") .type(JsonFieldType.STRING) .optional(), PayloadDocumentation .subsectionWithPath("metadata") .attributes(getConstraintsForField(constraintDescriptions, "metadata")) .description("Any semi-structured metadata. Must be valid JSON") .type(JsonFieldType.OBJECT) .optional(), PayloadDocumentation .fieldWithPath("tags") .attributes(getConstraintsForField(constraintDescriptions, "tags")) .description("The tags") .type(JsonFieldType.ARRAY) .optional() ); }
Example #27
Source File: Snippets.java From genie with Apache License 2.0 | 5 votes |
private static FieldDescriptor[] getSearchResultFields() { return new FieldDescriptor[]{ PayloadDocumentation .subsectionWithPath("_links") .description("<<_hateoas,Links>> to other resources.") .attributes(EMPTY_CONSTRAINTS), PayloadDocumentation .fieldWithPath("page") .description("The result page information.") .attributes(EMPTY_CONSTRAINTS), PayloadDocumentation .fieldWithPath("page.size") .description("The number of elements in this page result.") .attributes(EMPTY_CONSTRAINTS), PayloadDocumentation .fieldWithPath("page.totalElements") .description("The total number of elements this search result could return.") .attributes(EMPTY_CONSTRAINTS), PayloadDocumentation .fieldWithPath("page.totalPages") .description("The total number of pages there could be at the current page size.") .attributes(EMPTY_CONSTRAINTS), PayloadDocumentation .fieldWithPath("page.number") .description("The current page number.") .attributes(EMPTY_CONSTRAINTS), }; }
Example #28
Source File: Snippets.java From genie with Apache License 2.0 | 5 votes |
private static FieldDescriptor[] getCriterionFieldDescriptors() { return new FieldDescriptor[]{ PayloadDocumentation .fieldWithPath("id") .attributes(getConstraintsForField(CRITERION_CONSTRAINTS, "id")) .description("The unique identifier a resource needs to have to match this criterion") .type(JsonFieldType.STRING) .optional(), PayloadDocumentation .fieldWithPath("name") .attributes(getConstraintsForField(CRITERION_CONSTRAINTS, "name")) .description("The name a resource needs to have to match this criterion") .type(JsonFieldType.STRING) .optional(), PayloadDocumentation .fieldWithPath("version") .attributes(getConstraintsForField(CRITERION_CONSTRAINTS, "version")) .description("The version a resource needs to have to match this criterion") .type(JsonFieldType.STRING) .optional(), PayloadDocumentation .fieldWithPath("status") .attributes(getConstraintsForField(CRITERION_CONSTRAINTS, "status")) .description("The status a resource needs to have to match this criterion") .type(JsonFieldType.STRING) .optional(), PayloadDocumentation .fieldWithPath("tags") .attributes(getConstraintsForField(CRITERION_CONSTRAINTS, "tags")) .description("The set of tags a resource needs to have to match this criterion") .type(JsonFieldType.ARRAY) .optional(), }; }
Example #29
Source File: ClusterRestControllerIntegrationTest.java From genie with Apache License 2.0 | 5 votes |
@Test void canUpdateConfigsForCluster() throws Exception { this.createConfigResource(new Cluster.Builder(NAME, USER, VERSION, ClusterStatus.UP).withId(ID).build(), null); final RestDocumentationFilter updateFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.CONTENT_TYPE_HEADER, // Request header Snippets.ID_PATH_PARAM, // Path parameters PayloadDocumentation.requestFields(Snippets.CONFIG_FIELDS) // Request fields ); this.canUpdateElementsForResource(CLUSTERS_API + "/{id}/configs", ID, updateFilter); }
Example #30
Source File: ClusterRestControllerIntegrationTest.java From genie with Apache License 2.0 | 5 votes |
@Test void canUpdateDependenciesForCluster() throws Exception { this.createConfigResource(new Cluster.Builder(NAME, USER, VERSION, ClusterStatus.UP).withId(ID).build(), null); final RestDocumentationFilter updateFilter = RestAssuredRestDocumentation.document( "{class-name}/{method-name}/{step}/", Snippets.CONTENT_TYPE_HEADER, // Request header Snippets.ID_PATH_PARAM, // Path parameters PayloadDocumentation.requestFields(Snippets.DEPENDENCIES_FIELDS) // Request fields ); this.canUpdateElementsForResource(CLUSTERS_API + "/{id}/configs", ID, updateFilter); }