当前位置: 首页>>代码示例>>Java>>正文


Java FieldDescriptor类代码示例

本文整理汇总了Java中org.springframework.restdocs.payload.FieldDescriptor的典型用法代码示例。如果您正苦于以下问题:Java FieldDescriptor类的具体用法?Java FieldDescriptor怎么用?Java FieldDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FieldDescriptor类属于org.springframework.restdocs.payload包,在下文中一共展示了FieldDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: roleFieldsForResponse

import org.springframework.restdocs.payload.FieldDescriptor; //导入依赖的package包/类
/**
 * Role fields used in responses.
 * An array field equivalent can be provided.
 *
 * @param isJsonArray if the fields are used in a JsonArray
 * @return FieldDescriptor
 */
private FieldDescriptor[] roleFieldsForResponse(boolean isJsonArray) {
    return isJsonArray ?
            new FieldDescriptor[]{
                    fieldWithPath("_embedded.roles[]").description("Roles list"),
                    fieldWithPath("_embedded.roles[].id").description("Role's id"),
                    fieldWithPath("_embedded.roles[].name").description("Role's name"),
                    fieldWithPath("_embedded.roles[].lastModifiedDate").type(Date.class).description("Role's date of last modification"),
                    fieldWithPath("_links").optional().ignored(),
                    fieldWithPath("page").optional().ignored()
            } :
            new FieldDescriptor[]{
                    fieldWithPath("id").description("Role's id"),
                    fieldWithPath("name").description("Role's name"),
                    fieldWithPath("lastModifiedDate").type(Date.class).description("Role's date of last modification"),
                    fieldWithPath("_links").optional().ignored(),
                    fieldWithPath("page").optional().ignored()
            };
}
 
开发者ID:bulktrade,项目名称:SMSC,代码行数:26,代码来源:RoleRestTest.java

示例2: roleFieldsForRequest

import org.springframework.restdocs.payload.FieldDescriptor; //导入依赖的package包/类
/**
 * Role fields used in requests.
 *
 * @return FieldDescriptor
 */
private FieldDescriptor[] roleFieldsForRequest(boolean isPatchRequest) {
    return isPatchRequest ?
            new FieldDescriptor[]{
                    fieldWithPath("name").optional().type(String.class).description("Role's name")
                            .attributes(key("mandatory").value(false)),
                    fieldWithPath("id").optional().ignored(),
                    fieldWithPath("lastModifiedDate").optional().ignored(),
                    fieldWithPath("_links").optional().ignored(),
                    fieldWithPath("page").optional().ignored()
            } :
            new FieldDescriptor[]{
                    fieldWithPath("name").type(String.class).description("Role's name")
                            .attributes(key("mandatory").value(true)),
                    fieldWithPath("id").optional().ignored(),
                    fieldWithPath("lastModifiedDate").optional().ignored(),
                    fieldWithPath("_links").optional().ignored(),
                    fieldWithPath("page").optional().ignored()
            };
}
 
开发者ID:bulktrade,项目名称:SMSC,代码行数:25,代码来源:RoleRestTest.java

示例3: toFieldDescriptor

import org.springframework.restdocs.payload.FieldDescriptor; //导入依赖的package包/类
private static FieldDescriptor toFieldDescriptor(LinkDescriptor linkDescriptor) {
    FieldDescriptor descriptor = fieldWithPath("_links." + linkDescriptor.getRel()) //change to subsectionWithPath on spring-rest-docs 1.2
            .description(linkDescriptor.getDescription())
            .type(JsonFieldType.OBJECT)
            .attributes(linkDescriptor.getAttributes().entrySet().stream()
                    .map(e -> new Attribute(e.getKey(), e.getValue()))
                    .toArray(Attribute[]::new));

    if (linkDescriptor.isOptional()) {
        descriptor = descriptor.optional();
    }
    if (linkDescriptor.isIgnored()) {
        descriptor = descriptor.ignored();
    }

    return descriptor;
}
 
开发者ID:ePages-de,项目名称:restdocs-raml,代码行数:18,代码来源:RamlResourceSnippetParameters.java

示例4: should_extract_response_field_descriptors

import org.springframework.restdocs.payload.FieldDescriptor; //导入依赖的package包/类
@Test
public void should_extract_response_field_descriptors() {
    // given
    ResponseFieldsSnippet snippet = responseFields(
        fieldWithPath("object.field").description("Is documented!"),
        fieldWithPath("object.anotherField").description("Is documented, too!")
    );

    // when
    List<FieldDescriptor> descriptors = extract(snippet);

    then(descriptors).hasSize(2);
    then(descriptors.stream().map(FieldDescriptor::getPath).collect(toList()))
            .containsExactly("object.field", "object.anotherField");
    then(descriptors.stream().map(AbstractDescriptor::getDescription).collect(toList()))
            .containsExactly("Is documented!", "Is documented, too!");
}
 
开发者ID:ePages-de,项目名称:restdocs-raml,代码行数:18,代码来源:DescriptorExtractorTest.java

示例5: post

import org.springframework.restdocs.payload.FieldDescriptor; //导入依赖的package包/类
@Test
public void post() throws Exception {

    ConstrainedFields fields = new ConstrainedFields(FactTransactionJson.class);
    List<FieldDescriptor> fieldDescriptors = Descriptors.getFactFieldDescriptors("facts[].",
            fields);
    fieldDescriptors.add(0, fields.withPath("facts").description(
            "Non empty list with the facts to commit in this transaction"));
    Snippet requestFieldSnippet = requestFields(//
            fieldDescriptors);

    FactTransactionJson factTransactionJson = objectMapper.readValue(this.getClass()
            .getResourceAsStream("TransactionJson.json"), FactTransactionJson.class);

    final Response response = target("/transactions").register(documentationConfiguration(
            this.documentation))
            .register(document("facts-transactions", preprocessRequest(
                    removeHeaders("User-Agent"), prettyPrint()), preprocessResponse(
                            prettyPrint()), requestFieldSnippet))
            .request()
            .post(Entity.entity(
                    factTransactionJson, MediaType.APPLICATION_JSON));
    assertThat(response.getStatus(), is(204));

}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:26,代码来源:TransactionDocumentation0Test.java

示例6: authorityFieldsForResponse

import org.springframework.restdocs.payload.FieldDescriptor; //导入依赖的package包/类
/**
 * Authority fields used in responses.
 * An array field equivalent can be provided.
 *
 * @param isJsonArray if the fields are used in a JsonArray
 * @return FieldDescriptor
 */
private FieldDescriptor[] authorityFieldsForResponse(boolean isJsonArray) {
    return isJsonArray ?
            new FieldDescriptor[]{
                    fieldWithPath("_embedded.authorities[]").description("Authorities list"),
                    fieldWithPath("_embedded.authorities[].id").description("Authority's id"),
                    fieldWithPath("_embedded.authorities[].name").description("Authority's name"),
                    fieldWithPath("_embedded.authorities[].lastModifiedDate").type(Date.class).description("Authority's date of last modification"),
                    fieldWithPath("_links").optional().ignored(),
                    fieldWithPath("page").optional().ignored()
            } :
            new FieldDescriptor[]{
                    fieldWithPath("id").description("Authority's id"),
                    fieldWithPath("name").description("Authority's name"),
                    fieldWithPath("lastModifiedDate").type(Date.class).description("Authority's date of last modification"),
                    fieldWithPath("_links").optional().ignored(),
                    fieldWithPath("page").optional().ignored()
            };
}
 
开发者ID:bulktrade,项目名称:SMSC,代码行数:26,代码来源:AuthorityRestTest.java

示例7: authorityFieldsForRequest

import org.springframework.restdocs.payload.FieldDescriptor; //导入依赖的package包/类
/**
 * Authority fields used in requests.
 *
 * @return FieldDescriptor
 */
private FieldDescriptor[] authorityFieldsForRequest(boolean isPatchRequest) {
    return isPatchRequest ?
            new FieldDescriptor[]{
                    fieldWithPath("name").optional().type(String.class).description("Authority's name")
                            .attributes(key("mandatory").value(false)),
                    fieldWithPath("id").optional().ignored(),
                    fieldWithPath("lastModifiedDate").optional().ignored(),
                    fieldWithPath("_links").optional().ignored(),
                    fieldWithPath("page").optional().ignored()
            } :
            new FieldDescriptor[]{
                    fieldWithPath("name").type(String.class).description("Authority's name")
                            .attributes(key("mandatory").value(true)),
                    fieldWithPath("id").optional().ignored(),
                    fieldWithPath("lastModifiedDate").optional().ignored(),
                    fieldWithPath("_links").optional().ignored(),
                    fieldWithPath("page").optional().ignored()
            };
}
 
开发者ID:bulktrade,项目名称:SMSC,代码行数:25,代码来源:AuthorityRestTest.java

示例8: groupFieldsForResponse

import org.springframework.restdocs.payload.FieldDescriptor; //导入依赖的package包/类
/**
 * Group fields used in responses.
 * An array field equivalent can be provided.
 *
 * @param isJsonArray if the fields are used in a JsonArray
 * @return FieldDescriptor
 */
private FieldDescriptor[] groupFieldsForResponse(boolean isJsonArray) {
    return isJsonArray ?
            new FieldDescriptor[]{
                    fieldWithPath("_embedded.groups[]").description("Groups list"),
                    fieldWithPath("_embedded.groups[].id").description("Group's id"),
                    fieldWithPath("_embedded.groups[].name").description("Group's name"),
                    fieldWithPath("_embedded.groups[].lastModifiedDate").type(Date.class).description("Group's date of last modification"),
                    fieldWithPath("_links").optional().ignored(),
                    fieldWithPath("page").optional().ignored()
            } :
            new FieldDescriptor[]{
                    fieldWithPath("id").description("Group's id"),
                    fieldWithPath("name").description("Group's name"),
                    fieldWithPath("lastModifiedDate").type(Date.class).description("Group's date of last modification"),
                    fieldWithPath("_links").optional().ignored(),
                    fieldWithPath("page").optional().ignored()
            };
}
 
开发者ID:bulktrade,项目名称:SMSC,代码行数:26,代码来源:GroupRestTest.java

示例9: groupFieldsForRequest

import org.springframework.restdocs.payload.FieldDescriptor; //导入依赖的package包/类
/**
 * Group fields used in requests.
 *
 * @return FieldDescriptor
 */
private FieldDescriptor[] groupFieldsForRequest(boolean isPatchRequest) {
    return isPatchRequest ?
            new FieldDescriptor[]{
                    fieldWithPath("name").optional().type(String.class).description("Group's name")
                            .attributes(key("mandatory").value(false)),
                    fieldWithPath("id").optional().ignored(),
                    fieldWithPath("lastModifiedDate").optional().ignored(),
                    fieldWithPath("_links").optional().ignored(),
                    fieldWithPath("page").optional().ignored()
            } :
            new FieldDescriptor[]{
                    fieldWithPath("name").type(String.class).description("Group's name")
                            .attributes(key("mandatory").value(true)),
                    fieldWithPath("id").optional().ignored(),
                    fieldWithPath("lastModifiedDate").optional().ignored(),
                    fieldWithPath("_links").optional().ignored(),
                    fieldWithPath("page").optional().ignored()
            };
}
 
开发者ID:bulktrade,项目名称:SMSC,代码行数:25,代码来源:GroupRestTest.java

示例10: dashboardBoxTypeFieldsForResponse

import org.springframework.restdocs.payload.FieldDescriptor; //导入依赖的package包/类
/**
 * DashboardBoxType fields used in responses.
 * An array field equivalent can be provided.
 *
 * @param isJsonArray if the fields are used in a JsonArray
 * @return FieldDescriptor
 */
private FieldDescriptor[] dashboardBoxTypeFieldsForResponse(boolean isJsonArray) {
    return isJsonArray ?
            new FieldDescriptor[]{
                    fieldWithPath("_embedded.dashboard-box-types[]").description("DashboardBoxType list"),
                    fieldWithPath("_embedded.dashboard-box-types[].id").description("DashboardBoxType's id"),
                    fieldWithPath("_embedded.dashboard-box-types[].name").description("DashboardBoxType's name"),
                    fieldWithPath("_embedded.dashboard-box-types[].type").description("DashboardBoxType's type"),
                    fieldWithPath("_embedded.dashboard-box-types[].kind").description("DashboardBoxType's kind"),
                    fieldWithPath("_embedded.dashboard-box-types[].lastModifiedDate").type(Date.class)
                            .description("DashboardBoxType's date of last modification"),
                    fieldWithPath("_links").optional().ignored(),
                    fieldWithPath("page").optional().ignored()
            } :
            new FieldDescriptor[]{
                    fieldWithPath("id").description("DashboardBoxType's id"),
                    fieldWithPath("name").description("DashboardBoxType's name"),
                    fieldWithPath("type").description("DashboardBoxType's type"),
                    fieldWithPath("kind").description("DashboardBoxType's kind"),
                    fieldWithPath("lastModifiedDate").type(Date.class)
                            .description("DashboardBoxType's date of last modification"),
                    fieldWithPath("_links").optional().ignored(),
                    fieldWithPath("page").optional().ignored()
            };
}
 
开发者ID:bulktrade,项目名称:SMSC,代码行数:32,代码来源:DashboardBoxTypeRestTest.java

示例11: dashboardFieldsForResponse

import org.springframework.restdocs.payload.FieldDescriptor; //导入依赖的package包/类
/**
 * Dashboard fields used in responses.
 * An array field equivalent can be provided
 *
 * @param isJsonArray if the fields are used in a JsonArray
 * @return FieldDescriptor
 */
private FieldDescriptor[] dashboardFieldsForResponse(boolean isJsonArray) {
    return isJsonArray ?
            new FieldDescriptor[]{
                    fieldWithPath("_embedded.dashboards[]").description("Dashboard list"),
                    fieldWithPath("_embedded.dashboards[].id").description("Dashboard's id"),
                    fieldWithPath("_embedded.dashboards[].name").description("Dashboard's name"),
                    fieldWithPath("_embedded.dashboards[].icon").description("Dashboard's icon"),
                    fieldWithPath("_embedded.dashboards[].lastModifiedDate").type(Date.class)
                            .description("AdminUser's date of last modification"),
                    fieldWithPath("_links").optional().ignored(),
                    fieldWithPath("page").optional().ignored()

            } :
            new FieldDescriptor[]{
                    fieldWithPath("id").description("Dashboard's id"),
                    fieldWithPath("name").description("Dashboard's name"),
                    fieldWithPath("icon").description("Dashboard's icon"),
                    fieldWithPath("lastModifiedDate").type(Date.class)
                            .description("Dashboard's date of last modification"),
                    fieldWithPath("_links").optional().ignored(),
                    fieldWithPath("page").optional().ignored()
            };
}
 
开发者ID:bulktrade,项目名称:SMSC,代码行数:31,代码来源:DashboardRestTest.java

示例12: testLoginAdmin

import org.springframework.restdocs.payload.FieldDescriptor; //导入依赖的package包/类
@Test
public void testLoginAdmin() throws Exception {
    FieldDescriptor[] JWTAuthenticationRequestFields = new FieldDescriptor[]{
            fieldWithPath("username").description("User's username")
                    .attributes(key("mandatory").value(true)),
            fieldWithPath("password").description("User's password")
            .attributes(key("mandatory").value(true))
    };

    FieldDescriptor[] JWTAuthenticationResponseFields = new FieldDescriptor[]{
            fieldWithPath("token").description("Access token"),
            fieldWithPath("refreshToken").description("Refresh token")
    };

    mockMvc.perform(post("/rest/auth/token")
            .contentType(MediaType.APPLICATION_JSON)
            .content(json(new JWTAuthenticationRequest("admin", "admin"))))
            .andExpect(status().isOk())
            .andDo(document("getTokens",
                    requestFields(JWTAuthenticationRequestFields),
                    responseFields(JWTAuthenticationResponseFields)));
}
 
开发者ID:bulktrade,项目名称:SMSC,代码行数:23,代码来源:JWTAuthenticationTest.java

示例13: testRefreshToken

import org.springframework.restdocs.payload.FieldDescriptor; //导入依赖的package包/类
@Test
public void testRefreshToken() throws Exception {
    FieldDescriptor[] JWTRefreshTokenRequestFields = new FieldDescriptor[]{
            fieldWithPath("refreshToken").description("Refresh token")
                    .attributes(key("mandatory").value(true))
    };

    FieldDescriptor[] JWTRefreshTokenResponseFields = new FieldDescriptor[]{
            fieldWithPath("refreshedToken").description("New access token")
    };

    UserDetails adminDetails = createJWTUser();
    String refreshToken = jwtTokenGenerationService.generateRefreshToken(adminDetails);

    mockMvc.perform(put("/rest/auth/token")
            .contentType(MediaType.APPLICATION_JSON)
            .content(json(new JWTRefreshTokenRequest(refreshToken))))
            .andExpect(status().isOk())
            .andDo(document("refreshToken",
                    requestFields(JWTRefreshTokenRequestFields),
                    responseFields(JWTRefreshTokenResponseFields)));
}
 
开发者ID:bulktrade,项目名称:SMSC,代码行数:23,代码来源:JWTAuthenticationTest.java

示例14: testFilterLike

import org.springframework.restdocs.payload.FieldDescriptor; //导入依赖的package包/类
@Test
public void testFilterLike() throws Exception
{
    MockHttpSession session = getSession( "F_DATAELEMENT_PUBLIC_ADD" );
    DataElement de = createDataElement( 'A' );
    manager.save( de );

    List<FieldDescriptor> fieldDescriptors = new ArrayList<>();
    fieldDescriptors.addAll( ResponseDocumentation.pager() );
    fieldDescriptors.add( fieldWithPath( "dataElements" ).description( "Data elements" ) );

    mvc.perform( get( "/dataElements?filter=name:like:DataElementA" )
        .session( session )
        .contentType( TestUtils.APPLICATION_JSON_UTF8 ) )
        .andExpect( jsonPath( "$.pager.total", new GreaterThan<Integer>( 0 ) ) )
        .andDo( documentPrettyPrint( "data-elements/filter",
            responseFields( fieldDescriptors.toArray( new FieldDescriptor[fieldDescriptors.size()] ) ) ) );
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:19,代码来源:DataElementControllerDocumentation.java

示例15: testFieldsFilterOk

import org.springframework.restdocs.payload.FieldDescriptor; //导入依赖的package包/类
@Test
public void testFieldsFilterOk() throws Exception
{
    MockHttpSession session = getSession( "F_DATAELEMENT_PUBLIC_ADD" );
    DataElement de = createDataElement( 'A' );
    manager.save( de );

    List<FieldDescriptor> fieldDescriptors = new ArrayList<>();
    fieldDescriptors.addAll( ResponseDocumentation.pager() );
    fieldDescriptors.add( fieldWithPath( "dataElements" ).description( "Data elements" ) );

    mvc.perform( get( "/dataElements?filter=name:eq:DataElementA&fields=id,name,valueType" )
        .session( session )
        .contentType( TestUtils.APPLICATION_JSON_UTF8 ) )
        .andExpect( jsonPath( "$.dataElements[*].id" ).exists() )
        .andExpect( jsonPath( "$.dataElements[*].name" ).exists() )
        .andExpect( jsonPath( "$.dataElements[*].valueType" ).exists() )
        .andExpect( jsonPath( "$.dataElements[*].categoryCombo" ).doesNotExist() )
        .andDo( documentPrettyPrint( "data-elements/fields",
            responseFields( fieldDescriptors.toArray( new FieldDescriptor[fieldDescriptors.size()] ) ) ) );
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:22,代码来源:DataElementControllerDocumentation.java


注:本文中的org.springframework.restdocs.payload.FieldDescriptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。