File tree Expand file tree Collapse file tree 3 files changed +31
-4
lines changed
main/java/io/github/malczuuu/problem4j/core
test/java/io/github/malczuuu/problem4j/core Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ public interface ProblemBuilder {
2626 * @param type string URI identifying the problem type
2727 * @return this builder instance for chaining
2828 * @throws IllegalArgumentException if the string is not a valid URI
29- * @throws NullPointerException if the string is null
3029 */
3130 ProblemBuilder type (String type );
3231
@@ -77,7 +76,6 @@ public interface ProblemBuilder {
7776 * @param instance string URI identifying the problem occurrence
7877 * @return this builder instance for chaining
7978 * @throws IllegalArgumentException if the string is not a valid URI
80- * @throws NullPointerException if the string is null
8179 */
8280 ProblemBuilder instance (String instance );
8381
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ public ProblemBuilder type(URI type) {
2727
2828 @ Override
2929 public ProblemBuilder type (String type ) {
30- return type (URI .create (type ));
30+ return type != null ? type (URI .create (type )) : type (( URI ) null );
3131 }
3232
3333 @ Override
@@ -67,7 +67,7 @@ public ProblemBuilder instance(URI instance) {
6767
6868 @ Override
6969 public ProblemBuilder instance (String instance ) {
70- return instance (URI .create (instance ));
70+ return instance != null ? instance (URI .create (instance )) : instance (( URI ) null );
7171 }
7272
7373 @ Override
Original file line number Diff line number Diff line change 22
33import static org .assertj .core .api .Assertions .assertThat ;
44
5+ import java .net .URI ;
56import java .util .Arrays ;
67import java .util .Collection ;
78import java .util .HashMap ;
1011
1112class ProblemBuilderImplTests {
1213
14+ @ Test
15+ void givenNullURIType_shouldNotSetIt () {
16+ Problem problem = Problem .builder ().type ((URI ) null ).build ();
17+
18+ assertThat (problem .getType ()).isEqualTo (Problem .BLANK_TYPE );
19+ }
20+
21+ @ Test
22+ void givenNullStringType_shouldNotSetIt () {
23+ Problem problem = Problem .builder ().type ((String ) null ).build ();
24+
25+ assertThat (problem .getType ()).isEqualTo (Problem .BLANK_TYPE );
26+ }
27+
1328 @ Test
1429 void givenNullProblemStatus_shouldNotSetTitleOrStatus () {
1530 Problem problem = Problem .builder ().status (null ).build ();
@@ -18,6 +33,20 @@ void givenNullProblemStatus_shouldNotSetTitleOrStatus() {
1833 assertThat (problem .getTitle ()).isNull ();
1934 }
2035
36+ @ Test
37+ void givenNullURIInstance_shouldNotSetIt () {
38+ Problem problem = Problem .builder ().instance ((URI ) null ).build ();
39+
40+ assertThat (problem .getInstance ()).isNull ();
41+ }
42+
43+ @ Test
44+ void givenNullStringInstance_shouldNotSetIt () {
45+ Problem problem = Problem .builder ().instance ((String ) null ).build ();
46+
47+ assertThat (problem .getInstance ()).isNull ();
48+ }
49+
2150 @ Test
2251 void givenNullNameExtension_shouldIgnoreIt () {
2352 Problem problem = Problem .builder ().extension (null , "value" ).build ();
You can’t perform that action at this time.
0 commit comments