Skip to content

Commit f9341e3

Browse files
committed
ACC-2100 reset mocks to fix tests when running them all together
1 parent be94921 commit f9341e3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

contentgrid-appserver-rest/src/test/java/com/contentgrid/appserver/rest/RelationRestControllerTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.Optional;
2424
import java.util.UUID;
2525
import java.util.stream.Stream;
26+
import org.junit.jupiter.api.AfterEach;
2627
import org.junit.jupiter.api.Nested;
2728
import org.junit.jupiter.api.Test;
2829
import org.junit.jupiter.params.ParameterizedTest;
@@ -79,6 +80,11 @@ public void dropTables(Application application) {
7980
}
8081
}
8182

83+
@AfterEach
84+
void resetMocks() {
85+
Mockito.reset(datamodelApi);
86+
}
87+
8288
@Nested
8389
class ValidInput {
8490

@@ -93,6 +99,9 @@ void followOneToOneRelation() throws Exception {
9399
.andExpect(status().isFound())
94100
.andExpect(
95101
header().string(HttpHeaders.LOCATION, "http://localhost/invoices/%s".formatted(targetId)));
102+
103+
Mockito.verify(datamodelApi)
104+
.findRelationTarget(TestApplication.APPLICATION, TestApplication.INVOICE_PREVIOUS, INVOICE_ID);
96105
}
97106

98107
@Test
@@ -106,6 +115,9 @@ void followManyToOneRelation() throws Exception {
106115
.andExpect(status().isFound())
107116
.andExpect(
108117
header().string(HttpHeaders.LOCATION, "http://localhost/persons/%s".formatted(targetId)));
118+
119+
Mockito.verify(datamodelApi)
120+
.findRelationTarget(TestApplication.APPLICATION, TestApplication.INVOICE_CUSTOMER, INVOICE_ID);
109121
}
110122

111123
@Test
@@ -121,6 +133,9 @@ void followOneToManyRelation() throws Exception {
121133
.andExpect(status().isFound())
122134
.andExpect(header().string(HttpHeaders.LOCATION,
123135
"http://localhost/invoices?page=0&customer=%s".formatted(PERSON_ID)));
136+
137+
Mockito.verify(datamodelApi)
138+
.findById(TestApplication.APPLICATION, TestApplication.PERSON, PERSON_ID);
124139
}
125140

126141
@Test
@@ -136,6 +151,9 @@ void followManyToManyRelation() throws Exception {
136151
.andExpect(status().isFound())
137152
.andExpect(header().string(HttpHeaders.LOCATION,
138153
"http://localhost/invoices?page=0&products=%s".formatted(PRODUCT_ID)));
154+
155+
Mockito.verify(datamodelApi)
156+
.findById(TestApplication.APPLICATION, TestApplication.PRODUCT, PRODUCT_ID);
139157
}
140158

141159
@Test

0 commit comments

Comments
 (0)