Skip to content

Commit 8930f7c

Browse files
committed
introducing Mockito
1 parent 2ffd128 commit 8930f7c

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

jmolecules-bytebuddy-tests/jmolecules-bytebuddy-tests-vaadoo/pom.xml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
<dependencies>
1515

16-
<dependency>
17-
<groupId>org.jmolecules</groupId>
18-
<artifactId>jmolecules-ddd</artifactId>
19-
<version>${jmolecules.version}</version>
20-
</dependency>
16+
<dependency>
17+
<groupId>org.jmolecules</groupId>
18+
<artifactId>jmolecules-ddd</artifactId>
19+
<version>${jmolecules.version}</version>
20+
</dependency>
2121

2222
<!-- nodep artifact provides the plugin registration and minimal
2323
classes required for classpath discovery by the byte-buddy
@@ -36,6 +36,12 @@
3636
<version>${project.version}</version>
3737
</dependency>
3838

39+
<dependency>
40+
<groupId>org.mockito</groupId>
41+
<artifactId>mockito-core</artifactId>
42+
<scope>test</scope>
43+
</dependency>
44+
3945
</dependencies>
4046

4147
<build>

jmolecules-bytebuddy-tests/jmolecules-bytebuddy-tests-vaadoo/src/test/java/org/jmolecules/bytebuddy/JMoleculesVaadooPluginTests.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import static org.assertj.core.api.Assertions.assertThatException;
2121
import static org.assertj.core.api.Assertions.assertThatNoException;
2222
import static org.assertj.core.api.Assertions.assertThatRuntimeException;
23+
import static org.mockito.Mockito.mock;
24+
import static org.mockito.Mockito.verifyNoInteractions;
2325

2426
import java.io.File;
2527
import java.lang.reflect.Constructor;
@@ -37,6 +39,7 @@
3739
import org.jmolecules.bytebuddy.testclasses.ValueObjectWithAttribute;
3840
import org.junit.jupiter.api.Test;
3941
import org.junit.jupiter.api.io.TempDir;
42+
import org.mockito.Mockito;
4043

4144
import example.SampleValueObject;
4245
import example.SampleValueObjectWithSideEffect;
@@ -130,10 +133,11 @@ void doesNotThrowExceptionOnNonNullValueAndAssignsValues() {
130133

131134
@Test
132135
void mustNotCallAddOnListWithNull() {
133-
List<String> list = new ArrayList<>();
134-
assertThatRuntimeException().isThrownBy(() -> new SampleValueObjectWithSideEffect(list, null))
136+
@SuppressWarnings("unchecked")
137+
List<String> listMock = mock(List.class);
138+
assertThatRuntimeException().isThrownBy(() -> new SampleValueObjectWithSideEffect(listMock, null))
135139
.withMessage("toAdd must not be null");
136-
assertThat(list).isEmpty();
140+
verifyNoInteractions(listMock);
137141
}
138142

139143
}

0 commit comments

Comments
 (0)