org.springframework.test.web.servlet.ResultHandler Java Examples

The following examples show how to use org.springframework.test.web.servlet.ResultHandler. 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: GetCriticalFilesControllerTest.java    From coderadar with MIT License 6 votes vote down vote up
private ResultHandler documentGetFilesWithContributors() {
  ConstrainedFields<GetFilesWithContributorsCommand> fields =
      fields(GetFilesWithContributorsCommand.class);

  return document(
      "metrics/criticalFiles/numberOfContributors",
      requestFields(
          fields
              .withPath("commitHash")
              .description(
                  "Only search for critical files in the file tree of the given commit."),
          fields
              .withPath("numberOfContributors")
              .description(
                  "The amount of contributors for which a file is considered critical.")));
}
 
Example #2
Source File: GetCriticalFilesControllerTest.java    From coderadar with MIT License 6 votes vote down vote up
private ResultHandler documentGetFrequentlyChangedFiles() {
  ConstrainedFields<GetFrequentlyChangedFilesCommand> fields =
      fields(GetFrequentlyChangedFilesCommand.class);

  return document(
      "metrics/criticalFiles/modificationFrequency",
      requestFields(
          fields
              .withPath("commitHash")
              .description(
                  "Only search for critical files in the file tree of the given commit."),
          fields.withPath("startDate").description("Start date of the time period."),
          fields
              .withPath("frequency")
              .description(
                  "How often a file needs to be changed in the time period to be declared as critical.")));
}
 
Example #3
Source File: ChangePasswordControllerIntegrationTest.java    From coderadar with MIT License 5 votes vote down vote up
private ResultHandler documentPasswordChange() {
  ConstrainedFields fields = fields(ChangePasswordCommand.class);
  return document(
      "user/password/change",
      requestFields(
          fields.withPath("refreshToken").description("the current refresh token of the user"),
          fields
              .withCustomPath("newPassword")
              .description("The password of the user as plaintext")));
}
 
Example #4
Source File: MockMvcResultHandlers.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void handle(MvcResult result) throws Exception {
	if (logger.isDebugEnabled()) {
		StringWriter stringWriter = new StringWriter();
		ResultHandler printingResultHandler =
				new PrintWriterPrintingResultHandler(new PrintWriter(stringWriter));
		printingResultHandler.handle(result);
		logger.debug("MvcResult details:\n" + stringWriter);
	}
}
 
Example #5
Source File: CreateProjectControllerIntegrationTest.java    From coderadar with MIT License 5 votes vote down vote up
private ResultHandler documentCreateProject() {
  ConstrainedFields<CreateProjectCommand> fields = fields(CreateProjectCommand.class);
  return document(
      "projects/create",
      requestFields(
          fields.withPath("name").description("The name of the project to be analyzed."),
          fields
              .withPath("vcsUrl")
              .description(
                  "The URL to the version control repository where the project's source files are kept."),
          fields
              .withPath("vcsUsername")
              .description(
                  "The user name used to access the version control system of your project. Needs read access only. Don't provide this field if anonymous access is possible."),
          fields
              .withPath("vcsPassword")
              .description(
                  "The password of the version control system user. This password has to be stored in plain text for coderadar to be usable, so make sure to provide a user with only reading permissions. Don't provide this field if anonymous access is possible."),
          fields
              .withPath("vcsOnline")
              .description(
                  "Set to false if you want no interaction with a remote repository for this project. True by default."),
          fields
              .withPath("startDate")
              .type("Date")
              .description(
                  "The start date of the range of commits which should be analyzed by coderadar. Leave empty to start at the first commit.")));
}
 
Example #6
Source File: MockMvcResultHandlers.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void handle(MvcResult result) throws Exception {
	if (logger.isDebugEnabled()) {
		StringWriter stringWriter = new StringWriter();
		ResultHandler printingResultHandler =
				new PrintWriterPrintingResultHandler(new PrintWriter(stringWriter));
		printingResultHandler.handle(result);
		logger.debug("MvcResult details:\n" + stringWriter);
	}
}
 
Example #7
Source File: ListContributorsControllerIntegrationTest.java    From coderadar with MIT License 5 votes vote down vote up
private ResultHandler documentListContributors() {
  return document(
      "contributors/list",
      responseFields(
          fieldWithPath("[]").description("Array of all contributors in this project"),
          fieldWithPath("[].id").description("The id of the contributor"),
          fieldWithPath("[].displayName").description("Display name of the contributor"),
          fieldWithPath("[].names")
              .description("Set of names that the contributor has used in git commits"),
          fieldWithPath("[].emailAddresses")
              .description("Set of email addresses of the contributor")));
}
 
Example #8
Source File: ListContributorsControllerIntegrationTest.java    From coderadar with MIT License 5 votes vote down vote up
private ResultHandler documentListContributorsForFile() {
  ConstrainedFields<GetContributorsForPathCommand> fields =
      fields(GetContributorsForPathCommand.class);

  return document(
      "contributors/list/path/file",
      requestFields(
          fields
              .withPath("path")
              .description("The path for. Either it is a filepath or a directory."),
          fields
              .withPath("commitHash")
              .description("Get the critical file only if it belongs to this commit tree.")));
}
 
Example #9
Source File: ListContributorsControllerIntegrationTest.java    From coderadar with MIT License 5 votes vote down vote up
private ResultHandler documentListContributorsForDirectory() {
  ConstrainedFields<GetContributorsForPathCommand> fields =
      fields(GetContributorsForPathCommand.class);

  return document(
      "contributors/list/path/directory",
      requestFields(
          fields
              .withPath("path")
              .description("The path for. Either it is a filepath or a directory."),
          fields
              .withPath("commitHash")
              .description("Get the critical file only if it belongs to this commit tree.")));
}
 
Example #10
Source File: UpdateContributorControllerIntegrationTest.java    From coderadar with MIT License 5 votes vote down vote up
private ResultHandler documentUpdateContributor() {
  ConstrainedFields<UpdateContributorCommand> fields = fields(UpdateContributorCommand.class);
  return document(
      "contributors/update",
      requestFields(
          fields
              .withPath("displayName")
              .description("The new display name of the contributor.")));
}
 
Example #11
Source File: GetContributorControllerIntegrationTest.java    From coderadar with MIT License 5 votes vote down vote up
private ResultHandler documentContributor() {
  return document(
      "contributors/get",
      responseFields(
          fieldWithPath("id").description("The id of the contributor."),
          fieldWithPath("displayName").description("The display name of the contributor."),
          fieldWithPath("names")
              .description(
                  "Different names that appear in different commits, but all belong to this contributor."),
          fieldWithPath("emailAddresses")
              .description("Different email addresses of the contributor.")));
}
 
Example #12
Source File: MockMvcResultHandlers.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void handle(MvcResult result) throws Exception {
	if (logger.isDebugEnabled()) {
		StringWriter stringWriter = new StringWriter();
		ResultHandler printingResultHandler =
				new PrintWriterPrintingResultHandler(new PrintWriter(stringWriter));
		printingResultHandler.handle(result);
		logger.debug("MvcResult details:\n" + stringWriter);
	}
}
 
Example #13
Source File: CreateFilePatternControllerIntegrationTest.java    From coderadar with MIT License 5 votes vote down vote up
private ResultHandler documentCreateFilePattern() {
  ConstrainedFields fields = fields(CreateFilePatternCommand.class);
  return document(
      "filepatterns/create-update",
      requestFields(
          fields.withPath("pattern").description("The pattern string of this FilePattern."),
          fields
              .withPath("inclusionType")
              .description("Whether the pattern is included or excluded.")));
}
 
Example #14
Source File: RegisterUserControllerIntegrationTest.java    From coderadar with MIT License 5 votes vote down vote up
private ResultHandler documentRegistration() {
  ConstrainedFields fields = fields(RegisterUserCommand.class);
  return document(
      "user/registration",
      requestFields(
          fields.withPath("username").description("The name of the user to be registered."),
          fields
              .withCustomPath("password")
              .description("The password of the user as plaintext")));
}
 
Example #15
Source File: RefreshTokenControllerIntegrationTest.java    From coderadar with MIT License 5 votes vote down vote up
private ResultHandler documentRefresh() {
  ConstrainedFields fields = fields(RefreshTokenCommand.class);
  return document(
      "user/refresh",
      requestFields(
          fields.withPath("accessToken").description("The expired access token"),
          fields.withPath("refreshToken").description("The valid refresh token")));
}
 
Example #16
Source File: LoginUserControllerIntegrationTest.java    From coderadar with MIT License 5 votes vote down vote up
private ResultHandler documentLogin() {
  ConstrainedFields fields = fields(LoginUserCommand.class);
  return document(
      "user/auth",
      requestFields(
          fields.withPath("username").description("The name of the user to be logged in."),
          fields.withPath("password").description("The password of the user as plaintext")));
}
 
Example #17
Source File: MergeContributorsControllerIntegrationTest.java    From coderadar with MIT License 5 votes vote down vote up
private ResultHandler documentMergeContributors() {
  ConstrainedFields<MergeContributorsCommand> fields = fields(MergeContributorsCommand.class);
  return document(
      "contributors/merge",
      requestFields(
          fields
              .withPath("contributorIds")
              .description(
                  "The IDs of the contributors to merge. "
                      + "The ID of the first contributor in the list will be the ID of the merged contributor. "
                      + "All other IDs become invalid."),
          fields
              .withPath("displayName")
              .description("The new display name of the merged contributor.")));
}
 
Example #18
Source File: JacksonResultHandlers.java    From spring-auto-restdocs with Apache License 2.0 4 votes vote down vote up
public static ResultHandler prepareJackson(ObjectMapper objectMapper,
        SnippetTranslationResolver translationResolver) {
    return new JacksonPreparingResultHandler(objectMapper, new TypeMapping(),
            translationResolver,
            new DynamicResourceBundleConstraintDescriptionResolver());
}
 
Example #19
Source File: JacksonResultHandlers.java    From spring-auto-restdocs with Apache License 2.0 4 votes vote down vote up
public static ResultHandler prepareJackson(ObjectMapper objectMapper, TypeMapping typeMapping) {
    return new JacksonPreparingResultHandler(objectMapper, typeMapping,
            SnippetTranslationManager.getDefaultResolver(),
            new DynamicResourceBundleConstraintDescriptionResolver());
}
 
Example #20
Source File: JacksonResultHandlers.java    From spring-auto-restdocs with Apache License 2.0 4 votes vote down vote up
public static ResultHandler prepareJackson(ObjectMapper objectMapper,
        ConstraintDescriptionResolver constraintDescriptionResolver) {
    return new JacksonPreparingResultHandler(objectMapper, new TypeMapping(),
            SnippetTranslationManager.getDefaultResolver(), constraintDescriptionResolver);
}
 
Example #21
Source File: JacksonResultHandlers.java    From spring-auto-restdocs with Apache License 2.0 4 votes vote down vote up
public static ResultHandler prepareJackson(ObjectMapper objectMapper, TypeMapping typeMapping,
        SnippetTranslationResolver translationResolver) {
    return new JacksonPreparingResultHandler(objectMapper, typeMapping,
            translationResolver, new DynamicResourceBundleConstraintDescriptionResolver());
}
 
Example #22
Source File: MockMvcResultPrinter.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Print {@link MvcResult} details to logger.
 */
public static ResultHandler print() {
    return new ConsolePrintingResultHandler();
}
 
Example #23
Source File: JacksonResultHandlers.java    From spring-auto-restdocs with Apache License 2.0 4 votes vote down vote up
public static ResultHandler prepareJackson(ObjectMapper objectMapper,
        SnippetTranslationResolver translationResolver,
        ConstraintDescriptionResolver constraintDescriptionResolver) {
    return new JacksonPreparingResultHandler(objectMapper, new TypeMapping(),
            translationResolver, constraintDescriptionResolver);
}
 
Example #24
Source File: JacksonResultHandlers.java    From spring-auto-restdocs with Apache License 2.0 4 votes vote down vote up
public static ResultHandler prepareJackson(ObjectMapper objectMapper, TypeMapping typeMapping,
        ConstraintDescriptionResolver constraintDescriptionResolver) {
    return new JacksonPreparingResultHandler(objectMapper, typeMapping,
            SnippetTranslationManager.getDefaultResolver(), constraintDescriptionResolver);
}
 
Example #25
Source File: JacksonResultHandlers.java    From spring-auto-restdocs with Apache License 2.0 4 votes vote down vote up
public static ResultHandler prepareJackson(ObjectMapper objectMapper, TypeMapping typeMapping,
        SnippetTranslationResolver translationResolver,
        ConstraintDescriptionResolver constraintDescriptionResolver) {
    return new JacksonPreparingResultHandler(objectMapper, typeMapping,
            translationResolver, constraintDescriptionResolver);
}
 
Example #26
Source File: TranslationHandlers.java    From spring-auto-restdocs with Apache License 2.0 4 votes vote down vote up
public static ResultHandler defaultTranslation() {
    return new TranslationPreparingResultHandler(SnippetTranslationManager.getDefaultResolver());
}
 
Example #27
Source File: TranslationHandlers.java    From spring-auto-restdocs with Apache License 2.0 4 votes vote down vote up
public static ResultHandler translation(SnippetTranslationResolver translationResolver) {
    return new TranslationPreparingResultHandler(translationResolver);
}
 
Example #28
Source File: AbstractMockMvcBuilder.java    From spring-analysis-note with MIT License 4 votes vote down vote up
public final <T extends B> T alwaysDo(ResultHandler resultHandler) {
	this.globalResultHandlers.add(resultHandler);
	return self();
}
 
Example #29
Source File: YcMockMvcResultHandlers.java    From yes-cart with Apache License 2.0 4 votes vote down vote up
/**
 * Print {@link org.springframework.test.web.servlet.MvcResult} details to the "standard" output stream.
 */
public static ResultHandler print() {
    return new ConsolePrintingResultHandler();
}
 
Example #30
Source File: BaseDocumentation.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
private ToggleableResultHandler(ResultHandler delegate) {
	this.delegate = delegate;
}