Skip to content
This repository was archived by the owner on Apr 12, 2019. It is now read-only.

Commit 3af0082

Browse files
authored
Merge pull request #95 from open-prevo/feature/43_tests_for_multiple_funds
Added tests and extended existing once to check the possibility to us…
2 parents 317d20b + dff9783 commit 3af0082

File tree

12 files changed

+133
-22
lines changed

12 files changed

+133
-22
lines changed

adapter-dummy/src/main/resources/pakt-sample-employment-commencement.json

+21
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,26 @@
6161
"iban": "CH52 0483 5012 3456 7100 0",
6262
"referenceId": "756.1335.5778.23"
6363
}
64+
},
65+
{
66+
"techId": "",
67+
"jobInfo": {
68+
"retirementFundUid": "CHE-109.537.488-Helvetia-Prisma-Sammelstiftung 2",
69+
"internalReferenz": "",
70+
"oasiNumber": "756.9534.5271.94",
71+
"internalPersonId": "",
72+
"date": "2018-07-01"
73+
},
74+
"capitalTransferInfo": {
75+
"name": "Helvetia Prisma Sammelstiftung 2",
76+
"additionalName": "Helvetia Versicherungen Schweiz 2",
77+
"address": {
78+
"street": "St. Alban-Anlage 26",
79+
"postalCode": "4002",
80+
"city": "Basel"
81+
},
82+
"iban": "CH52 0483 5012 3456 7100 0",
83+
"referenceId": "756.9534.5271.94"
84+
}
6485
}
6586
]

adapter-dummy/src/main/resources/pakt-sample-employment-termination.json

+10
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,15 @@
2828
"internalPersonId": "",
2929
"date": "2018-06-30"
3030
}
31+
},
32+
{
33+
"techId": "",
34+
"jobInfo": {
35+
"retirementFundUid": "CHE-109.537.488-Helvetia-Prisma-Sammelstiftung 2",
36+
"internalReferenz": "",
37+
"oasiNumber": "756.5678.1234.17",
38+
"internalPersonId": "",
39+
"date": "2018-06-30"
40+
}
3141
}
3242
]

adapter-dummy/src/main/resources/sample-employment-commencement.json

+20
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@
6060
},
6161
"iban": "CH53 0077 0016 02222 3334 4",
6262
"referenceId": "756.5678.1234.17"
63+
} },
64+
{
65+
"techId": "",
66+
"jobInfo": {
67+
"retirementFundUid": "CHE-109.740.084-Baloise-Sammelstiftung 2",
68+
"internalReferenz": "",
69+
"oasiNumber": "756.3324.5678.58",
70+
"internalPersonId": "",
71+
"date": "2018-07-01"
72+
},
73+
"capitalTransferInfo": {
74+
"name": "Perspectiva Sammelstiftung für berufliche Vorsorge 2",
75+
"additionalName": "Basler Leben AG 2",
76+
"address": {
77+
"street": "Aeschengraben 21, Postfach",
78+
"postalCode": "4002",
79+
"city": "Basel"
80+
},
81+
"iban": "CH53 0077 0016 02222 3334 4",
82+
"referenceId": "756.3324.5678.58"
6383
}
6484
}
6585
]

adapter-dummy/src/main/resources/sample-employment-termination.json

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
"oasiNumber": "756.9534.5271.94",
2828
"internalPersonId": "",
2929
"date": "2018-06-30"
30+
} },
31+
{
32+
"techId": "",
33+
"jobInfo": {
34+
"retirementFundUid": "CHE-109.740.084-Baloise-Sammelstiftung 2",
35+
"internalReferenz": "",
36+
"oasiNumber": "756.9874.5778.58",
37+
"internalPersonId": "",
38+
"date": "2018-06-30"
3039
}
3140
}
3241
]

hub/src/main/java/ch/prevo/open/hub/nodes/DockerNodeRegistry.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package ch.prevo.open.hub.nodes;
22

3-
import static java.util.Collections.singletonList;
3+
import org.springframework.context.annotation.Profile;
4+
import org.springframework.stereotype.Service;
45

56
import java.util.Arrays;
67
import java.util.List;
78

8-
import org.springframework.context.annotation.Profile;
9-
import org.springframework.stereotype.Service;
10-
119
/**
1210
* All node instances currently known by the hub, currently only a mock implementation.
1311
*/
@@ -17,10 +15,10 @@ class DockerNodeRegistry implements NodeRegistry {
1715

1816
static final NodeConfiguration BALOISE_NODE =
1917
new NodeConfiguration("http://node_baloise:8080",
20-
singletonList("CHE-109.740.084-Baloise-Sammelstiftung"));
18+
"CHE-109.740.084-Baloise-Sammelstiftung", "CHE-109.740.084-Baloise-Sammelstiftung 2");
2119
static final NodeConfiguration HELVETIA_NODE =
2220
new NodeConfiguration("http://node_helvetia:8080",
23-
singletonList("CHE-109.537.488-Helvetia-Prisma-Sammelstiftung"));
21+
"CHE-109.537.488-Helvetia-Prisma-Sammelstiftung", "CHE-109.537.488-Helvetia-Prisma-Sammelstiftung 2");
2422

2523
@Override
2624
public List<NodeConfiguration> getCurrentNodes() {

hub/src/main/java/ch/prevo/open/hub/nodes/NodeConfiguration.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package ch.prevo.open.hub.nodes;
22

3+
import org.apache.commons.lang3.builder.ToStringBuilder;
4+
5+
import java.util.Arrays;
36
import java.util.List;
47
import java.util.Objects;
58

6-
import org.apache.commons.lang3.builder.ToStringBuilder;
7-
89
@SuppressWarnings("unused")
910
public class NodeConfiguration {
1011

@@ -21,12 +22,12 @@ public class NodeConfiguration {
2122

2223
public NodeConfiguration() {}
2324

24-
public NodeConfiguration(String baseUrl, List<String> retirementFundUids) {
25+
public NodeConfiguration(String baseUrl, String... retirementFundUids) {
2526
this.jobEntriesUrl = baseUrl + JOB_START_ENDPOINT;
2627
this.jobExitsUrl = baseUrl + JOB_END_ENDPOINT;
2728
this.commencementMatchNotifyUrl = baseUrl + COMMENCEMENT_MATCH_NOTIFICATION_ENDPOINT;
2829
this.terminationMatchNotifyUrl = baseUrl + TERMINATION_MATCH_NOTIFICATION_ENDPOINT;
29-
this.retirementFundUids = retirementFundUids;
30+
this.retirementFundUids = Arrays.asList(retirementFundUids);
3031
}
3132

3233
String getJobExitsUrl() {

hub/src/main/resources/nodes.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
-
22
retirementFundUids:
33
- CHE-109.740.084-Baloise-Sammelstiftung
4+
- CHE-109.740.084-Baloise-Sammelstiftung 2
45
jobExitsUrl: http://localhost:8881/job-end
56
jobEntriesUrl: http://localhost:8881/job-start
67
commencementMatchNotifyUrl: http://localhost:8881/commencement-match-notification
78
terminationMatchNotifyUrl: http://localhost:8881/termination-match-notification
89
-
910
retirementFundUids:
1011
- CHE-109.537.488-Helvetia-Prisma-Sammelstiftung
12+
- CHE-109.537.488-Helvetia-Prisma-Sammelstiftung 2
1113
jobExitsUrl: http://localhost:8882/job-end
1214
jobEntriesUrl: http://localhost:8882/job-start
1315
commencementMatchNotifyUrl: http://localhost:8882/commencement-match-notification

hub/src/test/java/ch/prevo/open/hub/integration/HubIntegrationTest.java

+25-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import ch.prevo.open.hub.nodes.NodeConfiguration;
66
import ch.prevo.open.hub.nodes.NodeRegistry;
77
import ch.prevo.open.hub.nodes.NodeService;
8-
98
import org.junit.Before;
109
import org.junit.ClassRule;
1110
import org.junit.Test;
@@ -23,7 +22,6 @@
2322
import java.util.List;
2423

2524
import static java.util.Arrays.asList;
26-
import static java.util.Collections.singletonList;
2725
import static org.assertj.core.api.Java6Assertions.assertThat;
2826
import static org.mockito.Mockito.verify;
2927
import static org.mockito.Mockito.when;
@@ -54,10 +52,10 @@ public class HubIntegrationTest {
5452
public void setup() {
5553

5654
NodeConfiguration nodeBaloise = new NodeConfiguration(getBaseUrlForNode("node_baloise"),
57-
singletonList("CHE-109.740.084-Baloise-Sammelstiftung"));
55+
"CHE-109.740.084-Baloise-Sammelstiftung", "CHE-109.740.084-Baloise-Sammelstiftung 2");
5856

5957
NodeConfiguration nodeHelvetia = new NodeConfiguration(getBaseUrlForNode("node_helvetia"),
60-
singletonList("CHE-109.537.488-Helvetia-Prisma-Sammelstiftung"));
58+
"CHE-109.537.488-Helvetia-Prisma-Sammelstiftung", "CHE-109.537.488-Helvetia-Prisma-Sammelstiftung 2");
6159

6260
when(nodeRegistry.getCurrentNodes()).thenReturn(asList(nodeBaloise, nodeHelvetia));
6361
}
@@ -71,19 +69,38 @@ private String getBaseUrlForNode(String nodeName) {
7169
@Test
7270
public void testMatchingService() {
7371
//given
74-
Match expectedMatchFromHelvetiaToBaloise = new Match("756.1234.5678.97",
72+
Match expectedMatchFromHelvetia1ToBaloise1 = new Match("756.1234.5678.97",
73+
"CHE-109.537.488-Helvetia-Prisma-Sammelstiftung",
74+
"CHE-109.740.084-Baloise-Sammelstiftung", LocalDate.of(2018, 7, 1), LocalDate.of(2018, 6, 30));
75+
Match expectedMatchFromHelvetia1ToBaloise2 = new Match("756.3324.5678.58",
7576
"CHE-109.537.488-Helvetia-Prisma-Sammelstiftung",
77+
"CHE-109.740.084-Baloise-Sammelstiftung 2", LocalDate.of(2018, 7, 1), LocalDate.of(2018, 6, 30));
78+
Match expectedMatchFromHelvetia2ToBaloise1 = new Match("756.5678.1234.17",
79+
"CHE-109.537.488-Helvetia-Prisma-Sammelstiftung 2",
7680
"CHE-109.740.084-Baloise-Sammelstiftung", LocalDate.of(2018, 7, 1), LocalDate.of(2018, 6, 30));
77-
Match expectedMatchFromBaloiseToHelvetia = new Match("756.1335.5778.23",
81+
Match expectedMatchFromBaloise1ToHelvetia1 = new Match("756.1335.5778.23",
82+
"CHE-109.740.084-Baloise-Sammelstiftung",
83+
"CHE-109.537.488-Helvetia-Prisma-Sammelstiftung", LocalDate.of(2018, 7, 1), LocalDate.of(2018, 6, 30));
84+
Match expectedMatchFromBaloise1ToHelvetia2 = new Match("756.9534.5271.94",
7885
"CHE-109.740.084-Baloise-Sammelstiftung",
86+
"CHE-109.537.488-Helvetia-Prisma-Sammelstiftung 2", LocalDate.of(2018, 7, 1), LocalDate.of(2018, 6, 30));
87+
Match expectedMatchFromBaloise2ToHelvetia1 = new Match("756.9874.5778.58",
88+
"CHE-109.740.084-Baloise-Sammelstiftung 2",
7989
"CHE-109.537.488-Helvetia-Prisma-Sammelstiftung", LocalDate.of(2018, 7, 1), LocalDate.of(2018, 6, 30));
8090

8191
// when
8292
List<Match> matches = hubService.matchAndNotify();
8393

8494
// then
85-
assertThat(matches).hasSize(2)
86-
.containsExactlyInAnyOrder(expectedMatchFromHelvetiaToBaloise, expectedMatchFromBaloiseToHelvetia);
95+
assertThat(matches)
96+
.containsExactlyInAnyOrder(
97+
expectedMatchFromHelvetia1ToBaloise1,
98+
expectedMatchFromHelvetia1ToBaloise2,
99+
expectedMatchFromHelvetia2ToBaloise1,
100+
expectedMatchFromBaloise1ToHelvetia1,
101+
expectedMatchFromBaloise1ToHelvetia2,
102+
expectedMatchFromBaloise2ToHelvetia1
103+
);
87104
verify(nodeService).notifyMatches(matches);
88105
}
89106
}

hub/src/test/java/ch/prevo/open/hub/nodes/NodeCallerTest.java

+25
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
public class NodeCallerTest {
3030

3131
private static final String OASI1 = "756.1234.5678.97";
32+
private static final String OASI2 = "756.1335.5778.23";
3233
private static final String UID1 = "CHE-223.471.073";
3334
private static final String UID2 = "CHE-109.723.097";
3435

@@ -38,6 +39,12 @@ public class NodeCallerTest {
3839
private static final String INSURANT_INFORMATION_JSON_ARRAY
3940
= "[{\"encryptedOasiNumber\" : \"" + OASI1 + "\", \"retirementFundUid\" : \"" + UID1 + "\", \"date\" : \"2017-12-31\"}]";
4041

42+
private static final String INSURANT_INFORMATION_JSON_ARRAY_WITH_MULTIPLE_FUNDS
43+
= "[" +
44+
"{\"encryptedOasiNumber\" : \"" + OASI1 + "\", \"retirementFundUid\" : \"" + UID1 + "\", \"date\" : \"2017-12-31\"}," +
45+
"{\"encryptedOasiNumber\" : \"" + OASI2 + "\", \"retirementFundUid\" : \"" + UID2 + "\", \"date\" : \"2017-12-31\"}" +
46+
"]";
47+
4148
private static final String CAPITAL_TRANSFER_INFORMATION
4249
= "{\"name\" : \"" + RETIREMENT_FUND_NAME + "\", \"iban\" : \"" + IBAN + "\"}";
4350

@@ -64,6 +71,24 @@ public void getInsurantInformationList() throws Exception {
6471
server.verify();
6572
}
6673

74+
@Test
75+
public void getInsurantInformationListWithMultipleRetirementFunds() {
76+
// given
77+
server.expect(requestTo(URL1))
78+
.andRespond(withSuccess(INSURANT_INFORMATION_JSON_ARRAY_WITH_MULTIPLE_FUNDS, MediaType.APPLICATION_JSON));
79+
80+
List<InsurantInformation> insurantInformationList = nodeCaller.getInsurantInformationList(URL1);
81+
82+
assertEquals(2, insurantInformationList.size());
83+
assertEquals(UID1, insurantInformationList.get(0).getRetirementFundUid());
84+
assertEquals(OASI1, insurantInformationList.get(0).getEncryptedOasiNumber());
85+
assertEquals(of(2017, 12, 31), insurantInformationList.get(0).getDate());
86+
assertEquals(UID2, insurantInformationList.get(1).getRetirementFundUid());
87+
assertEquals(OASI2, insurantInformationList.get(1).getEncryptedOasiNumber());
88+
assertEquals(of(2017, 12, 31), insurantInformationList.get(0).getDate());
89+
server.verify();
90+
}
91+
6792
@Test
6893
public void tryGetInsurantInformationListWithUnreachableNode() {
6994
// given

hub/src/test/java/ch/prevo/open/hub/nodes/NodeServiceTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public class NodeServiceTest {
5353

5454
@Before
5555
public void setUp() {
56-
node1_new = new NodeConfiguration("https://host1", singletonList(UID1_OLD));
57-
node2_old = new NodeConfiguration("https://host2", singletonList(UID2_NEW));
56+
node1_new = new NodeConfiguration("https://host1", UID1_OLD);
57+
node2_old = new NodeConfiguration("https://host2", UID2_NEW);
5858
terminationInsurantInfo = new InsurantInformation(OASI1, UID1_OLD, of(2020, 12, 15));
5959
commencementInsurantInfo = new InsurantInformation(OASI1, UID2_NEW, of(2021, 2, 1));
6060
assertTrue(matcherService.employmentTerminationNotMatched(terminationInsurantInfo));

node/src/test/java/ch/prevo/open/node/api/JobEndControllerTest.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public void getAllJobEndData() throws Exception {
4545
.andExpect(content().contentType(contentType))
4646
.andExpect(jsonPath("$", hasSize(3)))
4747
.andExpect(jsonPath("$[0].encryptedOasiNumber", is("756.1335.5778.23")))
48-
.andExpect(jsonPath("$[0].retirementFundUid", is("CHE-109.740.084")));
48+
.andExpect(jsonPath("$[0].retirementFundUid", is("CHE-109.740.084")))
49+
.andExpect(jsonPath("$[1].encryptedOasiNumber", is("756.3412.8844.97")))
50+
.andExpect(jsonPath("$[1].retirementFundUid", is("CHE-109.537.488")))
51+
.andExpect(jsonPath("$[2].encryptedOasiNumber", is("756.9534.5271.94")))
52+
.andExpect(jsonPath("$[2].retirementFundUid", is("CHE-109.740.078")));
4953
}
5054
}

node/src/test/java/ch/prevo/open/node/api/JobStartControllerTest.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public void getAllJobStartData() throws Exception {
4545
.andExpect(content().contentType(contentType))
4646
.andExpect(jsonPath("$", hasSize(3)))
4747
.andExpect(jsonPath("$[0].encryptedOasiNumber", is("756.1234.5678.97")))
48-
.andExpect(jsonPath("$[0].retirementFundUid", is("CHE-109.740.084")));
48+
.andExpect(jsonPath("$[0].retirementFundUid", is("CHE-109.740.084")))
49+
.andExpect(jsonPath("$[1].encryptedOasiNumber", is("756.1298.6578.97")))
50+
.andExpect(jsonPath("$[1].retirementFundUid", is("CHE-109.537.488")))
51+
.andExpect(jsonPath("$[2].encryptedOasiNumber", is("756.5678.1234.17")))
52+
.andExpect(jsonPath("$[2].retirementFundUid", is("CHE-109.740.078")));
4953
}
5054
}

0 commit comments

Comments
 (0)