17
17
18
18
19
19
import static org .assertj .core .api .Assertions .assertThat ;
20
+ import static software .amazon .awssdk .codegen .TestStringUtils .toPlatformLfs ;
20
21
21
22
import org .junit .Test ;
22
23
import software .amazon .awssdk .codegen .docs .DocumentationBuilder ;
23
24
24
-
25
25
public class DocumentationBuilderTest {
26
26
27
27
@ Test
28
28
public void javadocFormattedCorrectly () {
29
29
String docs = new DocumentationBuilder ()
30
- .description ("Some service docs" )
31
- .param ("paramOne" , "param one docs" )
32
- .param ("paramTwo" , "param two docs" )
33
- .returns ("This returns something" )
34
- .syncThrows ("FooException" , "Thrown when foo happens" )
35
- .syncThrows ("BarException" , "Thrown when bar happens" )
36
- .tag ("sample" , "FooService.FooOperation" )
37
- .see ("this thing" )
38
- .see ("this other thing" )
39
- .build ();
40
- assertThat (docs ).isEqualTo ("Some service docs\n " +
41
- "\n " +
42
- "@param paramOne param one docs\n " +
43
- "@param paramTwo param two docs\n " +
44
- "@return This returns something\n " +
45
- "@throws FooException Thrown when foo happens\n " +
46
- "@throws BarException Thrown when bar happens\n " +
47
- "@sample FooService.FooOperation\n " +
48
- "@see this thing\n " +
49
- "@see this other thing\n " );
30
+ .description ("Some service docs" )
31
+ .param ("paramOne" , "param one docs" )
32
+ .param ("paramTwo" , "param two docs" )
33
+ .returns ("This returns something" )
34
+ .syncThrows ("FooException" , "Thrown when foo happens" )
35
+ .syncThrows ("BarException" , "Thrown when bar happens" )
36
+ .tag ("sample" , "FooService.FooOperation" )
37
+ .see ("this thing" )
38
+ .see ("this other thing" )
39
+ .build ();
40
+ assertThat (docs ).isEqualTo (toPlatformLfs ( "Some service docs\n " +
41
+ "\n " +
42
+ "@param paramOne param one docs\n " +
43
+ "@param paramTwo param two docs\n " +
44
+ "@return This returns something\n " +
45
+ "@throws FooException Thrown when foo happens\n " +
46
+ "@throws BarException Thrown when bar happens\n " +
47
+ "@sample FooService.FooOperation\n " +
48
+ "@see this thing\n " +
49
+ "@see this other thing\n " ) );
50
50
}
51
51
52
52
/**
@@ -57,55 +57,55 @@ public void javadocFormattedCorrectly() {
57
57
@ Test
58
58
public void asyncReturns_FormatsExceptionsInUnorderedList () {
59
59
String docs = new DocumentationBuilder ()
60
- .description ("Some service docs" )
61
- .param ("paramOne" , "param one docs" )
62
- .returns ("CompletableFuture of success" )
63
- .asyncThrows ("FooException" , "Foo docs" )
64
- .asyncThrows ("BarException" , "Bar docs" )
65
- .build ();
66
- assertThat (docs ).isEqualTo ("Some service docs\n " +
67
- "\n " +
68
- "@param paramOne param one docs\n " +
69
- "@return CompletableFuture of success<br/>\n " +
70
- "The CompletableFuture returned by this method can be completed exceptionally with the following exceptions.\n " +
71
- "<ul>\n " +
72
- "<li>FooException Foo docs</li>\n " +
73
- "<li>BarException Bar docs</li>\n " +
74
- "</ul>\n " );
60
+ .description ("Some service docs" )
61
+ .param ("paramOne" , "param one docs" )
62
+ .returns ("CompletableFuture of success" )
63
+ .asyncThrows ("FooException" , "Foo docs" )
64
+ .asyncThrows ("BarException" , "Bar docs" )
65
+ .build ();
66
+ assertThat (docs ).isEqualTo (toPlatformLfs ( "Some service docs\n " +
67
+ "\n " +
68
+ "@param paramOne param one docs\n " +
69
+ "@return CompletableFuture of success<br/>\n " +
70
+ "The CompletableFuture returned by this method can be completed exceptionally with the following exceptions.\n " +
71
+ "<ul>\n " +
72
+ "<li>FooException Foo docs</li>\n " +
73
+ "<li>BarException Bar docs</li>\n " +
74
+ "</ul>\n " ) );
75
75
76
76
}
77
77
78
78
@ Test
79
79
public void asyncReturnsWithoutDocsForSuccessReturn_FormatsExceptionsInUnorderedList () {
80
80
String docs = new DocumentationBuilder ()
81
- .description ("Some service docs" )
82
- .param ("paramOne" , "param one docs" )
83
- .asyncThrows ("FooException" , "Foo docs" )
84
- .asyncThrows ("BarException" , "Bar docs" )
85
- .build ();
86
- assertThat (docs ).isEqualTo ("Some service docs\n " +
87
- "\n " +
88
- "@param paramOne param one docs\n " +
89
- "@return A CompletableFuture indicating when result will be completed.<br/>\n " +
90
- "The CompletableFuture returned by this method can be completed exceptionally with the following exceptions.\n " +
91
- "<ul>\n " +
92
- "<li>FooException Foo docs</li>\n " +
93
- "<li>BarException Bar docs</li>\n " +
94
- "</ul>\n " );
81
+ .description ("Some service docs" )
82
+ .param ("paramOne" , "param one docs" )
83
+ .asyncThrows ("FooException" , "Foo docs" )
84
+ .asyncThrows ("BarException" , "Bar docs" )
85
+ .build ();
86
+ assertThat (docs ).isEqualTo (toPlatformLfs ( "Some service docs\n " +
87
+ "\n " +
88
+ "@param paramOne param one docs\n " +
89
+ "@return A CompletableFuture indicating when result will be completed.<br/>\n " +
90
+ "The CompletableFuture returned by this method can be completed exceptionally with the following exceptions.\n " +
91
+ "<ul>\n " +
92
+ "<li>FooException Foo docs</li>\n " +
93
+ "<li>BarException Bar docs</li>\n " +
94
+ "</ul>\n " ) );
95
95
}
96
96
97
97
@ Test
98
98
public void missingValuesAreNotPresent () {
99
99
String docs = new DocumentationBuilder ()
100
- .description ("Some service docs" )
101
- .build ();
102
- assertThat (docs ).isEqualTo ("Some service docs\n \n " );
100
+ .description ("Some service docs" )
101
+ .build ();
102
+ assertThat (docs ).isEqualTo (toPlatformLfs ( "Some service docs\n \n " ) );
103
103
}
104
104
105
105
@ Test
106
106
public void allValuesMissing_ProducesEmptyDocString () {
107
107
String docs = new DocumentationBuilder ()
108
- .build ();
108
+ .build ();
109
109
assertThat (docs ).isEqualTo ("" );
110
110
}
111
111
0 commit comments