本文整理汇总了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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例9: restDocumentation
import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
@Bean
public RestDocumentationResultHandler restDocumentation() {
return MockMvcRestDocumentation.document("{method-name}/{step}",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()));
}
示例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);
}
示例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;
}
示例14: documentPrettyPrint
import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
public RestDocumentationResultHandler documentPrettyPrint( String useCase, Snippet... snippets )
{
return document( useCase, preprocessRequest( prettyPrint() ), preprocessResponse( prettyPrint() ), snippets );
}
示例15: commonDocumentation
import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; //导入依赖的package包/类
protected RestDocumentationResultHandler commonDocumentation() {
return document("{class-name}/{method-name}",
preprocessRequest(), commonResponsePreprocessor());
}