Skip to content

Commit 6021c21

Browse files
authored
v1.4.1
1 parent 63cdefb commit 6021c21

23 files changed

+925
-656
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,28 @@
22

33
# Changelog
44

5+
## [1.4.1]
6+
7+
### Upgraded
8+
9+
- lombok 1.18.34 → 1.18.38
10+
- spring-boot 3.4.0 → 3.4.4
11+
12+
### Improved
13+
14+
- reduced number of transitive dependencies
15+
16+
### Fixed
17+
18+
- `answerAsObject(Class<T> expectedClass)` now returns `null` instead of throwing
19+
a `MismatchedInputException` when the HTTP response is `null`.
20+
- `answerAsList(Class<T> elementType)` now returns `null` instead of throwing
21+
a `MismatchedInputException` when the HTTP response is `null`.
22+
- `answerAsSet(Class<T> elementType)` now returns `null` instead of throwing
23+
a `MismatchedInputException` when the HTTP response is `null`.
24+
- `answerAsMap(Class<K> keyType, Class<V> valueType)` now returns `null` instead of throwing
25+
a `MismatchedInputException` when the HTTP response is `null`.
26+
527
## [1.4.0]
628

729
### Added

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ documentation of the classes.
4646
<dependency>
4747
<groupId>io.github.co-mmer</groupId>
4848
<artifactId>aaa-mockmvc</artifactId>
49-
<version>1.4.0</version>
49+
<version>1.4.1</version>
5050
<scope>test</scope>
5151
</dependency>
5252

@@ -191,7 +191,7 @@ public class AAAMockMvcConfig {
191191

192192
@Bean
193193
public ObjectMapper objectMapper() {
194-
// Custom MockMvc configuration
194+
// Custom ObjectMapper configuration
195195
return new ObjectMapper();
196196
}
197197
}

pom.xml

Lines changed: 78 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.co-mmer</groupId>
88
<artifactId>aaa-mockmvc</artifactId>
9-
<version>1.4.0</version>
9+
<version>1.4.1</version>
1010
<packaging>jar</packaging>
1111

1212
<name>AAA-MockMvc</name>
@@ -45,7 +45,7 @@
4545
<parent>
4646
<groupId>org.springframework.boot</groupId>
4747
<artifactId>spring-boot-starter-parent</artifactId>
48-
<version>3.3.4</version>
48+
<version>3.4.4</version>
4949
<relativePath/>
5050
</parent>
5151

@@ -62,28 +62,93 @@
6262
<dependency>
6363
<groupId>org.projectlombok</groupId>
6464
<artifactId>lombok</artifactId>
65-
<version>1.18.36</version>
65+
<version>1.18.38</version>
66+
<scope>provided</scope>
67+
</dependency>
68+
69+
<!-- jakarta -->
70+
<dependency>
71+
<groupId>jakarta.servlet</groupId>
72+
<artifactId>jakarta.servlet-api</artifactId>
73+
<version>6.1.0</version>
6674
<scope>provided</scope>
6775
</dependency>
6876

6977
<!-- Spring -->
7078
<dependency>
7179
<groupId>org.springframework.boot</groupId>
7280
<artifactId>spring-boot-starter-web</artifactId>
73-
<version>3.4.1</version>
81+
<scope>provided</scope>
82+
<exclusions>
83+
<exclusion>
84+
<groupId>org.springframework.boot</groupId>
85+
<artifactId>spring-boot-starter-logging</artifactId>
86+
</exclusion>
87+
<exclusion>
88+
<groupId>com.fasterxml.jackson.module</groupId>
89+
<artifactId>jackson-module-parameter-names</artifactId>
90+
</exclusion>
91+
<exclusion>
92+
<groupId>com.fasterxml.jackson.datatype</groupId>
93+
<artifactId>jackson-datatype-jsr310</artifactId>
94+
</exclusion>
95+
<exclusion>
96+
<groupId>com.fasterxml.jackson.datatype</groupId>
97+
<artifactId>jackson-datatype-jdk8</artifactId>
98+
</exclusion>
99+
<exclusion>
100+
<groupId>org.yaml</groupId>
101+
<artifactId>snakeyaml</artifactId>
102+
</exclusion>
103+
<exclusion>
104+
<groupId>org.springframework.boot</groupId>
105+
<artifactId>spring-boot-starter-tomcat</artifactId>
106+
</exclusion>
107+
<exclusion>
108+
<groupId>org.apache.tomcat.embed</groupId>
109+
<artifactId>tomcat-embed-el</artifactId>
110+
</exclusion>
111+
<exclusion>
112+
<groupId>org.apache.tomcat.embed</groupId>
113+
<artifactId>tomcat-embed-websocket</artifactId>
114+
</exclusion>
115+
<exclusion>
116+
<groupId>ch.qos.logback</groupId>
117+
<artifactId>logback-classic</artifactId>
118+
</exclusion>
119+
</exclusions>
74120
</dependency>
121+
75122
<dependency>
76123
<groupId>org.springframework.boot</groupId>
77124
<artifactId>spring-boot-starter-test</artifactId>
78-
<version>3.4.1</version>
79-
</dependency>
80-
81-
<!-- Mockito -->
82-
<dependency>
83-
<groupId>org.mockito</groupId>
84-
<artifactId>mockito-core</artifactId>
85-
<version>5.15.2</version>
86-
<scope>test</scope>
125+
<scope>provided</scope>
126+
<exclusions>
127+
<exclusion>
128+
<groupId>org.xmlunit</groupId>
129+
<artifactId>xmlunit-core</artifactId>
130+
</exclusion>
131+
<exclusion>
132+
<groupId>org.assertj</groupId>
133+
<artifactId>assertj-core</artifactId>
134+
</exclusion>
135+
<exclusion>
136+
<groupId>org.skyscreamer</groupId>
137+
<artifactId>jsonassert</artifactId>
138+
</exclusion>
139+
<exclusion>
140+
<groupId>jakarta.xml.bind</groupId>
141+
<artifactId>jakarta.xml.bind-api</artifactId>
142+
</exclusion>
143+
<exclusion>
144+
<groupId>org.awaitility</groupId>
145+
<artifactId>awaitility</artifactId>
146+
</exclusion>
147+
<exclusion>
148+
<groupId>org.ow2.asm</groupId>
149+
<artifactId>asm</artifactId>
150+
</exclusion>
151+
</exclusions>
87152
</dependency>
88153
</dependencies>
89154

@@ -99,7 +164,6 @@
99164
<extensions>true</extensions>
100165
<configuration>
101166
<publishingServerId>central</publishingServerId>
102-
<tokenAuth>true</tokenAuth>
103167
<autoPublish>true</autoPublish>
104168
<waitUntil>published</waitUntil>
105169
</configuration>

src/main/java/io/github/co_mmer/aaamockmvc/ej/test/web/asserts/bytes/TestAssert1Byte.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public interface TestAssert1Byte {
4747
* <p>If an error occurs, execution is terminated with a call to {@code Assertions.fail}, passing
4848
* the corresponding exception.
4949
*
50+
* <p>Note: The length refers to the number of bytes in the serialized HTTP response body using
51+
* UTF-8 encoding. For example, an empty JSON array {@code []} has a byte length of 2.
52+
*
5053
* @param length the expected length of the HTTP response content
5154
* @return the current instance of {@code TestAssert2Byte} for method chaining
5255
* @since 1.4.0

src/main/java/io/github/co_mmer/aaamockmvc/ej/test/web/asserts/bytes/TestAssertByteImpl.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.github.co_mmer.aaamockmvc.ej.test.web.asserts.bytes;
22

3+
import static io.github.co_mmer.aaamockmvc.ej.test.web.utils.StringUtils.EMPTY;
4+
import static io.github.co_mmer.aaamockmvc.ej.test.web.utils.StringUtils.EMPTY_ARRAY;
35
import static org.hamcrest.MatcherAssert.assertThat;
46
import static org.hamcrest.Matchers.anyOf;
57
import static org.hamcrest.Matchers.is;
@@ -8,7 +10,6 @@
810
import io.github.co_mmer.aaamockmvc.ej.test.web.asserts.head.TestAssertHead;
911
import io.github.co_mmer.aaamockmvc.ej.test.web.asserts.head.TestAssertHeadImpl;
1012
import lombok.NonNull;
11-
import org.apache.logging.log4j.util.Strings;
1213
import org.junit.jupiter.api.Assertions;
1314
import org.springframework.mock.web.MockHttpServletResponse;
1415
import org.springframework.test.web.servlet.ResultActions;
@@ -60,7 +61,7 @@ public TestAssertByteImpl(@NonNull ResultActions actions) {
6061
@Override
6162
public TestAssert2Byte assertByteNotEmpty() {
6263
try {
63-
assertThat(this.response.getContentAsString(), not(anyOf(is(Strings.EMPTY), is("[]"))));
64+
assertThat(this.response.getContentAsString(), not(anyOf(is(EMPTY), is(EMPTY_ARRAY))));
6465
} catch (Exception e) {
6566
Assertions.fail(e);
6667
}
@@ -79,7 +80,7 @@ public TestAssert2Byte assertByteNotEmpty() {
7980
@Override
8081
public TestAssertLByte assertByteEmpty() {
8182
try {
82-
assertThat(this.response.getContentAsString(), anyOf(is(Strings.EMPTY), is("[]")));
83+
assertThat(this.response.getContentAsString(), anyOf(is(EMPTY), is(EMPTY_ARRAY)));
8384
} catch (Exception e) {
8485
Assertions.fail(e);
8586
}
@@ -93,14 +94,17 @@ public TestAssertLByte assertByteEmpty() {
9394
* <p>If an error occurs, execution is terminated with a call to {@code Assertions.fail}, passing
9495
* the corresponding exception.
9596
*
97+
* <p>Note: The length refers to the number of bytes in the serialized HTTP response body using
98+
* UTF-8 encoding. For example, an empty JSON array {@code []} has a byte length of 2.
99+
*
96100
* @param length the expected length of the HTTP response content
97101
* @return the current instance of {@code TestAssert2Byte} for method chaining
98102
* @since 1.4.0
99103
*/
100104
@Override
101105
public TestAssert2Byte assertByteLength(int length) {
102106
try {
103-
assertThat(this.response.getContentAsByteArray().length, is(length));
107+
assertThat(this.response.getContentAsString().length(), is(length));
104108
} catch (Exception e) {
105109
Assertions.fail(e);
106110
}

src/main/java/io/github/co_mmer/aaamockmvc/ej/test/web/asserts/collection/TestAssertCollectionImpl.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import static io.github.co_mmer.aaamockmvc.ej.test.web.asserts.match.TestAssertMatchType.NONE;
66
import static io.github.co_mmer.aaamockmvc.ej.test.web.asserts.string.TestArrangeNormalizer.normalizeAsObjects;
77
import static io.github.co_mmer.aaamockmvc.ej.test.web.asserts.string.TestArrangeNormalizer.normalizeCollection;
8-
import static io.github.co_mmer.aaamockmvc.ej.test.web.mapper.TestGenericMapper.mapToList;
8+
import static io.github.co_mmer.aaamockmvc.ej.test.web.mapper.TestGenericMapper.mapToCollection;
9+
import static io.github.co_mmer.aaamockmvc.ej.test.web.utils.StringUtils.EMPTY;
10+
import static io.github.co_mmer.aaamockmvc.ej.test.web.utils.StringUtils.EMPTY_ARRAY;
911
import static org.hamcrest.MatcherAssert.assertThat;
1012
import static org.hamcrest.Matchers.anyOf;
1113
import static org.hamcrest.Matchers.containsInAnyOrder;
@@ -17,7 +19,7 @@
1719
import com.fasterxml.jackson.databind.ObjectMapper;
1820
import io.github.co_mmer.aaamockmvc.ej.test.web.asserts.head.TestAssertHead;
1921
import io.github.co_mmer.aaamockmvc.ej.test.web.asserts.head.TestAssertHeadImpl;
20-
import io.github.co_mmer.aaamockmvc.ej.test.web.asserts.match.TestAssertMatchList;
22+
import io.github.co_mmer.aaamockmvc.ej.test.web.asserts.match.TestAssertMatchCollection;
2123
import io.github.co_mmer.aaamockmvc.ej.test.web.asserts.match.TestAssertMatchType;
2224
import io.github.co_mmer.aaamockmvc.ej.test.web.mapper.exception.TestGenericMapperException;
2325
import java.util.Arrays;
@@ -26,7 +28,6 @@
2628
import java.util.function.BiConsumer;
2729
import java.util.function.Predicate;
2830
import lombok.NonNull;
29-
import org.apache.logging.log4j.util.Strings;
3031
import org.junit.jupiter.api.Assertions;
3132
import org.springframework.mock.web.MockHttpServletResponse;
3233
import org.springframework.test.web.servlet.ResultActions;
@@ -113,7 +114,7 @@ public TestAssertCollectionImpl(
113114
@Override
114115
public TestAssert2Collection assertCollectionNotEmpty() {
115116
try {
116-
assertThat(this.response.getContentAsString(), not(anyOf(is(Strings.EMPTY), is("[]"))));
117+
assertThat(this.response.getContentAsString(), not(anyOf(is(EMPTY), is(EMPTY_ARRAY))));
117118
} catch (Exception e) {
118119
Assertions.fail(e);
119120
}
@@ -133,7 +134,7 @@ public TestAssert2Collection assertCollectionNotEmpty() {
133134
@Override
134135
public TestAssertLCollection assertCollectionEmpty() {
135136
try {
136-
assertThat(this.response.getContentAsString(), anyOf(is(Strings.EMPTY), is("[]")));
137+
assertThat(this.response.getContentAsString(), anyOf(is(EMPTY), is(EMPTY_ARRAY)));
137138
} catch (Exception e) {
138139
Assertions.fail(e);
139140
}
@@ -193,7 +194,7 @@ private <T> void performAssertion(
193194
BiConsumer<Collection<T>, Collection<T>> assertion) {
194195

195196
try {
196-
var actual = mapToList(this.objectMapper, this.actions.andReturn(), expectedClass);
197+
var actual = mapToCollection(this.objectMapper, this.actions.andReturn(), expectedClass);
197198
assertion.accept(actual, expectedResponse);
198199
} catch (TestGenericMapperException e) {
199200
Assertions.fail(e);
@@ -402,11 +403,11 @@ public final <T> TestAssert4Collection assertCollectionMatchAll(
402403
}
403404

404405
private <T> void assertCollectionMatch(
405-
TestAssertMatchType matchType, Class<T> expectedClass, List<Predicate<T>> conditions) {
406+
TestAssertMatchType matchType, Class<T> expectedClass, Collection<Predicate<T>> conditions) {
406407

407408
try {
408-
var actual = mapToList(this.objectMapper, this.actions.andReturn(), expectedClass);
409-
TestAssertMatchList.assertMatch(matchType, actual, conditions);
409+
var actual = mapToCollection(this.objectMapper, this.actions.andReturn(), expectedClass);
410+
TestAssertMatchCollection.assertMatch(matchType, actual, conditions);
410411
} catch (TestGenericMapperException e) {
411412
Assertions.fail(e);
412413
}

src/main/java/io/github/co_mmer/aaamockmvc/ej/test/web/asserts/map/TestAssertMapImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import static io.github.co_mmer.aaamockmvc.ej.test.web.asserts.string.TestArrangeNormalizer.normalizeMap;
44
import static io.github.co_mmer.aaamockmvc.ej.test.web.mapper.TestGenericMapper.mapToMap;
5+
import static io.github.co_mmer.aaamockmvc.ej.test.web.utils.StringUtils.EMPTY;
6+
import static io.github.co_mmer.aaamockmvc.ej.test.web.utils.StringUtils.EMPTY_OBJECT;
57
import static org.hamcrest.MatcherAssert.assertThat;
68
import static org.hamcrest.Matchers.anyOf;
79
import static org.hamcrest.Matchers.is;
@@ -14,7 +16,6 @@
1416
import io.github.co_mmer.aaamockmvc.ej.test.web.mapper.exception.TestGenericMapperException;
1517
import java.util.Map;
1618
import lombok.NonNull;
17-
import org.apache.logging.log4j.util.Strings;
1819
import org.junit.jupiter.api.Assertions;
1920
import org.springframework.mock.web.MockHttpServletResponse;
2021
import org.springframework.test.web.servlet.ResultActions;
@@ -71,7 +72,7 @@ public TestAssertMapImpl(@NonNull ResultActions actions, @NonNull ObjectMapper o
7172
@Override
7273
public TestAssert2Map assertMapNotEmpty() {
7374
try {
74-
assertThat(this.response.getContentAsString(), not(anyOf(is(Strings.EMPTY), is("{}"))));
75+
assertThat(this.response.getContentAsString(), not(anyOf(is(EMPTY), is(EMPTY_OBJECT))));
7576
} catch (Exception e) {
7677
Assertions.fail(e);
7778
}
@@ -91,7 +92,7 @@ public TestAssert2Map assertMapNotEmpty() {
9192
@Override
9293
public TestAssertLMap assertMapEmpty() {
9394
try {
94-
assertThat(this.response.getContentAsString(), anyOf(is(Strings.EMPTY), is("{}")));
95+
assertThat(this.response.getContentAsString(), anyOf(is(EMPTY), is(EMPTY_OBJECT)));
9596
} catch (Exception e) {
9697
Assertions.fail(e);
9798
}

0 commit comments

Comments
 (0)