From a344ab3231dd8f6c99e2e7369789aa97681f719f Mon Sep 17 00:00:00 2001 From: Christian Kollmann Date: Tue, 12 Jan 2021 15:08:17 +0100 Subject: Use generic list types in parameters and return types List instead of ArrayList allows for easier mocking and stubbing --- .../eidas/v2/dao/MergedRegisterSearchResult.java | 8 +++---- .../auth/eidas/v2/ernp/DummyErnpClient.java | 26 +++++++++++----------- .../modules/auth/eidas/v2/ernp/IErnpClient.java | 10 ++++----- .../handler/DeSpecificDetailSearchProcessor.java | 13 ++++------- .../handler/ItSpecificDetailSearchProcessor.java | 14 ++++-------- .../auth/eidas/v2/tasks/InitialSearchTask.java | 19 +++++----------- .../modules/auth/eidas/v2/zmr/DummyZmrClient.java | 26 +++++++++++----------- .../modules/auth/eidas/v2/zmr/IZmrClient.java | 10 ++++----- 8 files changed, 53 insertions(+), 73 deletions(-) (limited to 'eidas_modules/authmodule-eIDAS-v2/src/main/java') diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/MergedRegisterSearchResult.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/MergedRegisterSearchResult.java index 7703af2a..e147b8aa 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/MergedRegisterSearchResult.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/MergedRegisterSearchResult.java @@ -26,15 +26,15 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.dao; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowException; import lombok.Data; -import java.util.ArrayList; +import java.util.List; @Data public class MergedRegisterSearchResult { - final ArrayList resultsZmr; - final ArrayList resultsErnp; + final List resultsZmr; + final List resultsErnp; - public MergedRegisterSearchResult(ArrayList resultsZmr, ArrayList resultsErnp) { + public MergedRegisterSearchResult(List resultsZmr, List resultsErnp) { this.resultsZmr = resultsZmr; this.resultsErnp = resultsErnp; } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java index 3b49ab95..e514c808 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/DummyErnpClient.java @@ -27,30 +27,34 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; import org.springframework.stereotype.Service; -import java.util.ArrayList; +import java.util.Collections; +import java.util.List; @Service("ErnbClientForeIDAS") public class DummyErnpClient implements IErnpClient { @Override - public ArrayList searchWithPersonIdentifier(String personIdentifier) { - return resultEmpty(); + public List searchWithPersonIdentifier(String personIdentifier) { + return Collections.emptyList(); } @Override - public ArrayList searchWithMds(String givenName, String familyName, String dateOfBirth) { - return resultEmpty();//TODO will I only receive matches where all three values match perfectly? + public List searchWithMds(String givenName, String familyName, String dateOfBirth) { + //TODO will I only receive matches where all three values match perfectly? + return Collections.emptyList(); } @Override - public ArrayList searchDeSpecific(String givenName, String familyName, String dateOfBirth, + public List searchDeSpecific(String givenName, String familyName, String dateOfBirth, String birthPlace, String birthName) { - return resultEmpty();//TODO + //TODO + return Collections.emptyList(); } @Override - public ArrayList searchItSpecific(String taxNumber) { - return resultEmpty();//TODO + public List searchItSpecific(String taxNumber) { + //TODO + return Collections.emptyList(); } @Override @@ -58,9 +62,5 @@ public class DummyErnpClient implements IErnpClient { //TODO } - private ArrayList resultEmpty() { - return new ArrayList();//Nobody found - } - } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/IErnpClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/IErnpClient.java index 01ac88fb..b9641c5c 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/IErnpClient.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/ernp/IErnpClient.java @@ -26,18 +26,18 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; -import java.util.ArrayList; +import java.util.List; public interface IErnpClient { - ArrayList searchWithPersonIdentifier(String personIdentifier); + List searchWithPersonIdentifier(String personIdentifier); - ArrayList searchWithMds(String givenName, String familyName, String dateOfBirth); + List searchWithMds(String givenName, String familyName, String dateOfBirth); - ArrayList searchDeSpecific(String givenName, String familyName, String dateOfBirth, + List searchDeSpecific(String givenName, String familyName, String dateOfBirth, String birthPlace, String birthName); - ArrayList searchItSpecific(String taxNumber); + List searchItSpecific(String taxNumber); void update(RegisterResult registerResult, SimpleEidasData eidData); } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java index a29725c8..544d5b0c 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/DeSpecificDetailSearchProcessor.java @@ -30,7 +30,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp.IErnpClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; -import java.util.ArrayList; +import java.util.List; public class DeSpecificDetailSearchProcessor extends CountrySpecificDetailSearchProcessor { @@ -54,17 +54,12 @@ public class DeSpecificDetailSearchProcessor extends CountrySpecificDetailSearch @Override public MergedRegisterSearchResult search(SimpleEidasData eidData) { - - - ArrayList resultsZmr = + List resultsZmr = zmrClient.searchDeSpecific(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth(), eidData.getPlaceOfBirth(), eidData.getBirthName()); - - ArrayList resultsErnb = + List resultsErnb = ernbClient.searchDeSpecific(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth(), eidData.getPlaceOfBirth(), eidData.getBirthName()); - - MergedRegisterSearchResult searchResult = new MergedRegisterSearchResult(resultsZmr, resultsErnb); - return searchResult; + return new MergedRegisterSearchResult(resultsZmr, resultsErnb); } } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java index e730066d..370a111c 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/ItSpecificDetailSearchProcessor.java @@ -30,7 +30,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp.IErnpClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; -import java.util.ArrayList; +import java.util.List; public class ItSpecificDetailSearchProcessor extends CountrySpecificDetailSearchProcessor { @@ -51,14 +51,8 @@ public class ItSpecificDetailSearchProcessor extends CountrySpecificDetailSearch @Override public MergedRegisterSearchResult search(SimpleEidasData eidData) { - - ArrayList resultsZmr = - zmrClient.searchItSpecific(eidData.getTaxNumber()); - - ArrayList resultsErnb = - ernbClient.searchItSpecific(eidData.getTaxNumber()); - - MergedRegisterSearchResult searchResult = new MergedRegisterSearchResult(resultsZmr, resultsErnb); - return searchResult; + List resultsZmr = zmrClient.searchItSpecific(eidData.getTaxNumber()); + List resultsErnb = ernbClient.searchItSpecific(eidData.getTaxNumber()); + return new MergedRegisterSearchResult(resultsZmr, resultsErnb); } } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java index c4f0f146..d1bc8f53 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/InitialSearchTask.java @@ -23,7 +23,6 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -209,12 +208,10 @@ public class InitialSearchTask extends AbstractAuthServletTask { private String step8RegisterSearchWithMds(MergedRegisterSearchResult initialSearchResult, SimpleEidasData eidData) { log.trace("Starting step8RegisterSearchWithMds"); - ArrayList resultsZmr = + List resultsZmr = zmrClient.searchWithMds(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth()); - - ArrayList resultsErnp = + List resultsErnp = ernpClient.searchWithMds(eidData.getGivenName(), eidData.getFamilyName(), eidData.getDateOfBirth()); - MergedRegisterSearchResult mdsSearchResult = new MergedRegisterSearchResult(resultsZmr, resultsErnp); log.debug("Automerge " + initialSearchResult + " with " + eidData + " " + mdsSearchResult); //TODO implement next phase and return correct value @@ -222,15 +219,9 @@ public class InitialSearchTask extends AbstractAuthServletTask { } private MergedRegisterSearchResult searchInZmrAndErnp(String personIdentifier) { - - ArrayList resultsZmr = - zmrClient.searchWithPersonIdentifier(personIdentifier); - - ArrayList resultsErnp = - ernpClient.searchWithPersonIdentifier(personIdentifier); - - MergedRegisterSearchResult initialSearchResult = new MergedRegisterSearchResult(resultsZmr, resultsErnp); - return initialSearchResult; + List resultsZmr = zmrClient.searchWithPersonIdentifier(personIdentifier); + List resultsErnp = ernpClient.searchWithPersonIdentifier(personIdentifier); + return new MergedRegisterSearchResult(resultsZmr, resultsErnp); } private SimpleEidasData convertSimpleMapToSimpleData(Map eidasAttrMap) diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/DummyZmrClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/DummyZmrClient.java index 60dd2ef2..b12c1bcb 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/DummyZmrClient.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/DummyZmrClient.java @@ -27,30 +27,34 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; import org.springframework.stereotype.Service; -import java.util.ArrayList; +import java.util.Collections; +import java.util.List; @Service("ZmrClientForeIDAS") public class DummyZmrClient implements IZmrClient { @Override - public ArrayList searchWithPersonIdentifier(String personIdentifier) { - return resultEmpty(); + public List searchWithPersonIdentifier(String personIdentifier) { + return Collections.emptyList(); } @Override - public ArrayList searchWithMds(String givenName, String familyName, String dateOfBirth) { - return resultEmpty();//TODO will I only receive matches where all three values match perfectly? + public List searchWithMds(String givenName, String familyName, String dateOfBirth) { + //TODO will I only receive matches where all three values match perfectly? + return Collections.emptyList(); } @Override - public ArrayList searchDeSpecific(String givenName, String familyName, String dateOfBirth, + public List searchDeSpecific(String givenName, String familyName, String dateOfBirth, String birthPlace, String birthName) { - return resultEmpty();//TODO + //TODO + return Collections.emptyList(); } @Override - public ArrayList searchItSpecific(String taxNumber) { - return resultEmpty();//TODO + public List searchItSpecific(String taxNumber) { + //TODO + return Collections.emptyList(); } @Override @@ -58,8 +62,4 @@ public class DummyZmrClient implements IZmrClient { //TODO } - private ArrayList resultEmpty() { - return new ArrayList();//Nobody found - } - } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/IZmrClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/IZmrClient.java index 3a518e64..5175cd7b 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/IZmrClient.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/zmr/IZmrClient.java @@ -26,18 +26,18 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; -import java.util.ArrayList; +import java.util.List; public interface IZmrClient { - ArrayList searchWithPersonIdentifier(String personIdentifier); + List searchWithPersonIdentifier(String personIdentifier); - ArrayList searchWithMds(String givenName, String familyName, String dateOfBirth); + List searchWithMds(String givenName, String familyName, String dateOfBirth); - ArrayList searchDeSpecific(String givenName, String familyName, String dateOfBirth, + List searchDeSpecific(String givenName, String familyName, String dateOfBirth, String birthPlace, String birthName); - ArrayList searchItSpecific(String taxNumber); + List searchItSpecific(String taxNumber); void update(RegisterResult registerResult, SimpleEidasData eidData); } -- cgit v1.2.3