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


Java RestDocumentationResultHandler类代码示例

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


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

示例1: setUp

import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
@Before
public void setUp() {
    this.deviceCertificateServiceMock = mock(DeviceCertificateService.class);
    this.demoServiceMock = mock(DemoService.class);

    DeviceCertificateCtrl sut = new DeviceCertificateCtrl(deviceCertificateServiceMock, demoServiceMock);

    RestDocumentationResultHandler document = document("{method-name}",
            preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()));

    ApplicationResolver applicationResolver = (appId, apiKey) ->
            Mono.just(new ApplicationEntity() {{
                setAppId("demo");
                setApiKey("demodemodemo");
            }});

    this.mvc = MockMvcBuilders.standaloneSetup(sut)
            .setCustomArgumentResolvers(new ApplicationAuthenticationArgumentResolver(applicationResolver))
            .apply(documentationConfiguration(this.restDocumentation))
            .alwaysDo(document)
            .alwaysDo(print())
            .build();
}
 
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:24,代码来源:DeviceCertificateCtrlExampleRequests.java

示例2: document

import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
public static RestDocumentationResultHandler document(String identifier,
                                                      String description,
                                                      boolean privateResource,
                                                      OperationRequestPreprocessor requestPreprocessor,
                                                      OperationResponsePreprocessor responsePreprocessor,
                                                      Function<List<Snippet>, List<Snippet>> snippetFilter,
                                                      Snippet... snippets) {

    Snippet[] enhancedSnippets = enhanceSnippetsWithRaml(description, privateResource, snippetFilter, snippets);

    if (requestPreprocessor != null && responsePreprocessor != null) {
        return MockMvcRestDocumentation.document(identifier, requestPreprocessor, responsePreprocessor, enhancedSnippets);
    } else if (requestPreprocessor != null) {
        return MockMvcRestDocumentation.document(identifier, requestPreprocessor, enhancedSnippets);
    } else if (responsePreprocessor != null) {
        return MockMvcRestDocumentation.document(identifier, responsePreprocessor, enhancedSnippets);
    }

    return MockMvcRestDocumentation.document(identifier, enhancedSnippets);
}
 
开发者ID:ePages-de,项目名称:restdocs-raml,代码行数:21,代码来源:RamlDocumentation.java

示例3: insertUser

import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
private void insertUser(User user) throws Exception {
    
    RestDocumentationResultHandler document = documentPrettyPrintReqResp("insertUser");
    
    document.document(
            requestFields(userFields(false)),
            responseFields(userFields(false))
    );
    
    this.mockMvc.perform(post("/api/v1/users")
            .accept(MediaType.APPLICATION_JSON)
            .content(objectMapper.writeValueAsString(user))
            .contentType(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andDo(document);
}
 
开发者ID:ssouris,项目名称:spring-tutorials,代码行数:17,代码来源:UserControllerDocumentation.java

示例4: getUser

import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
private void getUser(UUID userId) throws Exception {
    
    RestDocumentationResultHandler document = documentPrettyPrintReqResp("getUser");
    
    document.document(
            pathParameters(userPathParams()),
            responseFields(userFields(false))
    );
    
    this.mockMvc.perform(get("/api/v1/users/{userId}", userId)
            .contentType(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andExpect(jsonPath("userId").isNotEmpty())
            .andExpect(jsonPath("firstName").isNotEmpty())
            .andExpect(jsonPath("lastName").isNotEmpty())
            .andExpect(jsonPath("username").isNotEmpty())
            .andDo(document);
}
 
开发者ID:ssouris,项目名称:spring-tutorials,代码行数:19,代码来源:UserControllerDocumentation.java

示例5: getUsers

import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
private void getUsers() throws Exception {
    
    RestDocumentationResultHandler document = documentPrettyPrintReqResp("getUsers");
    
    document.document(
            pathParameters(
                    parameterWithName("page").description("Page of results"),
                    parameterWithName("size").description("Size of results")
            ),
            responseFields(userFields(true))
    );
    
    this.mockMvc.perform(get("/api/v1/users?page={page}&size={size}", 0, 10)
            .contentType(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andExpect(jsonPath("$").isArray())
            .andExpect(jsonPath("[*].userId").isNotEmpty())
            .andExpect(jsonPath("[*].firstName").isNotEmpty())
            .andExpect(jsonPath("[*].lastName").isNotEmpty())
            .andExpect(jsonPath("[*].username").isNotEmpty())
            .andDo(document);
}
 
开发者ID:ssouris,项目名称:spring-tutorials,代码行数:23,代码来源:UserControllerDocumentation.java

示例6: updateUser

import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
private void updateUser(User user) throws Exception {
    
    RestDocumentationResultHandler document = 
            documentPrettyPrintReqResp("updateUser");
    
    document.document(
            pathParameters(userPathParams()),
            requestFields(userFields(false)),
            responseFields(userFields(false))
    );
    this.mockMvc.perform(
            put("/api/v1/users/{userId}", user.getUserId())
            .accept(MediaType.APPLICATION_JSON)
            .content(objectMapper.writeValueAsString(user))
            .contentType(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andDo(document);
}
 
开发者ID:ssouris,项目名称:spring-tutorials,代码行数:19,代码来源:UserControllerDocumentation.java

示例7: restDocumentationConfigurer

import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
@Bean
@ConfigurationProperties("spring.test.restdocs")
public RestDocsMockMvcBuilderCustomizer restDocumentationConfigurer(
		MockMvcRestDocumentationConfigurer configurer,
		ObjectProvider<RestDocumentationResultHandler> resultHandler) {
	return new RestDocsMockMvcBuilderCustomizer(configurer,
			resultHandler.getIfAvailable());
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:RestDocsAutoConfiguration.java

示例8: deleteUser

import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
private void deleteUser(UUID userId) throws Exception {
    
    RestDocumentationResultHandler document = 
            documentPrettyPrintReqResp("deleteUser");
            
    document.document(
            pathParameters(userPathParams()),
            responseFields(userFields(false))
    );
    
    this.mockMvc.perform(delete("/api/v1/users/{userId}", userId)
            .contentType(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andDo(document);
}
 
开发者ID:ssouris,项目名称:spring-tutorials,代码行数:16,代码来源:UserControllerDocumentation.java

示例9: restDocumentation

import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
@Bean
public RestDocumentationResultHandler restDocumentation() {
    return MockMvcRestDocumentation.document("{method-name}/{step}",
                                             preprocessRequest(prettyPrint()),
                                             preprocessResponse(prettyPrint()));
}
 
开发者ID:florind,项目名称:inception-serving-sb,代码行数:7,代码来源:DocumentationConfig.java

示例10: document

import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
/**
 * Wraps the static document() method of RestDocs and configures it to pretty print request and
 * response JSON structures.
 */
protected RestDocumentationResultHandler document(String identifier, Snippet... snippets) {
  return MockMvcRestDocumentation.document(
      identifier, preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()), snippets);
}
 
开发者ID:reflectoring,项目名称:infiniboard,代码行数:9,代码来源:ControllerTestTemplate.java

示例11: RestDocsMockMvcBuilderCustomizer

import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
RestDocsMockMvcBuilderCustomizer(MockMvcRestDocumentationConfigurer delegate,
		RestDocumentationResultHandler resultHandler) {
	this.delegate = delegate;
	this.resultHandler = resultHandler;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:6,代码来源:RestDocsMockMvcBuilderCustomizer.java

示例12: restDocumentation

import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
@Bean
public RestDocumentationResultHandler restDocumentation() {
	return MockMvcRestDocumentation.document("{method-name}");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:5,代码来源:RestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java

示例13: docHandler

import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
protected RestDocumentationResultHandler docHandler() {
	return this.documentationHandler;
}
 
开发者ID:JanLoebel,项目名称:uaa-service,代码行数:4,代码来源:AbstractDocumentation.java

示例14: documentPrettyPrint

import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
public RestDocumentationResultHandler documentPrettyPrint( String useCase, Snippet... snippets )
{
    return document( useCase, preprocessRequest( prettyPrint() ), preprocessResponse( prettyPrint() ), snippets );
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:5,代码来源:DhisWebSpringTest.java

示例15: commonDocumentation

import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
protected RestDocumentationResultHandler commonDocumentation() {
    return document("{class-name}/{method-name}",
            preprocessRequest(), commonResponsePreprocessor());
}
 
开发者ID:ScaCap,项目名称:spring-auto-restdocs,代码行数:5,代码来源:MockMvcBase.java


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