Merge branch '1.2.x'
This commit is contained in:
@@ -104,6 +104,7 @@ org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.processAnnotations=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
|
||||
@@ -114,11 +115,14 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_e
|
||||
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_module_statements=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
|
||||
@@ -128,6 +132,8 @@ org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
|
||||
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
|
||||
@@ -154,6 +160,7 @@ org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
|
||||
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
|
||||
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
|
||||
org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
|
||||
org.eclipse.jdt.core.formatter.comment.format_header=false
|
||||
org.eclipse.jdt.core.formatter.comment.format_html=true
|
||||
@@ -186,6 +193,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
|
||||
org.eclipse.jdt.core.formatter.indentation.size=4
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
|
||||
@@ -380,12 +388,24 @@ org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
|
||||
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
|
||||
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines
|
||||
org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
|
||||
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
|
||||
org.eclipse.jdt.core.formatter.tabulation.char=tab
|
||||
org.eclipse.jdt.core.formatter.tabulation.size=4
|
||||
org.eclipse.jdt.core.formatter.use_on_off_tags=true
|
||||
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
||||
org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
|
||||
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
|
||||
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
|
||||
org.eclipse.jdt.core.javaFormatter=org.springframework.ide.eclipse.jdt.formatter.javaformatter
|
||||
org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -167,10 +167,9 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
|
||||
@Test
|
||||
public void postRequestWithMultipleParameters() throws IOException {
|
||||
this.snippets.expectCurlRequest()
|
||||
.withContents(codeBlock("bash")
|
||||
.content("$ curl 'http://localhost/foo' -i -X POST"
|
||||
+ " -d 'k1=v1&k1=v1-bis&k2=v2'"));
|
||||
this.snippets.expectCurlRequest().withContents(
|
||||
codeBlock("bash").content("$ curl 'http://localhost/foo' -i -X POST"
|
||||
+ " -d 'k1=v1&k1=v1-bis&k2=v2'"));
|
||||
new CurlRequestSnippet(this.commandFormatter).document(
|
||||
this.operationBuilder.request("http://localhost/foo").method("POST")
|
||||
.param("k1", "v1", "v1-bis").param("k2", "v2").build());
|
||||
@@ -224,10 +223,9 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
|
||||
@Test
|
||||
public void putRequestWithMultipleParameters() throws IOException {
|
||||
this.snippets.expectCurlRequest()
|
||||
.withContents(codeBlock("bash")
|
||||
.content("$ curl 'http://localhost/foo' -i -X PUT"
|
||||
+ " -d 'k1=v1&k1=v1-bis&k2=v2'"));
|
||||
this.snippets.expectCurlRequest().withContents(
|
||||
codeBlock("bash").content("$ curl 'http://localhost/foo' -i -X PUT"
|
||||
+ " -d 'k1=v1&k1=v1-bis&k2=v2'"));
|
||||
new CurlRequestSnippet(this.commandFormatter).document(this.operationBuilder
|
||||
.request("http://localhost/foo").method("PUT").param("k1", "v1")
|
||||
.param("k1", "v1-bis").param("k2", "v2").build());
|
||||
@@ -247,11 +245,10 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
this.snippets.expectCurlRequest()
|
||||
.withContents(codeBlock("bash").content("$ curl 'http://localhost/foo' -i"
|
||||
+ " -H 'Content-Type: application/json' -H 'a: alpha'"));
|
||||
new CurlRequestSnippet(this.commandFormatter)
|
||||
.document(this.operationBuilder.request("http://localhost/foo")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.APPLICATION_JSON_VALUE)
|
||||
.header("a", "alpha").build());
|
||||
new CurlRequestSnippet(this.commandFormatter).document(this.operationBuilder
|
||||
.request("http://localhost/foo")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
||||
.header("a", "alpha").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -285,10 +282,9 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
+ "'metadata={\"description\": \"foo\"}'";
|
||||
this.snippets.expectCurlRequest()
|
||||
.withContents(codeBlock("bash").content(expectedContent));
|
||||
new CurlRequestSnippet(this.commandFormatter).document(
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
new CurlRequestSnippet(this.commandFormatter).document(this.operationBuilder
|
||||
.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("metadata", "{\"description\": \"foo\"}".getBytes()).build());
|
||||
}
|
||||
|
||||
@@ -299,10 +295,9 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
+ "'image=@documents/images/example.png;type=image/png'";
|
||||
this.snippets.expectCurlRequest()
|
||||
.withContents(codeBlock("bash").content(expectedContent));
|
||||
new CurlRequestSnippet(this.commandFormatter).document(
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
new CurlRequestSnippet(this.commandFormatter).document(this.operationBuilder
|
||||
.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", new byte[0])
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.IMAGE_PNG_VALUE)
|
||||
.submittedFileName("documents/images/example.png").build());
|
||||
@@ -315,10 +310,9 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
+ "'image=@documents/images/example.png'";
|
||||
this.snippets.expectCurlRequest()
|
||||
.withContents(codeBlock("bash").content(expectedContent));
|
||||
new CurlRequestSnippet(this.commandFormatter).document(
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
new CurlRequestSnippet(this.commandFormatter).document(this.operationBuilder
|
||||
.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", new byte[0])
|
||||
.submittedFileName("documents/images/example.png").build());
|
||||
}
|
||||
@@ -331,10 +325,9 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
+ "-F 'b=banana'";
|
||||
this.snippets.expectCurlRequest()
|
||||
.withContents(codeBlock("bash").content(expectedContent));
|
||||
new CurlRequestSnippet(this.commandFormatter).document(
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
new CurlRequestSnippet(this.commandFormatter).document(this.operationBuilder
|
||||
.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", new byte[0])
|
||||
.submittedFileName("documents/images/example.png").and()
|
||||
.param("a", "apple", "avocado").param("b", "banana").build());
|
||||
@@ -344,11 +337,10 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
public void basicAuthCredentialsAreSuppliedUsingUserOption() throws IOException {
|
||||
this.snippets.expectCurlRequest().withContents(codeBlock("bash")
|
||||
.content("$ curl 'http://localhost/foo' -i -u 'user:secret'"));
|
||||
new CurlRequestSnippet(this.commandFormatter)
|
||||
.document(this.operationBuilder.request("http://localhost/foo")
|
||||
.header(HttpHeaders.AUTHORIZATION,
|
||||
"Basic " + Base64Utils
|
||||
.encodeToString("user:secret".getBytes()))
|
||||
new CurlRequestSnippet(this.commandFormatter).document(this.operationBuilder
|
||||
.request("http://localhost/foo")
|
||||
.header(HttpHeaders.AUTHORIZATION,
|
||||
"Basic " + Base64Utils.encodeToString("user:secret".getBytes()))
|
||||
.build());
|
||||
}
|
||||
|
||||
@@ -375,12 +367,11 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests {
|
||||
.withContents(codeBlock("bash").content(
|
||||
"$ curl 'http://localhost/foo' -i" + " -H 'Host: api.example.com'"
|
||||
+ " -H 'Content-Type: application/json' -H 'a: alpha'"));
|
||||
new CurlRequestSnippet(this.commandFormatter)
|
||||
.document(this.operationBuilder.request("http://localhost/foo")
|
||||
.header(HttpHeaders.HOST, "api.example.com")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.APPLICATION_JSON_VALUE)
|
||||
.header("a", "alpha").build());
|
||||
new CurlRequestSnippet(this.commandFormatter).document(this.operationBuilder
|
||||
.request("http://localhost/foo")
|
||||
.header(HttpHeaders.HOST, "api.example.com")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
||||
.header("a", "alpha").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -168,10 +168,9 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
|
||||
@Test
|
||||
public void postRequestWithMultipleParameters() throws IOException {
|
||||
this.snippets.expectHttpieRequest()
|
||||
.withContents(codeBlock("bash")
|
||||
.content("$ http --form POST 'http://localhost/foo'"
|
||||
+ " 'k1=v1' 'k1=v1-bis' 'k2=v2'"));
|
||||
this.snippets.expectHttpieRequest().withContents(
|
||||
codeBlock("bash").content("$ http --form POST 'http://localhost/foo'"
|
||||
+ " 'k1=v1' 'k1=v1-bis' 'k2=v2'"));
|
||||
new HttpieRequestSnippet(this.commandFormatter).document(
|
||||
this.operationBuilder.request("http://localhost/foo").method("POST")
|
||||
.param("k1", "v1", "v1-bis").param("k2", "v2").build());
|
||||
@@ -225,10 +224,9 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
|
||||
@Test
|
||||
public void putRequestWithMultipleParameters() throws IOException {
|
||||
this.snippets.expectHttpieRequest()
|
||||
.withContents(codeBlock("bash")
|
||||
.content("$ http --form PUT 'http://localhost/foo'"
|
||||
+ " 'k1=v1' 'k1=v1-bis' 'k2=v2'"));
|
||||
this.snippets.expectHttpieRequest().withContents(
|
||||
codeBlock("bash").content("$ http --form PUT 'http://localhost/foo'"
|
||||
+ " 'k1=v1' 'k1=v1-bis' 'k2=v2'"));
|
||||
new HttpieRequestSnippet(this.commandFormatter).document(this.operationBuilder
|
||||
.request("http://localhost/foo").method("PUT").param("k1", "v1")
|
||||
.param("k1", "v1-bis").param("k2", "v2").build());
|
||||
@@ -248,11 +246,10 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
this.snippets.expectHttpieRequest().withContents(
|
||||
codeBlock("bash").content("$ http GET 'http://localhost/foo'"
|
||||
+ " 'Content-Type:application/json' 'a:alpha'"));
|
||||
new HttpieRequestSnippet(this.commandFormatter)
|
||||
.document(this.operationBuilder.request("http://localhost/foo")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.APPLICATION_JSON_VALUE)
|
||||
.header("a", "alpha").build());
|
||||
new HttpieRequestSnippet(this.commandFormatter).document(this.operationBuilder
|
||||
.request("http://localhost/foo")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
||||
.header("a", "alpha").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -283,10 +280,9 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
+ " 'metadata'@<(echo '{\"description\": \"foo\"}')";
|
||||
this.snippets.expectHttpieRequest()
|
||||
.withContents(codeBlock("bash").content(expectedContent));
|
||||
new HttpieRequestSnippet(this.commandFormatter).document(
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
new HttpieRequestSnippet(this.commandFormatter).document(this.operationBuilder
|
||||
.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("metadata", "{\"description\": \"foo\"}".getBytes()).build());
|
||||
}
|
||||
|
||||
@@ -297,10 +293,9 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
+ " 'image'@'documents/images/example.png'";
|
||||
this.snippets.expectHttpieRequest()
|
||||
.withContents(codeBlock("bash").content(expectedContent));
|
||||
new HttpieRequestSnippet(this.commandFormatter).document(
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
new HttpieRequestSnippet(this.commandFormatter).document(this.operationBuilder
|
||||
.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", new byte[0])
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.IMAGE_PNG_VALUE)
|
||||
.submittedFileName("documents/images/example.png").build());
|
||||
@@ -312,10 +307,9 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
+ " 'image'@'documents/images/example.png'";
|
||||
this.snippets.expectHttpieRequest()
|
||||
.withContents(codeBlock("bash").content(expectedContent));
|
||||
new HttpieRequestSnippet(this.commandFormatter).document(
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
new HttpieRequestSnippet(this.commandFormatter).document(this.operationBuilder
|
||||
.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", new byte[0])
|
||||
.submittedFileName("documents/images/example.png").build());
|
||||
}
|
||||
@@ -327,10 +321,9 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
+ " 'b=banana'";
|
||||
this.snippets.expectHttpieRequest()
|
||||
.withContents(codeBlock("bash").content(expectedContent));
|
||||
new HttpieRequestSnippet(this.commandFormatter).document(
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
new HttpieRequestSnippet(this.commandFormatter).document(this.operationBuilder
|
||||
.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", new byte[0])
|
||||
.submittedFileName("documents/images/example.png").and()
|
||||
.param("a", "apple", "avocado").param("b", "banana").build());
|
||||
@@ -340,11 +333,10 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
public void basicAuthCredentialsAreSuppliedUsingAuthOption() throws IOException {
|
||||
this.snippets.expectHttpieRequest().withContents(codeBlock("bash")
|
||||
.content("$ http --auth 'user:secret' GET 'http://localhost/foo'"));
|
||||
new HttpieRequestSnippet(this.commandFormatter)
|
||||
.document(this.operationBuilder.request("http://localhost/foo")
|
||||
.header(HttpHeaders.AUTHORIZATION,
|
||||
"Basic " + Base64Utils
|
||||
.encodeToString("user:secret".getBytes()))
|
||||
new HttpieRequestSnippet(this.commandFormatter).document(this.operationBuilder
|
||||
.request("http://localhost/foo")
|
||||
.header(HttpHeaders.AUTHORIZATION,
|
||||
"Basic " + Base64Utils.encodeToString("user:secret".getBytes()))
|
||||
.build());
|
||||
}
|
||||
|
||||
@@ -371,12 +363,11 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests {
|
||||
.withContents(codeBlock("bash").content(
|
||||
"$ http GET 'http://localhost/foo' 'Host:api.example.com'"
|
||||
+ " 'Content-Type:application/json' 'a:alpha'"));
|
||||
new HttpieRequestSnippet(this.commandFormatter)
|
||||
.document(this.operationBuilder.request("http://localhost/foo")
|
||||
.header(HttpHeaders.HOST, "api.example.com")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.APPLICATION_JSON_VALUE)
|
||||
.header("a", "alpha").build());
|
||||
new HttpieRequestSnippet(this.commandFormatter).document(this.operationBuilder
|
||||
.request("http://localhost/foo")
|
||||
.header(HttpHeaders.HOST, "api.example.com")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
||||
.header("a", "alpha").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -83,8 +83,8 @@ public class RestDocumentationConfigurerTests {
|
||||
assertThat(configuration, hasEntry(equalTo(WriterResolver.class.getName()),
|
||||
instanceOf(StandardWriterResolver.class)));
|
||||
assertThat(configuration,
|
||||
hasEntry(
|
||||
equalTo(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_SNIPPETS),
|
||||
hasEntry(equalTo(
|
||||
RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_SNIPPETS),
|
||||
instanceOf(List.class)));
|
||||
List<Snippet> defaultSnippets = (List<Snippet>) configuration
|
||||
.get(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_SNIPPETS);
|
||||
@@ -138,8 +138,8 @@ public class RestDocumentationConfigurerTests {
|
||||
this.configurer.snippets().withDefaults(CliDocumentation.curlRequest())
|
||||
.apply(configuration, createContext());
|
||||
assertThat(configuration,
|
||||
hasEntry(
|
||||
equalTo(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_SNIPPETS),
|
||||
hasEntry(equalTo(
|
||||
RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_SNIPPETS),
|
||||
instanceOf(List.class)));
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Snippet> defaultSnippets = (List<Snippet>) configuration
|
||||
@@ -155,8 +155,8 @@ public class RestDocumentationConfigurerTests {
|
||||
this.configurer.snippets().withAdditionalDefaults(snippet).apply(configuration,
|
||||
createContext());
|
||||
assertThat(configuration,
|
||||
hasEntry(
|
||||
equalTo(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_SNIPPETS),
|
||||
hasEntry(equalTo(
|
||||
RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_SNIPPETS),
|
||||
instanceOf(List.class)));
|
||||
List<Snippet> defaultSnippets = (List<Snippet>) configuration
|
||||
.get(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_SNIPPETS);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -61,17 +61,10 @@ public class RequestHeadersSnippetTests extends AbstractSnippetTests {
|
||||
headerWithName("Accept-Encoding").description("three"),
|
||||
headerWithName("Accept-Language").description("four"),
|
||||
headerWithName("Cache-Control").description("five"),
|
||||
headerWithName(
|
||||
"Connection")
|
||||
.description("six")))
|
||||
.document(
|
||||
this.operationBuilder
|
||||
.request(
|
||||
"http://localhost")
|
||||
.header("X-Test", "test")
|
||||
.header("Accept", "*/*")
|
||||
.header("Accept-Encoding",
|
||||
"gzip, deflate")
|
||||
headerWithName("Connection").description("six"))).document(
|
||||
this.operationBuilder.request("http://localhost")
|
||||
.header("X-Test", "test").header("Accept", "*/*")
|
||||
.header("Accept-Encoding", "gzip, deflate")
|
||||
.header("Accept-Language", "en-US,en;q=0.5")
|
||||
.header("Cache-Control", "max-age=0")
|
||||
.header("Connection", "keep-alive").build());
|
||||
@@ -105,8 +98,7 @@ public class RequestHeadersSnippetTests extends AbstractSnippetTests {
|
||||
given(resolver.resolveTemplateResource("request-headers"))
|
||||
.willReturn(snippetResource("request-headers-with-title"));
|
||||
new RequestHeadersSnippet(
|
||||
Arrays.asList(headerWithName("X-Test").description("one")),
|
||||
attributes(
|
||||
Arrays.asList(headerWithName("X-Test").description("one")), attributes(
|
||||
key("title").value("Custom title")))
|
||||
.document(
|
||||
this.operationBuilder
|
||||
@@ -143,7 +135,7 @@ public class RequestHeadersSnippetTests extends AbstractSnippetTests {
|
||||
.header("X-Test", "test")
|
||||
.header("Accept-Encoding",
|
||||
"gzip, deflate")
|
||||
.header("Accept", "*/*").build());
|
||||
.header("Accept", "*/*").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -160,10 +152,7 @@ public class RequestHeadersSnippetTests extends AbstractSnippetTests {
|
||||
headerWithName("Accept-Encoding").description("three"),
|
||||
headerWithName("Accept-Language").description("four"))
|
||||
.and(headerWithName("Cache-Control").description("five"),
|
||||
headerWithName(
|
||||
"Connection")
|
||||
.description(
|
||||
"six"))
|
||||
headerWithName("Connection").description("six"))
|
||||
.document(this.operationBuilder.request("http://localhost")
|
||||
.header("X-Test", "test").header("Accept", "*/*")
|
||||
.header("Accept-Encoding", "gzip, deflate")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -58,15 +58,12 @@ public class ResponseHeadersSnippetTests extends AbstractSnippetTests {
|
||||
headerWithName("Content-Type").description("two"),
|
||||
headerWithName("Etag").description("three"),
|
||||
headerWithName("Cache-Control").description("five"),
|
||||
headerWithName("Vary").description("six")))
|
||||
.document(
|
||||
this.operationBuilder.response()
|
||||
.header("X-Test", "test")
|
||||
.header("Content-Type",
|
||||
"application/json")
|
||||
.header("Etag", "lskjadldj3ii32l2ij23")
|
||||
.header("Cache-Control", "max-age=0")
|
||||
.header("Vary", "User-Agent").build());
|
||||
headerWithName("Vary").description("six"))).document(
|
||||
this.operationBuilder.response().header("X-Test", "test")
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Etag", "lskjadldj3ii32l2ij23")
|
||||
.header("Cache-Control", "max-age=0")
|
||||
.header("Vary", "User-Agent").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -97,8 +94,7 @@ public class ResponseHeadersSnippetTests extends AbstractSnippetTests {
|
||||
given(resolver.resolveTemplateResource("response-headers"))
|
||||
.willReturn(snippetResource("response-headers-with-title"));
|
||||
new ResponseHeadersSnippet(
|
||||
Arrays.asList(headerWithName("X-Test").description("one")),
|
||||
attributes(
|
||||
Arrays.asList(headerWithName("X-Test").description("one")), attributes(
|
||||
key("title").value("Custom title")))
|
||||
.document(
|
||||
this.operationBuilder
|
||||
@@ -133,7 +129,8 @@ public class ResponseHeadersSnippetTests extends AbstractSnippetTests {
|
||||
.response().header("X-Test", "test")
|
||||
.header("Content-Type",
|
||||
"application/json")
|
||||
.header("Etag", "lskjadldj3ii32l2ij23").build());
|
||||
.header("Etag", "lskjadldj3ii32l2ij23")
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -278,10 +278,9 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
.header("Content-Type",
|
||||
"multipart/form-data; boundary=" + BOUNDARY)
|
||||
.header(HttpHeaders.HOST, "localhost").content(expectedContent));
|
||||
new HttpRequestSnippet().document(
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
new HttpRequestSnippet().document(this.operationBuilder
|
||||
.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", "<< data >>".getBytes()).build());
|
||||
}
|
||||
|
||||
@@ -294,10 +293,9 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
.header("Content-Type",
|
||||
"multipart/form-data; boundary=" + BOUNDARY)
|
||||
.header(HttpHeaders.HOST, "localhost").content(expectedContent));
|
||||
new HttpRequestSnippet().document(
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
new HttpRequestSnippet().document(this.operationBuilder
|
||||
.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", "<< data >>".getBytes()).submittedFileName("image.png")
|
||||
.build());
|
||||
}
|
||||
@@ -321,10 +319,9 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
.header("Content-Type",
|
||||
"multipart/form-data; boundary=" + BOUNDARY)
|
||||
.header(HttpHeaders.HOST, "localhost").content(expectedContent));
|
||||
new HttpRequestSnippet().document(
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
new HttpRequestSnippet().document(this.operationBuilder
|
||||
.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.param("a", "apple", "avocado").param("b", "banana")
|
||||
.part("image", "<< data >>".getBytes()).build());
|
||||
}
|
||||
@@ -341,11 +338,10 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
.header("Content-Type",
|
||||
"multipart/form-data; boundary=" + BOUNDARY)
|
||||
.header(HttpHeaders.HOST, "localhost").content(expectedContent));
|
||||
new HttpRequestSnippet().document(
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.param("a").part("image", "<< data >>".getBytes()).build());
|
||||
new HttpRequestSnippet().document(this.operationBuilder
|
||||
.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.param("a").part("image", "<< data >>".getBytes()).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -358,10 +354,9 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
.header("Content-Type",
|
||||
"multipart/form-data; boundary=" + BOUNDARY)
|
||||
.header(HttpHeaders.HOST, "localhost").content(expectedContent));
|
||||
new HttpRequestSnippet().document(
|
||||
this.operationBuilder.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
new HttpRequestSnippet().document(this.operationBuilder
|
||||
.request("http://localhost/upload").method("POST")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.part("image", "<< data >>".getBytes())
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.IMAGE_PNG_VALUE).build());
|
||||
}
|
||||
@@ -383,15 +378,11 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests {
|
||||
TemplateResourceResolver resolver = mock(TemplateResourceResolver.class);
|
||||
given(resolver.resolveTemplateResource("http-request"))
|
||||
.willReturn(snippetResource("http-request-with-title"));
|
||||
new HttpRequestSnippet(
|
||||
attributes(
|
||||
key("title").value("Title for the request")))
|
||||
.document(
|
||||
this.operationBuilder
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(
|
||||
resolver))
|
||||
.request("http://localhost/foo").build());
|
||||
new HttpRequestSnippet(attributes(key("title").value("Title for the request")))
|
||||
.document(this.operationBuilder
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(resolver))
|
||||
.request("http://localhost/foo").build());
|
||||
}
|
||||
|
||||
private String createPart(String content) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,11 +65,9 @@ public class HttpResponseSnippetTests extends AbstractSnippetTests {
|
||||
public void responseWithHeaders() throws IOException {
|
||||
this.snippets.expectHttpResponse().withContents(httpResponse(HttpStatus.OK)
|
||||
.header("Content-Type", "application/json").header("a", "alpha"));
|
||||
new HttpResponseSnippet()
|
||||
.document(this.operationBuilder.response()
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.APPLICATION_JSON_VALUE)
|
||||
.header("a", "alpha").build());
|
||||
new HttpResponseSnippet().document(this.operationBuilder.response()
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
||||
.header("a", "alpha").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -148,11 +148,10 @@ public class LinksSnippetTests extends AbstractSnippetTests {
|
||||
.attributes(key("foo").value("alpha")),
|
||||
new LinkDescriptor("b").description("two")
|
||||
.attributes(key("foo").value("bravo"))))
|
||||
.document(this.operationBuilder
|
||||
.attribute(TemplateEngine.class
|
||||
.getName(),
|
||||
.document(this.operationBuilder.attribute(
|
||||
TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(resolver))
|
||||
.build());
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -163,7 +162,7 @@ public class LinksSnippetTests extends AbstractSnippetTests {
|
||||
HypermediaDocumentation
|
||||
.links(new StubLinkExtractor().withLinks(new Link("a", "alpha"),
|
||||
new Link("b", "bravo")),
|
||||
new LinkDescriptor("a").description("one"))
|
||||
new LinkDescriptor("a").description("one"))
|
||||
.and(new LinkDescriptor("b").description("two"))
|
||||
.document(this.operationBuilder.build());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,7 +56,7 @@ public class PrettyPrintingContentModifierTests {
|
||||
equalTo(String
|
||||
.format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>%n"
|
||||
+ "<one a=\"alpha\">%n <two b=\"bravo\"/>%n</one>%n")
|
||||
.getBytes()));
|
||||
.getBytes()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -262,10 +262,8 @@ public class JsonFieldTypeResolverTests {
|
||||
|
||||
@Test
|
||||
public void intermediateWildcardWithVaryingType() throws IOException {
|
||||
assertThat(
|
||||
this.fieldTypeResolver.resolveFieldType(new FieldDescriptor("a.*.d"),
|
||||
createPayload(
|
||||
"{\"a\": {\"b\": {\"d\": 4}, \"c\": {\"d\": \"four\"}}}}")),
|
||||
assertThat(this.fieldTypeResolver.resolveFieldType(new FieldDescriptor("a.*.d"),
|
||||
createPayload("{\"a\": {\"b\": {\"d\": 4}, \"c\": {\"d\": \"four\"}}}}")),
|
||||
equalTo(JsonFieldType.VARIES));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -78,18 +78,12 @@ public class RequestBodyPartSnippetTests extends AbstractSnippetTests {
|
||||
TemplateResourceResolver resolver = mock(TemplateResourceResolver.class);
|
||||
given(resolver.resolveTemplateResource("request-part-body"))
|
||||
.willReturn(snippetResource("request-part-body-with-language"));
|
||||
requestPartBody("one",
|
||||
attributes(
|
||||
key("language").value("json")))
|
||||
.document(
|
||||
this.operationBuilder
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(
|
||||
resolver))
|
||||
.request("http://localhost")
|
||||
.part("one",
|
||||
"{\"a\":\"alpha\"}".getBytes())
|
||||
.build());
|
||||
requestPartBody("one", attributes(key("language").value("json")))
|
||||
.document(this.operationBuilder
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(resolver))
|
||||
.request("http://localhost")
|
||||
.part("one", "{\"a\":\"alpha\"}".getBytes()).build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -77,16 +77,12 @@ public class RequestBodySnippetTests extends AbstractSnippetTests {
|
||||
TemplateResourceResolver resolver = mock(TemplateResourceResolver.class);
|
||||
given(resolver.resolveTemplateResource("request-body"))
|
||||
.willReturn(snippetResource("request-body-with-language"));
|
||||
requestBody(
|
||||
attributes(
|
||||
key("language").value("json")))
|
||||
.document(
|
||||
this.operationBuilder
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(
|
||||
resolver))
|
||||
.request("http://localhost")
|
||||
.content("{\"a\":\"alpha\"}").build());
|
||||
requestBody(attributes(key("language").value("json")))
|
||||
.document(this.operationBuilder
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(resolver))
|
||||
.request("http://localhost").content("{\"a\":\"alpha\"}")
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -233,7 +233,7 @@ public class RequestFieldsSnippetFailureTests {
|
||||
this.operationBuilder.request("http://localhost")
|
||||
.content("{\"a\":[{\"b\": 1,\"c\": 2}, "
|
||||
+ "{\"c\": 2}, {\"b\": 1,\"c\": 2}]}")
|
||||
.build());
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -118,7 +118,7 @@ public class RequestFieldsSnippetTests extends AbstractSnippetTests {
|
||||
.document(this.operationBuilder.request("http://localhost")
|
||||
.content("[{\"a\": {\"b\": 5, \"c\":\"charlie\"}},"
|
||||
+ "{\"a\": {\"b\": 4, \"c\":\"chalk\"}}]")
|
||||
.build());
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -235,8 +235,8 @@ public class RequestFieldsSnippetTests extends AbstractSnippetTests {
|
||||
.willReturn(snippetResource("request-fields-with-title"));
|
||||
this.snippets.expectRequestFields().withContents(containsString("Custom title"));
|
||||
|
||||
new RequestFieldsSnippet(Arrays.asList(fieldWithPath("a").description("one")),
|
||||
attributes(
|
||||
new RequestFieldsSnippet(
|
||||
Arrays.asList(fieldWithPath("a").description("one")), attributes(
|
||||
key("title").value("Custom title")))
|
||||
.document(
|
||||
this.operationBuilder
|
||||
@@ -265,15 +265,13 @@ public class RequestFieldsSnippetTests extends AbstractSnippetTests {
|
||||
.attributes(key("foo").value("bravo")),
|
||||
fieldWithPath("a").description("three")
|
||||
.attributes(key("foo").value("charlie"))))
|
||||
.document(
|
||||
this.operationBuilder
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(
|
||||
resolver))
|
||||
.request("http://localhost")
|
||||
.content(
|
||||
"{\"a\": {\"b\": 5, \"c\": \"charlie\"}}")
|
||||
.build());
|
||||
.document(this.operationBuilder
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(resolver))
|
||||
.request("http://localhost")
|
||||
.content(
|
||||
"{\"a\": {\"b\": 5, \"c\": \"charlie\"}}")
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,17 +48,13 @@ public class RequestPartFieldsSnippetTests extends AbstractSnippetTests {
|
||||
.row("`a.b`", "`Number`", "one").row("`a.c`", "`String`", "two")
|
||||
.row("`a`", "`Object`", "three"));
|
||||
|
||||
new RequestPartFieldsSnippet("one",
|
||||
Arrays.asList(fieldWithPath("a.b").description("one"),
|
||||
fieldWithPath("a.c").description("two"), fieldWithPath("a")
|
||||
.description("three")))
|
||||
.document(
|
||||
this.operationBuilder
|
||||
.request("http://localhost")
|
||||
.part("one",
|
||||
"{\"a\": {\"b\": 5, \"c\": \"charlie\"}}"
|
||||
.getBytes())
|
||||
.build());
|
||||
new RequestPartFieldsSnippet("one", Arrays.asList(
|
||||
fieldWithPath("a.b").description("one"),
|
||||
fieldWithPath("a.c").description("two"),
|
||||
fieldWithPath("a").description("three"))).document(this.operationBuilder
|
||||
.request("http://localhost")
|
||||
.part("one", "{\"a\": {\"b\": 5, \"c\": \"charlie\"}}".getBytes())
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -67,17 +63,12 @@ public class RequestPartFieldsSnippetTests extends AbstractSnippetTests {
|
||||
.withContents(tableWithHeader("Path", "Type", "Description")
|
||||
.row("`b`", "`Number`", "one").row("`c`", "`String`", "two"));
|
||||
|
||||
new RequestPartFieldsSnippet("one",
|
||||
beneathPath("a"), Arrays
|
||||
.asList(fieldWithPath("b").description("one"),
|
||||
fieldWithPath("c").description("two")))
|
||||
.document(
|
||||
this.operationBuilder
|
||||
.request("http://localhost")
|
||||
.part("one",
|
||||
"{\"a\": {\"b\": 5, \"c\": \"charlie\"}}"
|
||||
.getBytes())
|
||||
.build());
|
||||
new RequestPartFieldsSnippet("one", beneathPath("a"), Arrays.asList(
|
||||
fieldWithPath("b").description("one"),
|
||||
fieldWithPath("c").description("two"))).document(this.operationBuilder
|
||||
.request("http://localhost")
|
||||
.part("one", "{\"a\": {\"b\": 5, \"c\": \"charlie\"}}".getBytes())
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -77,16 +77,11 @@ public class ResponseBodySnippetTests extends AbstractSnippetTests {
|
||||
TemplateResourceResolver resolver = mock(TemplateResourceResolver.class);
|
||||
given(resolver.resolveTemplateResource("response-body"))
|
||||
.willReturn(snippetResource("response-body-with-language"));
|
||||
responseBody(
|
||||
attributes(
|
||||
key("language").value("json")))
|
||||
.document(
|
||||
this.operationBuilder
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(
|
||||
resolver))
|
||||
.response().content("{\"a\":\"alpha\"}")
|
||||
.build());
|
||||
responseBody(attributes(key("language").value("json")))
|
||||
.document(this.operationBuilder
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(resolver))
|
||||
.response().content("{\"a\":\"alpha\"}").build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -108,7 +108,7 @@ public class ResponseFieldsSnippetFailureTests {
|
||||
.content("<a>foo</a>")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.APPLICATION_XML_VALUE)
|
||||
.build());
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -202,7 +202,7 @@ public class ResponseFieldsSnippetFailureTests {
|
||||
this.operationBuilder.response()
|
||||
.content("{\"a\":[{\"b\": 1,\"c\": 2}, "
|
||||
+ "{\"c\": 2}, {\"b\": 1,\"c\": 2}]}")
|
||||
.build());
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -121,7 +121,7 @@ public class ResponseFieldsSnippetTests extends AbstractSnippetTests {
|
||||
Arrays.asList(fieldWithPath("[]a.b").description("one")))
|
||||
.document(this.operationBuilder.response().content(
|
||||
"[{\"a\": {\"b\": null}}," + "{\"a\": {\"b\": null}}]")
|
||||
.build());
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -180,8 +180,8 @@ public class ResponseFieldsSnippetTests extends AbstractSnippetTests {
|
||||
.willReturn(snippetResource("response-fields-with-title"));
|
||||
this.snippets.expectResponseFields().withContents(containsString("Custom title"));
|
||||
|
||||
new ResponseFieldsSnippet(Arrays.asList(fieldWithPath("a").description("one")),
|
||||
attributes(
|
||||
new ResponseFieldsSnippet(
|
||||
Arrays.asList(fieldWithPath("a").description("one")), attributes(
|
||||
key("title").value("Custom title")))
|
||||
.document(
|
||||
this.operationBuilder
|
||||
@@ -241,15 +241,13 @@ public class ResponseFieldsSnippetTests extends AbstractSnippetTests {
|
||||
.attributes(key("foo").value("bravo")),
|
||||
fieldWithPath("a").description("three")
|
||||
.attributes(key("foo").value("charlie"))))
|
||||
.document(
|
||||
this.operationBuilder
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(
|
||||
resolver))
|
||||
.response()
|
||||
.content(
|
||||
"{\"a\": {\"b\": 5, \"c\": \"charlie\"}}")
|
||||
.build());
|
||||
.document(this.operationBuilder
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(resolver))
|
||||
.response()
|
||||
.content(
|
||||
"{\"a\": {\"b\": 5, \"c\": \"charlie\"}}")
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -319,7 +317,7 @@ public class ResponseFieldsSnippetTests extends AbstractSnippetTests {
|
||||
.content("<a id=\"1\">foo</a>")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.APPLICATION_XML_VALUE)
|
||||
.build());
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -335,7 +333,7 @@ public class ResponseFieldsSnippetTests extends AbstractSnippetTests {
|
||||
.content("<a>foo</a>")
|
||||
.header(HttpHeaders.CONTENT_TYPE,
|
||||
MediaType.APPLICATION_XML_VALUE)
|
||||
.build());
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -77,11 +77,10 @@ public class PathParametersSnippetTests extends AbstractSnippetTests {
|
||||
tableWithTitleAndHeader(getTitle(), "Parameter", "Description").row("`b`",
|
||||
"two"));
|
||||
new PathParametersSnippet(
|
||||
Arrays.asList(parameterWithName("b").description("two")),
|
||||
true).document(this.operationBuilder
|
||||
.attribute(RestDocumentationGenerator.ATTRIBUTE_NAME_URL_TEMPLATE,
|
||||
"/{a}/{b}")
|
||||
.build());
|
||||
Arrays.asList(parameterWithName("b").description("two")), true)
|
||||
.document(this.operationBuilder.attribute(
|
||||
RestDocumentationGenerator.ATTRIBUTE_NAME_URL_TEMPLATE,
|
||||
"/{a}/{b}").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -143,13 +142,12 @@ public class PathParametersSnippetTests extends AbstractSnippetTests {
|
||||
Arrays.asList(
|
||||
parameterWithName("a").description("one")
|
||||
.attributes(key("foo").value("alpha")),
|
||||
parameterWithName("b").description("two")
|
||||
.attributes(key("foo").value("bravo"))),
|
||||
parameterWithName("b").description("two")
|
||||
.attributes(key("foo").value("bravo"))),
|
||||
attributes(key("title").value("The title")))
|
||||
.document(this.operationBuilder
|
||||
.attribute(
|
||||
RestDocumentationGenerator.ATTRIBUTE_NAME_URL_TEMPLATE,
|
||||
"/{a}/{b}")
|
||||
.document(this.operationBuilder.attribute(
|
||||
RestDocumentationGenerator.ATTRIBUTE_NAME_URL_TEMPLATE,
|
||||
"/{a}/{b}")
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(resolver))
|
||||
.build());
|
||||
@@ -168,15 +166,13 @@ public class PathParametersSnippetTests extends AbstractSnippetTests {
|
||||
new PathParametersSnippet(Arrays.asList(
|
||||
parameterWithName("a").description("one")
|
||||
.attributes(key("foo").value("alpha")),
|
||||
parameterWithName("b").description("two")
|
||||
.attributes(key("foo").value("bravo"))))
|
||||
.document(this.operationBuilder
|
||||
.attribute(
|
||||
RestDocumentationGenerator.ATTRIBUTE_NAME_URL_TEMPLATE,
|
||||
"/{a}/{b}")
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(resolver))
|
||||
.build());
|
||||
parameterWithName("b").description("two").attributes(key("foo")
|
||||
.value("bravo")))).document(this.operationBuilder.attribute(
|
||||
RestDocumentationGenerator.ATTRIBUTE_NAME_URL_TEMPLATE,
|
||||
"/{a}/{b}")
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(resolver))
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -122,16 +122,12 @@ public class RequestParametersSnippetTests extends AbstractSnippetTests {
|
||||
.attributes(key("foo").value("alpha")),
|
||||
parameterWithName("b").description("two")
|
||||
.attributes(key("foo").value("bravo"))),
|
||||
attributes(
|
||||
key("title").value("The title")))
|
||||
.document(
|
||||
this.operationBuilder
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(
|
||||
resolver))
|
||||
.request("http://localhost")
|
||||
.param("a", "alpha").param("b", "bravo")
|
||||
.build());
|
||||
attributes(key("title").value("The title")))
|
||||
.document(this.operationBuilder
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(resolver))
|
||||
.request("http://localhost").param("a", "alpha")
|
||||
.param("b", "bravo").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -113,16 +113,12 @@ public class RequestPartsSnippetTests extends AbstractSnippetTests {
|
||||
.attributes(key("foo").value("alpha")),
|
||||
partWithName("b").description("two")
|
||||
.attributes(key("foo").value("bravo"))),
|
||||
attributes(
|
||||
key("title").value("The title")))
|
||||
.document(
|
||||
this.operationBuilder
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(
|
||||
resolver))
|
||||
.request("http://localhost")
|
||||
.part("a", "alpha".getBytes()).and()
|
||||
.part("b", "bravo".getBytes()).build());
|
||||
attributes(key("title").value("The title")))
|
||||
.document(this.operationBuilder
|
||||
.attribute(TemplateEngine.class.getName(),
|
||||
new MustacheTemplateEngine(resolver))
|
||||
.request("http://localhost").part("a", "alpha".getBytes())
|
||||
.and().part("b", "bravo".getBytes()).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -93,9 +93,8 @@ public class MockMvcRequestConverterTests {
|
||||
@Test
|
||||
public void requestWithCookies() throws Exception {
|
||||
OperationRequest request = createOperationRequest(
|
||||
MockMvcRequestBuilders.get("/foo")
|
||||
.cookie(new javax.servlet.http.Cookie("cookieName1",
|
||||
"cookieVal1"),
|
||||
MockMvcRequestBuilders.get("/foo").cookie(
|
||||
new javax.servlet.http.Cookie("cookieName1", "cookieVal1"),
|
||||
new javax.servlet.http.Cookie("cookieName2", "cookieVal2")));
|
||||
assertThat(request.getUri(), is(URI.create("http://localhost/foo")));
|
||||
assertThat(request.getMethod(), is(HttpMethod.GET));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -160,9 +160,8 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
|
||||
mockMvc.perform(post("/").accept(MediaType.APPLICATION_JSON).content("content"))
|
||||
.andExpect(status().isOk()).andDo(document("curl-snippet-with-content"));
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/curl-snippet-with-content/curl-request.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/curl-snippet-with-content/curl-request.adoc"),
|
||||
is(snippet(asciidoctor())
|
||||
.withContents(codeBlock(asciidoctor(), "bash").content(String
|
||||
.format("$ curl 'http://localhost:8080/' -i -X POST \\%n"
|
||||
@@ -178,9 +177,8 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON)
|
||||
.cookie(new Cookie("cookieName", "cookieVal"))).andExpect(status().isOk())
|
||||
.andDo(document("curl-snippet-with-cookies"));
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/curl-snippet-with-cookies/curl-request.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/curl-snippet-with-cookies/curl-request.adoc"),
|
||||
is(snippet(asciidoctor()).withContents(codeBlock(asciidoctor(), "bash")
|
||||
.content(String.format("$ curl 'http://localhost:8080/' -i \\%n"
|
||||
+ " -H 'Accept: application/json' \\%n"
|
||||
@@ -194,9 +192,8 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
mockMvc.perform(post("/?foo=bar").param("foo", "bar").param("a", "alpha")
|
||||
.accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
|
||||
.andDo(document("curl-snippet-with-query-string"));
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/curl-snippet-with-query-string/curl-request.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/curl-snippet-with-query-string/curl-request.adoc"),
|
||||
is(snippet(asciidoctor()).withContents(
|
||||
codeBlock(asciidoctor(), "bash").content(String.format("$ curl "
|
||||
+ "'http://localhost:8080/?foo=bar' -i -X POST \\%n"
|
||||
@@ -211,12 +208,11 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
mockMvc.perform(post("/").param("a", "alpha").accept(MediaType.APPLICATION_JSON)
|
||||
.content("some content")).andExpect(status().isOk())
|
||||
.andDo(document("curl-snippet-with-content-and-parameters"));
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/curl-snippet-with-content-and-parameters/curl-request.adoc"),
|
||||
is(snippet(asciidoctor())
|
||||
.withContents(codeBlock(asciidoctor(), "bash").content(String
|
||||
.format("$ curl 'http://localhost:8080/?a=alpha' -i -X POST \\%n"
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/curl-snippet-with-content-and-parameters/curl-request.adoc"),
|
||||
is(snippet(asciidoctor()).withContents(
|
||||
codeBlock(asciidoctor(), "bash").content(String.format(
|
||||
"$ curl 'http://localhost:8080/?a=alpha' -i -X POST \\%n"
|
||||
+ " -H 'Accept: application/json' \\%n"
|
||||
+ " -d 'some content'")))));
|
||||
}
|
||||
@@ -229,9 +225,8 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
mockMvc.perform(post("/").accept(MediaType.APPLICATION_JSON).content("content"))
|
||||
.andExpect(status().isOk())
|
||||
.andDo(document("httpie-snippet-with-content"));
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/httpie-snippet-with-content/httpie-request.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/httpie-snippet-with-content/httpie-request.adoc"),
|
||||
is(snippet(asciidoctor()).withContents(codeBlock(asciidoctor(), "bash")
|
||||
.content(String.format("$ echo 'content' | "
|
||||
+ "http POST 'http://localhost:8080/' \\%n"
|
||||
@@ -246,9 +241,8 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON)
|
||||
.cookie(new Cookie("cookieName", "cookieVal"))).andExpect(status().isOk())
|
||||
.andDo(document("httpie-snippet-with-cookies"));
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/httpie-snippet-with-cookies/httpie-request.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/httpie-snippet-with-cookies/httpie-request.adoc"),
|
||||
is(snippet(asciidoctor()).withContents(codeBlock(asciidoctor(), "bash")
|
||||
.content(String.format("$ http GET 'http://localhost:8080/' \\%n"
|
||||
+ " 'Accept:application/json' \\%n"
|
||||
@@ -262,11 +256,10 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
mockMvc.perform(post("/?foo=bar").param("foo", "bar").param("a", "alpha")
|
||||
.accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
|
||||
.andDo(document("httpie-snippet-with-query-string"));
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/httpie-snippet-with-query-string/httpie-request.adoc"),
|
||||
is(snippet(asciidoctor()).withContents(codeBlock(asciidoctor(),
|
||||
"bash").content(String.format("$ http "
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/httpie-snippet-with-query-string/httpie-request.adoc"),
|
||||
is(snippet(asciidoctor()).withContents(
|
||||
codeBlock(asciidoctor(), "bash").content(String.format("$ http "
|
||||
+ "--form POST 'http://localhost:8080/?foo=bar' \\%n"
|
||||
+ " 'Accept:application/json' \\%n 'a=alpha'")))));
|
||||
}
|
||||
@@ -278,9 +271,8 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
mockMvc.perform(post("/").param("a", "alpha").content("some content")
|
||||
.accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
|
||||
.andDo(document("httpie-snippet-post-with-content-and-parameters"));
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/httpie-snippet-post-with-content-and-parameters/httpie-request.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/httpie-snippet-post-with-content-and-parameters/httpie-request.adoc"),
|
||||
is(snippet(asciidoctor()).withContents(codeBlock(asciidoctor(), "bash")
|
||||
.content(String.format("$ echo " + "'some content' | http POST "
|
||||
+ "'http://localhost:8080/?a=alpha' \\%n"
|
||||
@@ -487,9 +479,8 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
}
|
||||
}
|
||||
String prettyPrinted = String.format("{%n \"a\" : \"<<beta>>\"%n}");
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/preprocessed-request/http-request.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/preprocessed-request/http-request.adoc"),
|
||||
is(snippet(asciidoctor())
|
||||
.withContents(preprocessedRequest.content(prettyPrinted))));
|
||||
}
|
||||
@@ -499,8 +490,7 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
Pattern pattern = Pattern.compile("(\"alpha\")");
|
||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
|
||||
.apply(documentationConfiguration(this.restDocumentation)
|
||||
.operationPreprocessors()
|
||||
.withRequestDefaults(prettyPrint(),
|
||||
.operationPreprocessors().withRequestDefaults(prettyPrint(),
|
||||
removeHeaders("a", HttpHeaders.HOST,
|
||||
HttpHeaders.CONTENT_LENGTH),
|
||||
replacePattern(pattern, "\"<<beta>>\"")))
|
||||
@@ -523,9 +513,8 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
}
|
||||
}
|
||||
String prettyPrinted = String.format("{%n \"a\" : \"<<beta>>\"%n}");
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/default-preprocessed-request/http-request.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/default-preprocessed-request/http-request.adoc"),
|
||||
is(snippet(asciidoctor())
|
||||
.withContents(preprocessedRequest.content(prettyPrinted))));
|
||||
}
|
||||
@@ -555,9 +544,8 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
.content(original))));
|
||||
String prettyPrinted = String.format("{%n \"a\" : \"<<beta>>\",%n \"links\" : "
|
||||
+ "[ {%n \"rel\" : \"rel\",%n \"href\" : \"...\"%n } ]%n}");
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/preprocessed-response/http-response.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/preprocessed-response/http-response.adoc"),
|
||||
is(snippet(asciidoctor())
|
||||
.withContents(httpResponse(asciidoctor(), HttpStatus.OK)
|
||||
.header("Content-Type", "application/json;charset=UTF-8")
|
||||
@@ -571,8 +559,8 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
Pattern pattern = Pattern.compile("(\"alpha\")");
|
||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
|
||||
.apply(documentationConfiguration(this.restDocumentation)
|
||||
.operationPreprocessors().withResponseDefaults(
|
||||
prettyPrint(), maskLinks(), removeHeaders("a"),
|
||||
.operationPreprocessors().withResponseDefaults(prettyPrint(),
|
||||
maskLinks(), removeHeaders("a"),
|
||||
replacePattern(pattern, "\"<<beta>>\"")))
|
||||
.build();
|
||||
|
||||
@@ -582,9 +570,8 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
|
||||
String prettyPrinted = String.format("{%n \"a\" : \"<<beta>>\",%n \"links\" : "
|
||||
+ "[ {%n \"rel\" : \"rel\",%n \"href\" : \"...\"%n } ]%n}");
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/default-preprocessed-response/http-response.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/default-preprocessed-response/http-response.adoc"),
|
||||
is(snippet(asciidoctor())
|
||||
.withContents(httpResponse(asciidoctor(), HttpStatus.OK)
|
||||
.header("Content-Type", "application/json;charset=UTF-8")
|
||||
@@ -611,9 +598,8 @@ public class MockMvcRestDocumentationIntegrationTests {
|
||||
finally {
|
||||
Thread.currentThread().setContextClassLoader(previous);
|
||||
}
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/custom-snippet-template/curl-request.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/custom-snippet-template/curl-request.adoc"),
|
||||
is(snippet(asciidoctor()).withContents(equalTo("Custom curl request"))));
|
||||
|
||||
mockMvc.perform(get("/")).andDo(document("index", curlRequest(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -88,17 +88,15 @@ public class RestAssuredRestDocumentationConfigurerTests {
|
||||
assertThat(configuration, hasEntry(equalTo(WriterResolver.class.getName()),
|
||||
instanceOf(WriterResolver.class)));
|
||||
assertThat(configuration,
|
||||
hasEntry(
|
||||
equalTo(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_SNIPPETS),
|
||||
hasEntry(equalTo(
|
||||
RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_SNIPPETS),
|
||||
instanceOf(List.class)));
|
||||
assertThat(configuration,
|
||||
hasEntry(
|
||||
equalTo(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_OPERATION_REQUEST_PREPROCESSOR),
|
||||
instanceOf(OperationRequestPreprocessor.class)));
|
||||
assertThat(configuration,
|
||||
hasEntry(
|
||||
equalTo(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_OPERATION_RESPONSE_PREPROCESSOR),
|
||||
instanceOf(OperationResponsePreprocessor.class)));
|
||||
assertThat(configuration, hasEntry(equalTo(
|
||||
RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_OPERATION_REQUEST_PREPROCESSOR),
|
||||
instanceOf(OperationRequestPreprocessor.class)));
|
||||
assertThat(configuration, hasEntry(equalTo(
|
||||
RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_OPERATION_RESPONSE_PREPROCESSOR),
|
||||
instanceOf(OperationResponsePreprocessor.class)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -99,9 +99,8 @@ public class RestAssuredRestDocumentationIntegrationTests {
|
||||
.body("content").contentType(contentType).post("/").then()
|
||||
.statusCode(200);
|
||||
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/curl-snippet-with-content/curl-request.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/curl-snippet-with-content/curl-request.adoc"),
|
||||
is(snippet(asciidoctor()).withContents(codeBlock(asciidoctor(), "bash")
|
||||
.content(String.format("$ curl 'http://localhost:"
|
||||
+ tomcat.getPort() + "/' -i -X POST \\%n"
|
||||
@@ -118,11 +117,10 @@ public class RestAssuredRestDocumentationIntegrationTests {
|
||||
.filter(document("curl-snippet-with-cookies")).accept("application/json")
|
||||
.contentType(contentType).cookie("cookieName", "cookieVal").get("/")
|
||||
.then().statusCode(200);
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/curl-snippet-with-cookies/curl-request.adoc"),
|
||||
is(snippet(asciidoctor()).withContents(codeBlock(asciidoctor(),
|
||||
"bash").content(String.format("$ curl 'http://localhost:"
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/curl-snippet-with-cookies/curl-request.adoc"),
|
||||
is(snippet(asciidoctor()).withContents(codeBlock(asciidoctor(), "bash")
|
||||
.content(String.format("$ curl 'http://localhost:"
|
||||
+ tomcat.getPort() + "/' -i \\%n"
|
||||
+ " -H 'Accept: application/json' \\%n"
|
||||
+ " -H 'Content-Type: " + contentType + "' \\%n"
|
||||
@@ -137,9 +135,8 @@ public class RestAssuredRestDocumentationIntegrationTests {
|
||||
.accept("application/json").param("foo", "bar").param("a", "alpha")
|
||||
.post("/?foo=bar").then().statusCode(200);
|
||||
String contentType = "application/x-www-form-urlencoded; charset=ISO-8859-1";
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/curl-snippet-with-query-string/curl-request.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/curl-snippet-with-query-string/curl-request.adoc"),
|
||||
is(snippet(asciidoctor()).withContents(codeBlock(asciidoctor(), "bash")
|
||||
.content(String.format("$ curl " + "'http://localhost:"
|
||||
+ tomcat.getPort() + "/?foo=bar' -i -X POST \\%n"
|
||||
@@ -317,9 +314,8 @@ public class RestAssuredRestDocumentationIntegrationTests {
|
||||
.header("Content-Length", "13")
|
||||
.content("{\"a\":\"alpha\"}"))));
|
||||
String prettyPrinted = String.format("{%n \"a\" : \"<<beta>>\"%n}");
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/preprocessed-request/http-request.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/preprocessed-request/http-request.adoc"),
|
||||
is(snippet(asciidoctor())
|
||||
.withContents(httpRequest(asciidoctor(), RequestMethod.GET, "/")
|
||||
.header("b", "bravo")
|
||||
@@ -333,8 +329,8 @@ public class RestAssuredRestDocumentationIntegrationTests {
|
||||
Pattern pattern = Pattern.compile("(\"alpha\")");
|
||||
given().port(tomcat.getPort())
|
||||
.filter(documentationConfiguration(this.restDocumentation)
|
||||
.operationPreprocessors().withRequestDefaults(
|
||||
prettyPrint(), replacePattern(pattern, "\"<<beta>>\""),
|
||||
.operationPreprocessors().withRequestDefaults(prettyPrint(),
|
||||
replacePattern(pattern, "\"<<beta>>\""),
|
||||
modifyUris().removePort(),
|
||||
removeHeaders("a", HttpHeaders.CONTENT_LENGTH)))
|
||||
.header("a", "alpha").header("b", "bravo").contentType("application/json")
|
||||
@@ -342,15 +338,12 @@ public class RestAssuredRestDocumentationIntegrationTests {
|
||||
.filter(document("default-preprocessed-request")).get("/").then()
|
||||
.statusCode(200);
|
||||
String prettyPrinted = String.format("{%n \"a\" : \"<<beta>>\"%n}");
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/default-preprocessed-request/http-request.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/default-preprocessed-request/http-request.adoc"),
|
||||
is(snippet(asciidoctor())
|
||||
.withContents(
|
||||
httpRequest(asciidoctor(), RequestMethod.GET, "/")
|
||||
.header("b", "bravo")
|
||||
.header("Accept",
|
||||
MediaType.APPLICATION_JSON_VALUE)
|
||||
.withContents(httpRequest(asciidoctor(), RequestMethod.GET, "/")
|
||||
.header("b", "bravo")
|
||||
.header("Accept", MediaType.APPLICATION_JSON_VALUE)
|
||||
.header("Content-Type", "application/json; charset=UTF-8")
|
||||
.header("Host", "localhost").content(prettyPrinted))));
|
||||
}
|
||||
@@ -369,9 +362,8 @@ public class RestAssuredRestDocumentationIntegrationTests {
|
||||
.get("/").then().statusCode(200);
|
||||
String prettyPrinted = String.format("{%n \"a\" : \"<<beta>>\",%n \"links\" : "
|
||||
+ "[ {%n \"rel\" : \"rel\",%n \"href\" : \"...\"%n } ]%n}");
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/preprocessed-response/http-response.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/preprocessed-response/http-response.adoc"),
|
||||
is(snippet(asciidoctor())
|
||||
.withContents(httpResponse(asciidoctor(), HttpStatus.OK)
|
||||
.header("Foo", "https://api.example.com/foo/bar")
|
||||
@@ -386,8 +378,8 @@ public class RestAssuredRestDocumentationIntegrationTests {
|
||||
Pattern pattern = Pattern.compile("(\"alpha\")");
|
||||
given().port(tomcat.getPort())
|
||||
.filter(documentationConfiguration(this.restDocumentation)
|
||||
.operationPreprocessors()
|
||||
.withResponseDefaults(prettyPrint(), maskLinks(),
|
||||
.operationPreprocessors().withResponseDefaults(prettyPrint(),
|
||||
maskLinks(),
|
||||
removeHeaders("a", "Transfer-Encoding", "Date", "Server"),
|
||||
replacePattern(pattern, "\"<<beta>>\""),
|
||||
modifyUris().scheme("https").host("api.example.com")
|
||||
@@ -396,9 +388,8 @@ public class RestAssuredRestDocumentationIntegrationTests {
|
||||
.statusCode(200);
|
||||
String prettyPrinted = String.format("{%n \"a\" : \"<<beta>>\",%n \"links\" : "
|
||||
+ "[ {%n \"rel\" : \"rel\",%n \"href\" : \"...\"%n } ]%n}");
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/default-preprocessed-response/http-response.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/default-preprocessed-response/http-response.adoc"),
|
||||
is(snippet(asciidoctor())
|
||||
.withContents(httpResponse(asciidoctor(), HttpStatus.OK)
|
||||
.header("Foo", "https://api.example.com/foo/bar")
|
||||
@@ -424,9 +415,8 @@ public class RestAssuredRestDocumentationIntegrationTests {
|
||||
finally {
|
||||
Thread.currentThread().setContextClassLoader(previous);
|
||||
}
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/custom-snippet-template/curl-request.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/custom-snippet-template/curl-request.adoc"),
|
||||
is(snippet(asciidoctor()).withContents(equalTo("Custom curl request"))));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,8 @@ public final class WebTestClientOperationPreprocessorsConfigurer extends
|
||||
OperationPreprocessorsConfigurer<WebTestClientRestDocumentationConfigurer, WebTestClientOperationPreprocessorsConfigurer>
|
||||
implements ExchangeFilterFunction {
|
||||
|
||||
WebTestClientOperationPreprocessorsConfigurer(WebTestClientRestDocumentationConfigurer parent) {
|
||||
WebTestClientOperationPreprocessorsConfigurer(
|
||||
WebTestClientRestDocumentationConfigurer parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -67,7 +67,7 @@ public class WebTestClientResponseConverterTests {
|
||||
(req) -> ServerResponse.ok()
|
||||
.cookie(ResponseCookie.from("name", "value")
|
||||
.domain("localhost").httpOnly(true).build())
|
||||
.build()))
|
||||
.build()))
|
||||
.configureClient().baseUrl("http://localhost").build().get().uri("/foo")
|
||||
.exchange().expectBody().returnResult();
|
||||
OperationResponse response = this.converter.convert(result);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -133,9 +133,8 @@ public class WebTestClientRestDocumentationIntegrationTests {
|
||||
.consumeWith(document("request-parameters", requestParameters(
|
||||
parameterWithName("a").description("Alpha description"),
|
||||
parameterWithName("b").description("Bravo description"))));
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/request-parameters/request-parameters.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/request-parameters/request-parameters.adoc"),
|
||||
is(snippet(asciidoctor()).withContents(
|
||||
tableWithHeader(TemplateFormats.asciidoctor(), "Parameter",
|
||||
"Description").row("`a`", "Alpha description").row("`b`",
|
||||
@@ -176,9 +175,8 @@ public class WebTestClientRestDocumentationIntegrationTests {
|
||||
this.webTestClient.get().uri("/").cookie("cookieName", "cookieVal")
|
||||
.accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk()
|
||||
.expectBody().consumeWith(document("curl-snippet-with-cookies"));
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/curl-snippet-with-cookies/curl-request.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/curl-snippet-with-cookies/curl-request.adoc"),
|
||||
is(snippet(asciidoctor()).withContents(codeBlock(asciidoctor(), "bash")
|
||||
.content(String.format("$ curl 'https://api.example.com/' -i \\%n"
|
||||
+ " -H 'Accept: application/json' \\%n"
|
||||
@@ -190,9 +188,8 @@ public class WebTestClientRestDocumentationIntegrationTests {
|
||||
this.webTestClient.get().uri("/").cookie("cookieName", "cookieVal")
|
||||
.accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk()
|
||||
.expectBody().consumeWith(document("httpie-snippet-with-cookies"));
|
||||
assertThat(
|
||||
new File(
|
||||
"build/generated-snippets/httpie-snippet-with-cookies/httpie-request.adoc"),
|
||||
assertThat(new File(
|
||||
"build/generated-snippets/httpie-snippet-with-cookies/httpie-request.adoc"),
|
||||
is(snippet(asciidoctor())
|
||||
.withContents(codeBlock(asciidoctor(), "bash").content(
|
||||
String.format("$ http GET 'https://api.example.com/' \\%n"
|
||||
|
||||
Reference in New Issue
Block a user