diff --git a/src/main/java/com/adobe/campaign/tests/integro/phased/MutationListener.java b/src/main/java/com/adobe/campaign/tests/integro/phased/MutationListener.java index 38a4a8d..7076ec2 100644 --- a/src/main/java/com/adobe/campaign/tests/integro/phased/MutationListener.java +++ b/src/main/java/com/adobe/campaign/tests/integro/phased/MutationListener.java @@ -282,7 +282,7 @@ public void onTestStart(ITestResult result) { + " due to failure in step " + PhasedTestManager.getScenarioContext() .get(PhasedTestManager.fetchScenarioName(result)).getFailedStep() + " in Phase " + PhasedTestManager.getScenarioContext() - .get(PhasedTestManager.fetchScenarioName(result)).getFailedInPhase().name(); + .get(PhasedTestManager.fetchScenarioName(result)).getFailedInPhase(); log.info(skipMessageSKIPFAILURE); result.setStatus(ITestResult.SKIP); diff --git a/src/main/java/com/adobe/campaign/tests/integro/phased/PhasedTestListener.java b/src/main/java/com/adobe/campaign/tests/integro/phased/PhasedTestListener.java index 8bb1f05..0193052 100644 --- a/src/main/java/com/adobe/campaign/tests/integro/phased/PhasedTestListener.java +++ b/src/main/java/com/adobe/campaign/tests/integro/phased/PhasedTestListener.java @@ -134,7 +134,7 @@ public void onTestStart(ITestResult result) { + " due to failure in step " + PhasedTestManager.getScenarioContext() .get(PhasedTestManager.fetchScenarioName(result)).getFailedStep() + " in Phase " + PhasedTestManager.getScenarioContext() - .get(PhasedTestManager.fetchScenarioName(result)).getFailedInPhase().name(); + .get(PhasedTestManager.fetchScenarioName(result)).getFailedInPhase(); log.info(skipMessageSKIPFAILURE); result.setStatus(ITestResult.SKIP); diff --git a/src/main/java/com/adobe/campaign/tests/integro/phased/PhasedTestManager.java b/src/main/java/com/adobe/campaign/tests/integro/phased/PhasedTestManager.java index 4ca3273..09848d4 100644 --- a/src/main/java/com/adobe/campaign/tests/integro/phased/PhasedTestManager.java +++ b/src/main/java/com/adobe/campaign/tests/integro/phased/PhasedTestManager.java @@ -1578,7 +1578,7 @@ protected static class ScenarioContextData { private boolean passed; private long duration; private String failedStep; - private Phases failedInPhase; + private String failedInPhase; private String currentStep; private int stepNr; @@ -1587,7 +1587,7 @@ protected static class ScenarioContextData { passed = true; duration = 0; failedStep = NOT_APPLICABLE_STEP_NAME; - setFailedInPhase(Phases.NON_PHASED); + setFailedInPhase("N/A"); setCurrentStep(NOT_APPLICABLE_STEP_NAME); } @@ -1610,7 +1610,7 @@ protected ScenarioContextData(String in_importString) { * @param in_phase The Phase in which the error happened * @param in_currentStep The current step in which we are */ - protected ScenarioContextData(boolean in_passed, long in_duration, String in_failedStep, Phases in_phase, + protected ScenarioContextData(boolean in_passed, long in_duration, String in_failedStep, String in_phase, String in_currentStep) { this.passed = in_passed; this.duration = in_duration; @@ -1631,7 +1631,7 @@ public ScenarioContextData(boolean in_passed, long in_duration, String in_failed this.passed = in_passed; this.duration = in_duration; this.failedStep = in_failedStep; - this.setFailedInPhase(Phases.getCurrentPhase()); + this.setFailedInPhase(ExecutionMode.getCurrentMode().fetchBehavior()); } public boolean isPassed() { @@ -1658,11 +1658,11 @@ public void setFailedStep(String failedStep) { this.failedStep = failedStep; } - public Phases getFailedInPhase() { + public String getFailedInPhase() { return failedInPhase; } - public void setFailedInPhase(Phases failedInPhase) { + public void setFailedInPhase(String failedInPhase) { this.failedInPhase = failedInPhase; } @@ -1700,7 +1700,7 @@ public void synchronizeState(String in_scenarioName, int in_stepRessult, long st switch (in_stepRessult) { case ITestResult.FAILURE: failedStep = in_scenarioName; - setFailedInPhase(Phases.getCurrentPhase()); + setFailedInPhase(ExecutionMode.getCurrentMode().fetchBehavior()); case ITestResult.SKIP: passed = false; default: @@ -1720,7 +1720,7 @@ public void synchronizeState(String in_scenarioName, int in_stepRessult, long st */ public String exportToString() { return this.passed + ";" + this.duration + ";" + this.failedStep + ";" - + this.getFailedInPhase().name(); + + this.getFailedInPhase(); } /** @@ -1753,14 +1753,16 @@ public void importFromString(String in_importString) { this.failedStep = !l_valueArray[2].trim().isEmpty() ? l_valueArray[2] : NOT_APPLICABLE_STEP_NAME; - try { - this.setFailedInPhase(!l_valueArray[3].trim().isEmpty() ? Phases.valueOf( - l_valueArray[3]) : Phases.NON_PHASED); - } catch (IllegalArgumentException exc) { - throw new IllegalArgumentException( - "The given import string " + in_importString - + " does not allow us to deduce the Phase."); - } + var importedPhase = !l_valueArray[3].trim().isEmpty() ? + l_valueArray[3] : "N/A"; + + if (importedPhase.equals("N/A") || ExecutionMode.INTERRUPTIVE.behaviorTypes.contains(importedPhase)) { + this.setFailedInPhase(importedPhase); + } else { + throw new IllegalArgumentException( + "The given import string " + in_importString + + " does not allow us to deduce the Phase."); + } //TODO include the StepNr ? diff --git a/src/test/java/com/adobe/campaign/tests/integro/phased/MutationManagerTests.java b/src/test/java/com/adobe/campaign/tests/integro/phased/MutationManagerTests.java index c73296a..68a805c 100644 --- a/src/test/java/com/adobe/campaign/tests/integro/phased/MutationManagerTests.java +++ b/src/test/java/com/adobe/campaign/tests/integro/phased/MutationManagerTests.java @@ -127,32 +127,27 @@ public void testExecutionIndex_InterruptiveProducer() { assertThat("We should have two steps to execute in Producer", MutationManager.fetchExecutionIndex(testClass.getTypeName(), l_phaseGroup, - Phases.PRODUCER.fetchRunValues()), + new RunValues(ExecutionMode.INTERRUPTIVE, "PRODUCER")), Matchers.arrayContaining(0, 2)); assertThat("We should have one steps to executed in Consumer", MutationManager.fetchExecutionIndex(testClass.getTypeName(), l_phaseGroup, - Phases.CONSUMER.fetchRunValues()), + new RunValues(ExecutionMode.INTERRUPTIVE, "CONSUMER")), Matchers.arrayContaining(2, 3)); assertThat("We should have one steps to executed by default", MutationManager.fetchExecutionIndex(testClass.getTypeName(), l_phaseGroup, - Phases.NON_PHASED.fetchRunValues()), - Matchers.arrayContaining(0, 3)); - - assertThat("We should have one steps to executed by default", - MutationManager.fetchExecutionIndex(testClass.getTypeName(), l_phaseGroup, - ExecutionMode.DEFAULT.fetchRunValues()), + new RunValues(ExecutionMode.DEFAULT, "")), Matchers.arrayContaining(0, 3)); assertThat("We should have one steps to executed in Asynchronous", MutationManager.fetchExecutionIndex(testClass.getTypeName(), l_phaseGroup, - Phases.ASYNCHRONOUS.fetchRunValues()), + new RunValues(ExecutionMode.NON_INTERRUPTIVE, "23")), Matchers.arrayContaining(0, 3)); assertThat("We should have one steps to executed in permutational", MutationManager.fetchExecutionIndex(testClass.getTypeName(), l_phaseGroup, - Phases.PERMUTATIONAL.fetchRunValues()), + new RunValues(ExecutionMode.PERMUTATIONAL, "23")), Matchers.arrayContaining(0, 3)); } diff --git a/src/test/java/com/adobe/campaign/tests/integro/phased/PhasedTestManagerTests.java b/src/test/java/com/adobe/campaign/tests/integro/phased/PhasedTestManagerTests.java index 4aa2bf5..9f23f1a 100644 --- a/src/test/java/com/adobe/campaign/tests/integro/phased/PhasedTestManagerTests.java +++ b/src/test/java/com/adobe/campaign/tests/integro/phased/PhasedTestManagerTests.java @@ -226,7 +226,7 @@ public void exportingData() throws IOException { assertThat("We should find our scenario", prop.containsKey(l_storedScenarioContext)); assertThat("We should find our scenario", prop.get(l_storedScenarioContext), - Matchers.equalTo("true;0;NA;NON_PHASED")); + Matchers.equalTo("true;0;NA;N/A")); } @@ -515,7 +515,7 @@ public void dataBrokerPhasedTestManagerInitializing_negativeNotAClass() public void importingData() { String l_stepId = PhasedTestManager.produceInStep("Hello"); String l_scenarioId = PhasedTestManager.storeTestData(PhasedSeries_F_Shuffle.class, "A", - new PhasedTestManager.ScenarioContextData(false,3,"abc",Phases.PRODUCER,"zdf" )); + new PhasedTestManager.ScenarioContextData(false,3,"abc","PRODUCER","zdf" )); File l_phasedTestFile = PhasedTestManager.exportPhaseData(); PhasedTestManager.clearCache(); @@ -3186,9 +3186,9 @@ public void testScenarioContextDataToString() { l_scenarioContext.setFailedStep("abc"); assertThat("The toString method should correctly export the data", l_scenarioContext.exportToString(), - Matchers.equalTo("false;2;abc;NON_PHASED")); + Matchers.equalTo("false;2;abc;N/A")); - l_scenarioContext.setFailedInPhase(Phases.CONSUMER); + l_scenarioContext.setFailedInPhase("CONSUMER"); assertThat("The toString method should correctly export the data", l_scenarioContext.exportToString(), Matchers.equalTo("false;2;abc;CONSUMER")); @@ -3211,7 +3211,7 @@ public void testScenarioContextDataToString() { @Test public void testScenarioContextData_StringConstructor() { - PhasedTestManager.ScenarioContextData l_scenarioContext = new PhasedTestManager.ScenarioContextData(false,2,"abc",Phases.PRODUCER,"efg" ); + PhasedTestManager.ScenarioContextData l_scenarioContext = new PhasedTestManager.ScenarioContextData(false,2,"abc","PRODUCER","efg" ); assertThat("The toString method should correctly export the data", l_scenarioContext.exportToString(), Matchers.equalTo("false;2;abc;"+Phases.PRODUCER.name())); @@ -3227,7 +3227,7 @@ public void testScenarioContextData_StringConstructor() { assertThat("The failedStep should be correctly imported", l_scenarioContextImported.getFailedStep(), Matchers.equalTo(l_scenarioContext.getFailedStep())); assertThat("The phased in which the failure occurred should be the producer phase", - l_scenarioContextImported.getFailedInPhase(), equalTo(Phases.PRODUCER)); + l_scenarioContextImported.getFailedInPhase(), equalTo("PRODUCER")); assertThat("The phased in which the failure occurred should be the producer phase", l_scenarioContextImported.getCurrentStep(), equalTo(PhasedTestManager.ScenarioContextData.NOT_APPLICABLE_STEP_NAME)); @@ -3245,7 +3245,7 @@ public void testScenarioContextData_import1_emptyFailedTest() { assertThat("The failedStep should be correctly imported", l_scenarioContextImported.getFailedStep(), Matchers.equalTo("NA")); assertThat("The phased in which the failure occurred should be the producer phase", - l_scenarioContextImported.getFailedInPhase(), equalTo(Phases.NON_PHASED)); + l_scenarioContextImported.getFailedInPhase(), equalTo("N/A")); } @Test @@ -3260,7 +3260,7 @@ public void testScenarioContextData_import2_passed() { assertThat("The failedStep should be correctly imported", l_scenarioContextImported.getFailedStep(), Matchers.equalTo("NA")); assertThat("The phased in which the failure occurred should be the producer phase", - l_scenarioContextImported.getFailedInPhase(), equalTo(Phases.NON_PHASED)); + l_scenarioContextImported.getFailedInPhase(), equalTo("N/A")); l_scenarioContextImported.importFromString("true;2"); @@ -3270,7 +3270,7 @@ public void testScenarioContextData_import2_passed() { assertThat("The failedStep should be correctly imported", l_scenarioContextImported.getFailedStep(), Matchers.equalTo("NA")); assertThat("The phased in which the failure occurred should be the producer phase", - l_scenarioContextImported.getFailedInPhase(), equalTo(Phases.NON_PHASED)); + l_scenarioContextImported.getFailedInPhase(), equalTo("N/A")); } @Test @@ -3285,7 +3285,7 @@ public void testScenarioContextData_import3_failed() { assertThat("The failedStep should be correctly imported", l_scenarioContextImported.getFailedStep(), Matchers.equalTo("sd")); assertThat("The phased in which the failure occurred should be the producer phase", - l_scenarioContextImported.getFailedInPhase(), equalTo(Phases.NON_PHASED)); + l_scenarioContextImported.getFailedInPhase(), equalTo("N/A")); } @Test @@ -3300,7 +3300,7 @@ public void testScenarioContextData_import4_failed() { assertThat("The failedStep should be correctly imported", l_scenarioContextImported.getFailedStep(), Matchers.equalTo(PhasedTestManager.ScenarioContextData.NOT_APPLICABLE_STEP_NAME)); assertThat("The phased in which the failure occurred should be the producer phase", - l_scenarioContextImported.getFailedInPhase(), equalTo(Phases.NON_PHASED)); + l_scenarioContextImported.getFailedInPhase(), equalTo("N/A")); } @Test