Skip to content

Commit c603210

Browse files
committed
Capture & Replay Integration Test for GroupService
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
1 parent b7379db commit c603210

File tree

2 files changed

+88
-3
lines changed

2 files changed

+88
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,58 @@
11
package io.securecodebox.persistence.defectdojo.service;
22

3+
import io.securecodebox.persistence.defectdojo.model.Group;
34
import org.junit.jupiter.api.Test;
45

5-
import static org.junit.jupiter.api.Assertions.*;
6+
import java.io.IOException;
7+
import java.net.URISyntaxException;
8+
import java.util.List;
9+
10+
import static com.github.tomakehurst.wiremock.client.WireMock.*;
611
import static org.hamcrest.MatcherAssert.assertThat;
7-
import static org.hamcrest.Matchers.*;
12+
import static org.hamcrest.Matchers.containsInAnyOrder;
13+
import static org.hamcrest.Matchers.hasSize;
14+
import static org.junit.jupiter.api.Assertions.assertAll;
815

916
/**
1017
* Tests for {@link GroupService}
1118
*/
1219
final class GroupServiceTest extends WireMockBaseTestCase {
1320
private final GroupService sut = new GroupService(conf());
21+
22+
@Test
23+
void search() throws URISyntaxException, IOException {
24+
stubFor(
25+
get("/api/v2/dojo_groups/?offset=0&limit=100")
26+
.willReturn(
27+
ok()
28+
.withBody(readResponseBodyFromFixture("GroupService_response_fixture.json"))
29+
)
30+
);
31+
32+
final var result = sut.search();
33+
34+
assertAll(
35+
() -> assertThat(result, hasSize(3)),
36+
() -> assertThat(result, containsInAnyOrder(
37+
Group.builder()
38+
.id(1)
39+
.name("foo")
40+
.socialProvider("GitHub")
41+
.users(List.of(4L))
42+
.build(),
43+
Group.builder()
44+
.id(2)
45+
.name("bar")
46+
.socialProvider("GitHub")
47+
.users(List.of(1L, 2L, 3L))
48+
.build(),
49+
Group.builder()
50+
.id(3)
51+
.name("snafu")
52+
.socialProvider("GitHub")
53+
.users(List.of(4L, 5L))
54+
.build()
55+
))
56+
);
57+
}
1458
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,42 @@
1-
{}
1+
{
2+
"count": 11,
3+
"next": null,
4+
"previous": null,
5+
"results": [
6+
{
7+
"id": 1,
8+
"configuration_permissions": [],
9+
"name": "foo",
10+
"description": null,
11+
"social_provider": "GitHub",
12+
"users": [
13+
4
14+
]
15+
},
16+
{
17+
"id": 2,
18+
"configuration_permissions": [],
19+
"name": "bar",
20+
"description": null,
21+
"social_provider": "GitHub",
22+
"users": [
23+
1,
24+
2,
25+
3
26+
]
27+
},
28+
{
29+
"id": 3,
30+
"configuration_permissions": [],
31+
"name": "snafu",
32+
"description": null,
33+
"social_provider": "GitHub",
34+
"users": [
35+
4,
36+
5
37+
]
38+
}
39+
],
40+
"prefetch": {}
41+
}
42+

0 commit comments

Comments
 (0)