diff options
author | Christian Kollmann <christian.kollmann@a-sit.at> | 2021-02-22 14:31:47 +0100 |
---|---|---|
committer | Christian Kollmann <christian.kollmann@a-sit.at> | 2021-02-22 15:04:24 +0100 |
commit | 0725cce166b91725624e4cde694e9fde4e931bc9 (patch) | |
tree | f708adddcc8fa790e64902fa4ef9812a9bb2f1ea /eidas_modules/authmodule-eIDAS-v2/src/test/java | |
parent | 5eb83e0ca367958c81a7b0ee2cbd047482dd1974 (diff) | |
download | National_eIDAS_Gateway-0725cce166b91725624e4cde694e9fde4e931bc9.tar.gz National_eIDAS_Gateway-0725cce166b91725624e4cde694e9fde4e931bc9.tar.bz2 National_eIDAS_Gateway-0725cce166b91725624e4cde694e9fde4e931bc9.zip |
Refactor exception throwing and some names
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test/java')
-rw-r--r-- | eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java | 60 |
1 files changed, 22 insertions, 38 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java index 4dd6b92e..c9f123dc 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java @@ -131,9 +131,7 @@ public class InitialSearchTaskTest { Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); task.execute(pendingReq, executionContext); - String bPk = (String) - pendingReq.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + String bPk = readBpkFromSessionData(pendingReq); Assert.assertEquals("Wrong bpk", bPk, randomBpk); } @@ -150,9 +148,7 @@ public class InitialSearchTaskTest { new RegisterResult(randomBpk, randomIdentifier, newRandomGivenName, randomFamilyName, randomBirthDate))); task.execute(pendingReq, executionContext); - String bPk = (String) - pendingReq.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + String bPk = readBpkFromSessionData(pendingReq); Assert.assertEquals("Wrong bpk", bPk, randomBpk); } @@ -174,7 +170,7 @@ public class InitialSearchTaskTest { () -> task.execute(pendingReq, executionContext)); Throwable origE = exception.getOriginalException(); - Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException)); + Assert.assertTrue("Wrong exception", (origE instanceof ManualFixNecessaryException)); } @@ -196,7 +192,7 @@ public class InitialSearchTaskTest { () -> task.execute(pendingReq, executionContext)); Throwable origE = exception.getOriginalException(); - Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException)); + Assert.assertTrue("Wrong exception", (origE instanceof ManualFixNecessaryException)); } /** @@ -210,9 +206,7 @@ public class InitialSearchTaskTest { new RegisterResult(randomBpk, randomIdentifier, randomGivenName, randomFamilyName, randomBirthDate))); task.execute(pendingReq, executionContext); - String bPk = (String) - pendingReq.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + String bPk = readBpkFromSessionData(pendingReq); Assert.assertEquals("Wrong bpk", bPk, randomBpk); } @@ -228,9 +222,7 @@ public class InitialSearchTaskTest { task.execute(pendingReq, executionContext); - String bPk = (String) - pendingReq.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + String bPk = readBpkFromSessionData(pendingReq); Assert.assertEquals("Wrong bpk", bPk, randomBpk); } @@ -257,9 +249,7 @@ public class InitialSearchTaskTest { task.execute(pendingReq1, executionContext); - String bPk = (String) - pendingReq1.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + String bPk = readBpkFromSessionData(pendingReq1); Assert.assertEquals("Wrong bpk", bPk, randomBpk); } @@ -287,9 +277,7 @@ public class InitialSearchTaskTest { task.execute(pendingReq1, executionContext); - String resultBpk = (String) - pendingReq1.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + String resultBpk = readBpkFromSessionData(pendingReq1); Assert.assertEquals("Wrong bpk", resultBpk, randomBpk); } @@ -325,7 +313,7 @@ public class InitialSearchTaskTest { () -> task.execute(pendingReq1, executionContext)); Throwable origE = exception.getOriginalException(); - Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException)); + Assert.assertTrue("Wrong exception", (origE instanceof ManualFixNecessaryException)); } /** @@ -358,7 +346,7 @@ public class InitialSearchTaskTest { () -> task.execute(pendingReq1, executionContext)); Throwable origE = exception.getOriginalException(); - Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException)); + Assert.assertTrue("Wrong exception", (origE instanceof ManualFixNecessaryException)); } /** @@ -372,14 +360,12 @@ public class InitialSearchTaskTest { task.execute(pendingReq, executionContext); - String bPk = (String) - pendingReq.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + String bPk = readBpkFromSessionData(pendingReq); Assert.assertNull("Wrong bpk", bPk); Boolean transitionGUI = (Boolean) executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK); Assert.assertNull("Wrong transition", transitionGUI); - Boolean transitionErnb = (Boolean) executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNB_ENTRY_TASK); + Boolean transitionErnb = (Boolean) executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK); Assert.assertTrue("Wrong transition", transitionErnb); } @@ -398,13 +384,11 @@ public class InitialSearchTaskTest { task.execute(pendingReq, executionContext); - String bPk = (String) - pendingReq.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + String bPk = readBpkFromSessionData(pendingReq); Assert.assertNull("Wrong bpk", bPk); Boolean transitionGUI = (Boolean) executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK); Assert.assertTrue("Wrong transition", transitionGUI); - Boolean transitionErnb = (Boolean) executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNB_ENTRY_TASK); + Boolean transitionErnb = (Boolean) executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK); Assert.assertNull("Wrong transition", transitionErnb); } @@ -423,13 +407,11 @@ public class InitialSearchTaskTest { task.execute(pendingReq, executionContext); - String bPk = (String) - pendingReq.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + String bPk = readBpkFromSessionData(pendingReq); Assert.assertNull("Wrong bpk", bPk); Boolean transitionGUI = (Boolean) executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK); Assert.assertTrue("Wrong transition", transitionGUI); - Boolean transitionErnb = (Boolean) executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNB_ENTRY_TASK); + Boolean transitionErnb = (Boolean) executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK); Assert.assertNull("Wrong transition", transitionErnb); } @@ -450,13 +432,11 @@ public class InitialSearchTaskTest { task.execute(pendingReq, executionContext); - String bPk = (String) - pendingReq.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + String bPk = readBpkFromSessionData(pendingReq); Assert.assertNull("Wrong bpk", bPk); Boolean transitionGUI = (Boolean) executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK); Assert.assertTrue("Wrong transition", transitionGUI); - Boolean transitionErnb = (Boolean) executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNB_ENTRY_TASK); + Boolean transitionErnb = (Boolean) executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK); Assert.assertNull("Wrong transition", transitionErnb); } @@ -538,4 +518,8 @@ public class InitialSearchTaskTest { .attributeValueMarshaller(marshaller).build(); } + private String readBpkFromSessionData(TestRequestImpl pendingReq) { + return (String) pendingReq.getSessionData(AuthProcessDataWrapper.class) + .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + } } |