@@ -43,19 +43,35 @@ void actualStringCanBeNull() {
43
43
}
44
44
45
45
@ Test
46
- void isEqualWhenSameShouldPass () {
46
+ void isEqualWhenActualIsNullStringShouldFail () {
47
+ assertThatExceptionOfType (AssertionError .class )
48
+ .isThrownBy (() -> assertThat (null ).isEqualTo ("text/html" ))
49
+ .withMessageContaining ("Media type" );
50
+ }
51
+
52
+ @ Test
53
+ void isEqualWhenSameStringShouldPass () {
47
54
assertThat (mediaType ("application/json" )).isEqualTo ("application/json" );
48
55
}
49
56
50
57
@ Test
51
- void isEqualWhenDifferentShouldFail () {
58
+ void isEqualWhenDifferentStringShouldFail () {
52
59
assertThatExceptionOfType (AssertionError .class )
53
60
.isThrownBy (() -> assertThat (mediaType ("application/json" )).isEqualTo ("text/html" ))
54
61
.withMessageContaining ("Media type" );
55
62
}
56
63
57
64
@ Test
58
- void isEqualWhenActualIsNullShouldFail () {
65
+ void isEqualInvalidStringShouldFail () {
66
+ assertThatExceptionOfType (AssertionError .class )
67
+ .isThrownBy (() -> assertThat (mediaType ("application/json" )).isEqualTo ("example of a bad value" ))
68
+ .withMessageContaining ("[Media type]" )
69
+ .withMessageEndingWith ("To be a valid media type but got:\n " +
70
+ " \" Invalid mime type \" example of a bad value\" : does not contain '/'\" \n " );
71
+ }
72
+
73
+ @ Test
74
+ void isEqualWhenActualIsNullTypeShouldFail () {
59
75
assertThatExceptionOfType (AssertionError .class )
60
76
.isThrownBy (() -> assertThat (null ).isEqualTo (MediaType .APPLICATION_JSON ))
61
77
.withMessageContaining ("Media type" );
@@ -73,6 +89,49 @@ void isEqualWhenDifferentTypeShouldFail() {
73
89
.withMessageContaining ("Media type" );
74
90
}
75
91
92
+ @ Test
93
+ void isNotEqualWhenActualIsNullStringShouldPass () {
94
+ assertThat (null ).isNotEqualTo ("application/json" );
95
+ }
96
+
97
+ @ Test
98
+ void isNotEqualWhenDifferentStringShouldPass () {
99
+ assertThat (mediaType ("application/json" )).isNotEqualTo ("text/html" );
100
+ }
101
+
102
+ @ Test
103
+ void isNotEqualWhenSameStringShouldFail () {
104
+ assertThatExceptionOfType (AssertionError .class )
105
+ .isThrownBy (() -> assertThat (mediaType ("application/json" )).isNotEqualTo ("application/json" ))
106
+ .withMessageContaining ("Media type" );
107
+ }
108
+
109
+ @ Test
110
+ void isNotEqualInvalidStringShouldFail () {
111
+ assertThatExceptionOfType (AssertionError .class )
112
+ .isThrownBy (() -> assertThat (mediaType ("application/json" )).isNotEqualTo ("example of a bad value" ))
113
+ .withMessageContaining ("[Media type]" )
114
+ .withMessageEndingWith ("To be a valid media type but got:\n " +
115
+ " \" Invalid mime type \" example of a bad value\" : does not contain '/'\" \n " );
116
+ }
117
+
118
+ @ Test
119
+ void isNotEqualWhenActualIsNullTypeShouldPass () {
120
+ assertThat (null ).isNotEqualTo (MediaType .APPLICATION_JSON );
121
+ }
122
+
123
+ @ Test
124
+ void isNotEqualWhenDifferentTypeShouldPass () {
125
+ assertThat (mediaType ("application/json" )).isNotEqualTo (MediaType .TEXT_HTML );
126
+ }
127
+
128
+ @ Test
129
+ void isNotEqualWhenSameTypeShouldFail () {
130
+ assertThatExceptionOfType (AssertionError .class )
131
+ .isThrownBy (() -> assertThat (mediaType ("application/json" )).isNotEqualTo (MediaType .APPLICATION_JSON ))
132
+ .withMessageContaining ("Media type" );
133
+ }
134
+
76
135
@ Test
77
136
void isCompatibleWhenSameShouldPass () {
78
137
assertThat (mediaType ("application/json" )).isCompatibleWith ("application/json" );
0 commit comments