org.springframework.restdocs.templates.TemplateFormats Java Examples

The following examples show how to use org.springframework.restdocs.templates.TemplateFormats. 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: MethodAndPathSnippetTest.java    From spring-auto-restdocs with Apache License 2.0 6 votes vote down vote up
@Test
public void simpleRequest() throws Exception {
    HandlerMethod handlerMethod = new HandlerMethod(new TestResource(), "testMethod");

    new MethodAndPathSnippet().document(operationBuilder
            .attribute(HandlerMethod.class.getName(), handlerMethod)
            .attribute(REQUEST_PATTERN, "/test")
            .request("http://localhost/test")
            .method("POST")
            .build());

    if (TemplateFormats.asciidoctor().equals(this.templateFormat)) {
        assertThat(this.generatedSnippets.snippet(AUTO_METHOD_PATH)).isEqualTo("`+POST /test+`");
    } else {
        assertThat(this.generatedSnippets.snippet(AUTO_METHOD_PATH)).isEqualTo("`POST /test`");
    }
}
 
Example #2
Source File: MethodAndPathSnippetTest.java    From spring-auto-restdocs with Apache License 2.0 5 votes vote down vote up
@Test
public void noHandlerMethod() throws Exception {
    new MethodAndPathSnippet().document(operationBuilder
            .attribute(REQUEST_PATTERN, "/test")
            .request("http://localhost/test")
            .method("POST")
            .build());

    if (TemplateFormats.asciidoctor().equals(this.templateFormat)) {
        assertThat(this.generatedSnippets.snippet(AUTO_METHOD_PATH)).isEqualTo("`+POST /test+`");
    } else {
        assertThat(this.generatedSnippets.snippet(AUTO_METHOD_PATH)).isEqualTo("`POST /test`");
    }
}
 
Example #3
Source File: OperationBuilder.java    From restdocs-wiremock with Apache License 2.0 4 votes vote down vote up
public OperationBuilder(String name, File outputDirectory) {
	this(name, outputDirectory, TemplateFormats.asciidoctor());
}
 
Example #4
Source File: OperationAttributeHelper.java    From spring-auto-restdocs with Apache License 2.0 4 votes vote down vote up
public static TemplateFormatting determineTemplateFormatting(TemplateFormat templateFormat) {
    return templateFormat.getId().equals(TemplateFormats.asciidoctor().getId())
            ? TemplateFormatting.ASCIIDOC : TemplateFormatting.MARKDOWN;
}
 
Example #5
Source File: SectionSnippetTest.java    From spring-auto-restdocs with Apache License 2.0 4 votes vote down vote up
public SectionSnippetTest() {
    // Only runs for AsciiDoctor, because Markdown is not supported.
    TemplateFormat templateFormat = TemplateFormats.asciidoctor();
    this.generatedSnippets = new GeneratedSnippets(templateFormat);
    this.operationBuilder = new OperationBuilder(templateFormat);
}