aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/test
diff options
context:
space:
mode:
authorChristian Kollmann <christian.kollmann@a-sit.at>2021-01-12 15:08:17 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2021-01-15 15:14:22 +0100
commita344ab3231dd8f6c99e2e7369789aa97681f719f (patch)
tree0c6064765e0033c81e74e8e3a1a146914f1eade3 /eidas_modules/authmodule-eIDAS-v2/src/test
parentcd61bfbb1f865456ca609b807aaba40d6d1e13b2 (diff)
downloadNational_eIDAS_Gateway-a344ab3231dd8f6c99e2e7369789aa97681f719f.tar.gz
National_eIDAS_Gateway-a344ab3231dd8f6c99e2e7369789aa97681f719f.tar.bz2
National_eIDAS_Gateway-a344ab3231dd8f6c99e2e7369789aa97681f719f.zip
Use generic list types in parameters and return types
List instead of ArrayList allows for easier mocking and stubbing
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java55
1 files changed, 17 insertions, 38 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java
index 35e2e56e..1f512354 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java
@@ -67,6 +67,7 @@ import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Random;
@@ -136,9 +137,7 @@ public class InitialSearchTaskFirstTest {
String newFirstName = RandomStringUtils.randomAlphabetic(5);
zmrResult.add(new RegisterResult(randomBpk, DE_ST+randomIdentifier, newFirstName, randomFamilyName, randomDate));
Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(zmrResult);
-
- ArrayList<RegisterResult> ernpResult = new ArrayList<>();
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(ernpResult);
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
task.execute(pendingReq, executionContext);
String bPk = (String)
@@ -152,9 +151,7 @@ public class InitialSearchTaskFirstTest {
@Test
@DirtiesContext
public void testNode100_UserIdentifiedUpdateNecessary_b() throws TaskExecutionException {
- ArrayList<RegisterResult> zmrResult = new ArrayList<>();
- Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(zmrResult);
-
+ Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
ArrayList<RegisterResult> ernpResult = new ArrayList<>();
String randomBpk = RandomStringUtils.randomNumeric(6);
ernpResult.add(new RegisterResult(randomBpk, DE_ST+randomIdentifier, "Max_new", randomFamilyName, randomDate));
@@ -177,9 +174,7 @@ public class InitialSearchTaskFirstTest {
zmrResult.add(new RegisterResult("bpkMax", DE_ST+randomIdentifier, randomGivenName, randomFamilyName, randomDate));
zmrResult.add(new RegisterResult("bpkMax", DE_ST+randomIdentifier, "Maximilian", randomFamilyName, randomDate));
Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(zmrResult);
-
- ArrayList<RegisterResult> ernpResult = new ArrayList<>();
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(ernpResult);
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
TaskExecutionException exception = assertThrows(TaskExecutionException.class,
() -> task.execute(pendingReq, executionContext));
@@ -195,9 +190,7 @@ public class InitialSearchTaskFirstTest {
@DirtiesContext
public void testNode101_ManualFixNecessary_b() {
String randombpk = RandomStringUtils.random(5);
- ArrayList<RegisterResult> zmrResult = new ArrayList<>();
- Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(zmrResult);
-
+ Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
ArrayList<RegisterResult> ernpResult = new ArrayList<>();
ernpResult.add(new RegisterResult(randombpk, DE_ST+randomIdentifier, randomGivenName, randomFamilyName, randomDate));
ernpResult.add(new RegisterResult(randombpk, DE_ST+randomIdentifier, randomGivenName+RandomStringUtils.random(2),
@@ -218,8 +211,7 @@ public class InitialSearchTaskFirstTest {
@DirtiesContext
public void testNode102_UserIdentified_a() throws Exception {
String randomBpk = RandomStringUtils.randomNumeric(12);
- ArrayList<RegisterResult> zmrResult = new ArrayList<>();
- Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(zmrResult);
+ Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
ArrayList<RegisterResult> ernpResult = new ArrayList<>();
ernpResult.add(new RegisterResult(randomBpk, DE_ST+randomIdentifier, randomGivenName, randomFamilyName, randomDate));
@@ -242,9 +234,7 @@ public class InitialSearchTaskFirstTest {
ArrayList<RegisterResult> zmrResult = new ArrayList<>();
zmrResult.add(new RegisterResult(randomBpk, DE_ST+randomIdentifier, randomGivenName, randomFamilyName, randomDate));
Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(zmrResult);
-
- ArrayList<RegisterResult> ernpResult = new ArrayList<>();
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(ernpResult);
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
task.execute(pendingReq, executionContext);
String bPk = (String)
@@ -265,8 +255,7 @@ public class InitialSearchTaskFirstTest {
pendingReq1.getSessionData(AuthProcessDataWrapper.class)
.setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
- ArrayList<RegisterResult> zmrResultInitial = new ArrayList<>();
- Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(zmrResultInitial);
+ Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
ArrayList<RegisterResult> zmrResultSpecific = new ArrayList<>();
zmrResultSpecific.add(new RegisterResult(bpkRegister, IT_ST+randomIdentifier+RandomStringUtils.random(2),
@@ -276,8 +265,7 @@ public class InitialSearchTaskFirstTest {
Mockito.when(zmrClient.searchItSpecific(taxNumber)).thenReturn(zmrResultSpecific);
- ArrayList<RegisterResult> ernpResultInitial = new ArrayList<>();
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(ernpResultInitial);
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
List<CountrySpecificDetailSearchProcessor> handlers = new ArrayList<>();
ItSpecificDetailSearchProcessor it = new ItSpecificDetailSearchProcessor(ernpClient, zmrClient);
@@ -310,8 +298,7 @@ public class InitialSearchTaskFirstTest {
pendingReq1.getSessionData(AuthProcessDataWrapper.class)
.setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
- ArrayList<RegisterResult> zmrResultInitial = new ArrayList<>();
- Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(zmrResultInitial);
+ Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
ArrayList<RegisterResult> zmrResultSpecific = new ArrayList<>();
zmrResultSpecific.add(new RegisterResult(bpk, pseudonym, givenName, familyName, dateOfBirth, placeOfBirth,
@@ -320,8 +307,7 @@ public class InitialSearchTaskFirstTest {
Mockito.when(zmrClient.searchDeSpecific(givenName, familyName, dateOfBirth, placeOfBirth, birthName)).thenReturn(zmrResultSpecific);
- ArrayList<RegisterResult> ernpResultInitial = new ArrayList<>();
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(ernpResultInitial);
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
List<CountrySpecificDetailSearchProcessor> handlers = new ArrayList<>();
DeSpecificDetailSearchProcessor de = new DeSpecificDetailSearchProcessor(ernpClient, zmrClient);
@@ -356,8 +342,7 @@ public class InitialSearchTaskFirstTest {
pendingReq1.getSessionData(AuthProcessDataWrapper.class)
.setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
- ArrayList<RegisterResult> zmrResultInitial = new ArrayList<>();
- Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(zmrResultInitial);
+ Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
ArrayList<RegisterResult> zmrResultSpecific = new ArrayList<>();
zmrResultSpecific.add(new RegisterResult(bpk1, pseudonym1, givenName, familyName, dateOfBirth, placeOfBirth,
@@ -368,8 +353,7 @@ public class InitialSearchTaskFirstTest {
null, null));
Mockito.when(zmrClient.searchDeSpecific(givenName, familyName, dateOfBirth, placeOfBirth, birthName)).thenReturn(zmrResultSpecific);
- ArrayList<RegisterResult> ernpResultInitial = new ArrayList<>();
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(ernpResultInitial);
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
List<CountrySpecificDetailSearchProcessor> handlers = new ArrayList<>();
DeSpecificDetailSearchProcessor de = new DeSpecificDetailSearchProcessor(ernpClient, zmrClient);
@@ -397,8 +381,7 @@ public class InitialSearchTaskFirstTest {
pendingReq1.getSessionData(AuthProcessDataWrapper.class)
.setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response);
- ArrayList<RegisterResult> zmrResultInitial = new ArrayList<>();
- Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(zmrResultInitial);
+ Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
ArrayList<RegisterResult> zmrResultSpecific = new ArrayList<>();
zmrResultSpecific.add(new RegisterResult("bpkMax", IT_ST+randomIdentifier+"4", randomGivenName, randomFamilyName,
@@ -409,8 +392,7 @@ public class InitialSearchTaskFirstTest {
fakeTaxNumber, null));
Mockito.when(zmrClient.searchItSpecific(fakeTaxNumber)).thenReturn(zmrResultSpecific);
- ArrayList<RegisterResult> ernpResultInitial = new ArrayList<>();
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(ernpResultInitial);
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
List<CountrySpecificDetailSearchProcessor> handlers = new ArrayList<>();
ItSpecificDetailSearchProcessor it = new ItSpecificDetailSearchProcessor(ernpClient, zmrClient);
@@ -430,11 +412,8 @@ public class InitialSearchTaskFirstTest {
@Test
@DirtiesContext
public void testNode105_TemporaryEnd() throws TaskExecutionException {
- ArrayList<RegisterResult> zmrResult = new ArrayList<>();
- Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(zmrResult);
-
- ArrayList<RegisterResult> ernpResult = new ArrayList<>();
- Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(ernpResult);
+ Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList());
task.execute(pendingReq, executionContext);
String bPk = (String)