2828 * tests help ensure that the coverage reports correctly reflect different execution paths, edge
2929 * cases, and instrumentation scenarios.
3030 */
31- class ProblemImplTests {
31+ class AbstractProblemTest {
3232
3333 @ Test
3434 void givenAllFieldsPopulated_whenToString_thenContainsAllFieldsProperly () {
@@ -43,7 +43,7 @@ void givenAllFieldsPopulated_whenToString_thenContainsAllFieldsProperly() {
4343 extensions .put ("booleanExt" , true );
4444 extensions .put ("objectExt" , new DummyObject ("foo" ));
4545
46- ProblemImpl problem = new ProblemImpl (type , title , status , detail , instance , extensions );
46+ Problem problem = new AbstractProblem (type , title , status , detail , instance , extensions ) {} ;
4747
4848 String result = problem .toString ();
4949
@@ -62,7 +62,7 @@ void givenAllFieldsPopulated_whenToString_thenContainsAllFieldsProperly() {
6262 @ Test
6363 void givenNullExtensionsAndNullableFields_whenToString_thenOmitsNulls () {
6464 Map <String , Object > extensions = new HashMap <>();
65- ProblemImpl problem = new ProblemImpl (null , null , 200 , null , null , extensions );
65+ Problem problem = new AbstractProblem (null , null , 200 , null , null , extensions ) {} ;
6666
6767 String result = problem .toString ();
6868
@@ -75,7 +75,7 @@ void givenOnlyStringExtensions_whenToString_thenContainsQuotedStrings() {
7575 extensions .put ("ext1" , "value1" );
7676 extensions .put ("ext2" , "value2" );
7777
78- ProblemImpl problem = new ProblemImpl (null , null , 0 , null , null , extensions );
78+ Problem problem = new AbstractProblem (null , null , 0 , null , null , extensions ) {} ;
7979
8080 String result = problem .toString ();
8181
@@ -89,7 +89,7 @@ void givenOnlyNumberExtensions_whenToString_thenContainsNumbers() {
8989 extensions .put ("ext1" , 123 );
9090 extensions .put ("ext2" , 456.78 );
9191
92- ProblemImpl problem = new ProblemImpl (null , null , 0 , null , null , extensions );
92+ Problem problem = new AbstractProblem (null , null , 0 , null , null , extensions ) {} ;
9393
9494 String result = problem .toString ();
9595
@@ -103,7 +103,7 @@ void givenOnlyBooleanExtensions_whenToString_thenContainsBooleans() {
103103 extensions .put ("flag1" , true );
104104 extensions .put ("flag2" , false );
105105
106- ProblemImpl problem = new ProblemImpl (null , null , 0 , null , null , extensions );
106+ Problem problem = new AbstractProblem (null , null , 0 , null , null , extensions ) {} ;
107107
108108 String result = problem .toString ();
109109
@@ -116,7 +116,7 @@ void givenNonPrimitiveExtension_whenToString_thenUsesClassNamePrefix() {
116116 Map <String , Object > extensions = new HashMap <>();
117117 extensions .put ("obj" , new DummyObject ("bar" ));
118118
119- ProblemImpl problem = new ProblemImpl (null , null , 0 , null , null , extensions );
119+ Problem problem = new AbstractProblem (null , null , 0 , null , null , extensions ) {} ;
120120
121121 String result = problem .toString ();
122122
@@ -128,7 +128,7 @@ void givenStringWithSpecialCharacters_whenToString_thenProperlyEscapes() {
128128 Map <String , Object > extensions = new HashMap <>();
129129 extensions .put ("ext" , "a\" b\\ c\n d" );
130130
131- ProblemImpl problem = new ProblemImpl (null , null , 0 , null , null , extensions );
131+ Problem problem = new AbstractProblem (null , null , 0 , null , null , extensions ) {} ;
132132
133133 String result = problem .toString ();
134134
@@ -137,10 +137,10 @@ void givenStringWithSpecialCharacters_whenToString_thenProperlyEscapes() {
137137
138138 @ Test
139139 void givenTwoEqualProblems_shouldBeEqual () {
140- ProblemImpl problem1 =
141- new ProblemImpl (null , "title" , 404 , "detail" , null , mapOf ("key" , "value" ));
142- ProblemImpl problem2 =
143- new ProblemImpl (null , "title" , 404 , "detail" , null , mapOf ("key" , "value" ));
140+ Problem problem1 =
141+ new AbstractProblem (null , "title" , 404 , "detail" , null , mapOf ("key" , "value" )) {} ;
142+ Problem problem2 =
143+ new AbstractProblem (null , "title" , 404 , "detail" , null , mapOf ("key" , "value" )) {} ;
144144
145145 assertThat (problem1 ).isEqualTo (problem2 );
146146 }
@@ -150,53 +150,55 @@ void givenSameProblems_shouldBeEqual() {
150150 Object problem ;
151151 Object other ;
152152
153- problem = other = new ProblemImpl (null , "title" , 404 , "detail" , null , mapOf ("key" , "value" ));
153+ problem =
154+ other = new AbstractProblem (null , "title" , 404 , "detail" , null , mapOf ("key" , "value" )) {};
154155
155156 assertThat (problem ).isEqualTo (other );
156157 }
157158
158159 @ Test
159160 void givenTwoDifferentProblems_shouldNotBeEqual () {
160- ProblemImpl problem1 =
161- new ProblemImpl (null , "title1" , 404 , "detail1" , null , mapOf ("key" , "value1" ));
162- ProblemImpl problem2 =
163- new ProblemImpl (null , "title2" , 500 , "detail2" , null , mapOf ("key" , "value2" ));
161+ Problem problem1 =
162+ new AbstractProblem (null , "title1" , 404 , "detail1" , null , mapOf ("key" , "value1" )) {} ;
163+ Problem problem2 =
164+ new AbstractProblem (null , "title2" , 500 , "detail2" , null , mapOf ("key" , "value2" )) {} ;
164165
165166 assertThat (problem1 ).isNotEqualTo (problem2 );
166167 }
167168
168169 @ Test
169170 void givenProblemAndDifferentObject_shouldNotBeEqual () {
170- Object problem = new ProblemImpl (null , "title1" , 404 , "detail1" , null , mapOf ("key" , "value" ));
171+ Object problem =
172+ new AbstractProblem (null , "title1" , 404 , "detail1" , null , mapOf ("key" , "value" )) {};
171173 Object differentObject = "always wanted to be a problem" ;
172174
173175 assertThat (problem ).isNotEqualTo (differentObject );
174176 }
175177
176178 @ Test
177179 void givenTwoEqualProblems_shouldHaveSameHashCode () {
178- ProblemImpl problem1 =
179- new ProblemImpl (null , "title" , 404 , "detail" , null , mapOf ("key" , "value" ));
180- ProblemImpl problem2 =
181- new ProblemImpl (null , "title" , 404 , "detail" , null , mapOf ("key" , "value" ));
180+ Problem problem1 =
181+ new AbstractProblem (null , "title" , 404 , "detail" , null , mapOf ("key" , "value" )) {} ;
182+ Problem problem2 =
183+ new AbstractProblem (null , "title" , 404 , "detail" , null , mapOf ("key" , "value" )) {} ;
182184
183185 assertThat (problem1 .hashCode ()).isEqualTo (problem2 .hashCode ());
184186 }
185187
186188 @ Test
187189 void givenTwoDifferentProblems_shouldHaveDifferentHashCodes () {
188- ProblemImpl problem1 =
189- new ProblemImpl (null , "title1" , 404 , "detail1" , null , mapOf ("key" , "value1" ));
190- ProblemImpl problem2 =
191- new ProblemImpl (null , "title2" , 500 , "detail2" , null , mapOf ("key" , "value2" ));
190+ Problem problem1 =
191+ new AbstractProblem (null , "title1" , 404 , "detail1" , null , mapOf ("key" , "value1" )) {} ;
192+ Problem problem2 =
193+ new AbstractProblem (null , "title2" , 500 , "detail2" , null , mapOf ("key" , "value2" )) {} ;
192194
193195 assertThat (problem1 .hashCode ()).isNotEqualTo (problem2 .hashCode ());
194196 }
195197
196198 @ Test
197199 void givenTwoEqualExtensions_shouldBeEqual () {
198- ProblemImpl . ExtensionImpl ext1 = new ProblemImpl . ExtensionImpl ("key" , "value" );
199- ProblemImpl . ExtensionImpl ext2 = new ProblemImpl . ExtensionImpl ("key" , "value" );
200+ Problem . Extension ext1 = new AbstractProblem . AbstractExtension ("key" , "value" ) {} ;
201+ Problem . Extension ext2 = new AbstractProblem . AbstractExtension ("key" , "value" ) {} ;
200202
201203 assertThat (ext1 ).isEqualTo (ext2 );
202204 }
@@ -213,32 +215,32 @@ void givenSameExtensions_shouldBeEqual() {
213215
214216 @ Test
215217 void givenTwoDifferentExtensions_shouldNotBeEqual () {
216- ProblemImpl . ExtensionImpl ext1 = new ProblemImpl . ExtensionImpl ("key1" , "value1" );
217- ProblemImpl . ExtensionImpl ext2 = new ProblemImpl . ExtensionImpl ("key2" , "value2" );
218+ Problem . Extension ext1 = new AbstractProblem . AbstractExtension ("key1" , "value1" ) {} ;
219+ Problem . Extension ext2 = new AbstractProblem . AbstractExtension ("key2" , "value2" ) {} ;
218220
219221 assertThat (ext1 ).isNotEqualTo (ext2 );
220222 }
221223
222224 @ Test
223225 void givenExtensionAndDifferentObject_shouldNotBeEqual () {
224- Object ext = new ProblemImpl . ExtensionImpl ("key" , "value" );
226+ Object ext = new AbstractProblem . AbstractExtension ("key" , "value" ) {} ;
225227 Object differentObject = "always wanted to be a problem" ;
226228
227229 assertThat (ext ).isNotEqualTo (differentObject );
228230 }
229231
230232 @ Test
231233 void givenTwoEqualExtensions_shouldHaveSameHashCode () {
232- ProblemImpl . ExtensionImpl ext1 = new ProblemImpl . ExtensionImpl ("key" , "value" );
233- ProblemImpl . ExtensionImpl ext2 = new ProblemImpl . ExtensionImpl ("key" , "value" );
234+ Problem . Extension ext1 = new AbstractProblem . AbstractExtension ("key" , "value" ) {} ;
235+ Problem . Extension ext2 = new AbstractProblem . AbstractExtension ("key" , "value" ) {} ;
234236
235237 assertThat (ext1 .hashCode ()).isEqualTo (ext2 .hashCode ());
236238 }
237239
238240 @ Test
239241 void givenTwoDifferentExtensions_shouldHaveDifferentHashCodes () {
240- ProblemImpl . ExtensionImpl ext1 = new ProblemImpl . ExtensionImpl ("key1" , "value1" );
241- ProblemImpl . ExtensionImpl ext2 = new ProblemImpl . ExtensionImpl ("key2" , "value2" );
242+ Problem . Extension ext1 = new AbstractProblem . AbstractExtension ("key1" , "value1" ) {} ;
243+ Problem . Extension ext2 = new AbstractProblem . AbstractExtension ("key2" , "value2" ) {} ;
242244
243245 assertThat (ext1 .hashCode ()).isNotEqualTo (ext2 .hashCode ());
244246 }
0 commit comments