summaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
authorEinat Vinouze <einat.vinouze@intl.att.com>2020-05-20 12:00:29 +0300
committerEinat Vinouze <einat.vinouze@intl.att.com>2020-05-21 08:32:30 +0300
commitcb024eb027cb9e0776359a9ee06b1caec4592256 (patch)
tree0c264aa8b5461d88ab3eb40e2bd35989588145a6 /vid-app-common
parent19016e3c0951ff994956e93b1c24e412a7ed542e (diff)
Set JobStatus as COMPLETED_AND_PAUSED when needed so we can present it on instantiationStatus
Issue-ID: VID-821 Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com> Change-Id: I19328ce643ea984a97dc04183626dea133be517d Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com>
Diffstat (limited to 'vid-app-common')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/Job.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt14
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/WatchChildrenJobsBL.kt3
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java110
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/command/WatchChildrenJobsBLTest.java28
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java9
6 files changed, 98 insertions, 70 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/Job.java b/vid-app-common/src/main/java/org/onap/vid/job/Job.java
index 197e03b7b..9861d0703 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/Job.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/Job.java
@@ -21,13 +21,12 @@
package org.onap.vid.job;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import org.onap.vid.job.impl.JobSharedData;
-
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import org.onap.vid.job.impl.JobSharedData;
public interface Job {
@@ -68,6 +67,7 @@ public interface Job {
COMPLETED_WITH_NO_ACTION(true, false),
CREATING(false),
PENDING_RESOURCE(false),
+ COMPLETED_AND_PAUSED(true, false),
;
private final Boolean finalStatus;
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt
index 9b4f8b985..3ecb4aed3 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt
@@ -230,7 +230,7 @@ abstract class ResourceCommand(
InternalState.IN_PROGRESS -> {
when {
- jobStatus != JobStatus.COMPLETED -> InternalState.IN_PROGRESS
+ jobStatus !in setOf(JobStatus.COMPLETED, JobStatus.COMPLETED_AND_PAUSED) -> InternalState.IN_PROGRESS
isDescendantHasAction(Action.Create) -> InternalState.CREATING_CHILDREN
isDescendantHasAction(Action.Upgrade) -> InternalState.CREATING_CHILDREN
else -> InternalState.TERMINAL
@@ -385,9 +385,19 @@ abstract class ResourceCommand(
protected open fun getExpiryChecker(): ExpiryChecker = ExpiryChecker {false}
protected open fun handleInProgressStatus(jobStatus: JobStatus): JobStatus {
- return if (jobStatus == JobStatus.PAUSE) JobStatus.IN_PROGRESS else jobStatus
+ if (jobStatus == JobStatus.PAUSE){
+ return JobStatus.IN_PROGRESS
+ } else if (completedAndPaused(jobStatus)){
+ return JobStatus.COMPLETED_AND_PAUSED
+ }
+ return jobStatus
}
+ private fun completedAndPaused(jobStatus: JobStatus) =
+ jobStatus == JobStatus.COMPLETED && getRequest().pauseInstantiation == afterCompletion
+ && featureManager.isActive(Features.FLAG_2006_PAUSE_VFMODULE_INSTANTIATION_CREATION)
+
+
protected open fun watchChildren():JobStatus {
return watchChildrenJobsBL.retrieveChildrenJobsStatus(childJobs)
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/WatchChildrenJobsBL.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/WatchChildrenJobsBL.kt
index 194fe4ba2..502d8344d 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/WatchChildrenJobsBL.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/WatchChildrenJobsBL.kt
@@ -21,11 +21,11 @@
package org.onap.vid.job.command
import org.apache.commons.lang3.StringUtils
+import org.onap.portalsdk.core.service.DataAccessService
import org.onap.vid.job.Job
import org.onap.vid.job.Job.JobStatus.*
import org.onap.vid.job.impl.JobDaoImpl
import org.onap.vid.utils.DaoUtils
-import org.onap.portalsdk.core.service.DataAccessService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import java.util.*
@@ -63,6 +63,7 @@ constructor(private val dataAccessService: DataAccessService) {
a == COMPLETED_WITH_ERRORS || b == COMPLETED_WITH_ERRORS-> COMPLETED_WITH_ERRORS
a == COMPLETED && b.isFailure -> COMPLETED_WITH_ERRORS
b == COMPLETED && a.isFailure -> COMPLETED_WITH_ERRORS
+ a == COMPLETED_AND_PAUSED || b == COMPLETED_AND_PAUSED -> COMPLETED_AND_PAUSED
a == COMPLETED || b == COMPLETED -> COMPLETED
a.isFailure || b.isFailure -> FAILED
else -> COMPLETED_WITH_NO_ACTION
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java
index 9d466f4b3..85faaab28 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java
@@ -28,6 +28,14 @@ import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import static org.onap.vid.job.Job.JobStatus.COMPLETED;
+import static org.onap.vid.job.Job.JobStatus.COMPLETED_WITH_ERRORS;
+import static org.onap.vid.job.Job.JobStatus.COMPLETED_WITH_NO_ACTION;
+import static org.onap.vid.job.Job.JobStatus.FAILED;
+import static org.onap.vid.job.Job.JobStatus.IN_PROGRESS;
+import static org.onap.vid.job.Job.JobStatus.PAUSE;
+import static org.onap.vid.job.Job.JobStatus.RESOURCE_IN_PROGRESS;
+import static org.onap.vid.job.Job.JobStatus.STOPPED;
import static org.onap.vid.job.command.ResourceCommandKt.ACTION_PHASE;
import static org.onap.vid.job.command.ResourceCommandKt.INTERNAL_STATE;
import static org.onap.vid.job.command.ResourceCommandTest.FakeResourceCreator.createGroup;
@@ -212,14 +220,14 @@ public class ResourceCommandTest {
@DataProvider
public static Object[][] nextStateDeletePhaseProvider() {
return new Object[][]{
- {InternalState.CREATING_CHILDREN, Job.JobStatus.COMPLETED, InternalState.WATCHING},
- {InternalState.WATCHING, Job.JobStatus.COMPLETED, InternalState.DELETE_MYSELF},
- {InternalState.WATCHING, Job.JobStatus.IN_PROGRESS, InternalState.WATCHING},
- {InternalState.WATCHING, Job.JobStatus.RESOURCE_IN_PROGRESS, InternalState.WATCHING},
- {InternalState.DELETE_MYSELF, Job.JobStatus.COMPLETED, InternalState.IN_PROGRESS},
- {InternalState.IN_PROGRESS, Job.JobStatus.COMPLETED, InternalState.TERMINAL},
- {InternalState.IN_PROGRESS, Job.JobStatus.IN_PROGRESS, InternalState.IN_PROGRESS},
- {InternalState.IN_PROGRESS, Job.JobStatus.RESOURCE_IN_PROGRESS, InternalState.IN_PROGRESS},
+ {InternalState.CREATING_CHILDREN, COMPLETED, InternalState.WATCHING},
+ {InternalState.WATCHING, COMPLETED, InternalState.DELETE_MYSELF},
+ {InternalState.WATCHING, IN_PROGRESS, InternalState.WATCHING},
+ {InternalState.WATCHING, RESOURCE_IN_PROGRESS, InternalState.WATCHING},
+ {InternalState.DELETE_MYSELF, COMPLETED, InternalState.IN_PROGRESS},
+ {InternalState.IN_PROGRESS, COMPLETED, InternalState.TERMINAL},
+ {InternalState.IN_PROGRESS, IN_PROGRESS, InternalState.IN_PROGRESS},
+ {InternalState.IN_PROGRESS, RESOURCE_IN_PROGRESS, InternalState.IN_PROGRESS},
};
}
@@ -228,28 +236,28 @@ public class ResourceCommandTest {
InternalState internalState, Job.JobStatus jobStatus, InternalState expectedState) {
//there is no meaning to the constructor inputs here
- MockCommandTestingStateMachine underTest = new MockCommandTestingStateMachine(InternalState.TERMINAL, Delete, Job.JobStatus.FAILED, true);
+ MockCommandTestingStateMachine underTest = new MockCommandTestingStateMachine(InternalState.TERMINAL, Delete, FAILED, true);
assertEquals(expectedState, underTest.calcNextStateDeletePhase(jobStatus, internalState));
}
@Test
public void whenNoNeedToDeleteMyself_internalStateMovesFromWatchingToTerminal() {
- MockCommandTestingStateMachine underTest = new MockCommandTestingStateMachine(InternalState.WATCHING, Delete, Job.JobStatus.COMPLETED, false);
- assertEquals(InternalState.TERMINAL, underTest.calcNextStateDeletePhase(Job.JobStatus.COMPLETED, InternalState.WATCHING));
+ MockCommandTestingStateMachine underTest = new MockCommandTestingStateMachine(InternalState.WATCHING, Delete, COMPLETED, false);
+ assertEquals(InternalState.TERMINAL, underTest.calcNextStateDeletePhase(COMPLETED, InternalState.WATCHING));
}
@DataProvider
public static Object[][] testShallStopJobDataProvider() {
return new Object[][]{
- {Job.JobStatus.IN_PROGRESS, None, false, false},
- {Job.JobStatus.COMPLETED_WITH_NO_ACTION, None, false, false},
- {Job.JobStatus.COMPLETED, None, false, false},
- {Job.JobStatus.FAILED, None, false, true},
- {Job.JobStatus.COMPLETED_WITH_ERRORS, None, false, true},
- {Job.JobStatus.COMPLETED_WITH_ERRORS, None, true, false},
- {Job.JobStatus.FAILED, None, true, false},
- {Job.JobStatus.FAILED, Delete, true, true},
- {Job.JobStatus.FAILED, Create, true, true},
+ {IN_PROGRESS, None, false, false},
+ {COMPLETED_WITH_NO_ACTION, None, false, false},
+ {COMPLETED, None, false, false},
+ {FAILED, None, false, true},
+ {COMPLETED_WITH_ERRORS, None, false, true},
+ {COMPLETED_WITH_ERRORS, None, true, false},
+ {FAILED, None, true, false},
+ {FAILED, Delete, true, true},
+ {FAILED, Create, true, true},
};
}
@@ -257,7 +265,7 @@ public class ResourceCommandTest {
@Test(dataProvider = "testShallStopJobDataProvider")
public void testShallStopJob(Job.JobStatus jobStatus, Action action, boolean isService, boolean expectedResult) {
//in this test, there is no meaning to constructor parameters besides isService
- MockCommandTestingStateMachine underTest = new MockCommandTestingStateMachine(InternalState.WATCHING, Delete, Job.JobStatus.COMPLETED, false, isService, true);
+ MockCommandTestingStateMachine underTest = new MockCommandTestingStateMachine(InternalState.WATCHING, Delete, COMPLETED, false, isService, true);
BaseResource mockedRequest = mock(BaseResource.class);
when(underTest.getSharedData().getRequest()).thenReturn(mockedRequest);
@@ -355,27 +363,27 @@ public class ResourceCommandTest {
@Test(dataProvider = "testIsDescendantHasActionDataProvider")
public void testIsDescendantHasAction(String desc, Action action, boolean expectedResult, BaseResource request) {
//in this test, there is no meaning to constructor parameters
- MockCommand underTest = new MockCommand(InternalState.WATCHING, Delete, Job.JobStatus.COMPLETED);
+ MockCommand underTest = new MockCommand(InternalState.WATCHING, Delete, COMPLETED);
assertEquals(expectedResult, underTest.isDescendantHasAction(request, action));
}
@DataProvider
public static Object[][] testCallDataProvider() {
return new Object[][]{
- {"initial state with successful creating children" ,InternalState.INITIAL, Job.JobStatus.COMPLETED, InternalState.WATCHING, Job.JobStatus.RESOURCE_IN_PROGRESS},
- {"initial state with failed creating children", InternalState.INITIAL, Job.JobStatus.FAILED, null, Job.JobStatus.FAILED},
- {"watching state with children still in progress" ,InternalState.WATCHING, Job.JobStatus.RESOURCE_IN_PROGRESS, InternalState.WATCHING, Job.JobStatus.RESOURCE_IN_PROGRESS},
- {"watching state with children that completed with errors" ,InternalState.WATCHING, Job.JobStatus.COMPLETED_WITH_ERRORS, null, Job.JobStatus.COMPLETED_WITH_ERRORS},
- {"watching state with children that completed with no action" ,InternalState.WATCHING, Job.JobStatus.COMPLETED_WITH_NO_ACTION, InternalState.DELETE_MYSELF, Job.JobStatus.RESOURCE_IN_PROGRESS},
- {"watching state with children that has completed" ,InternalState.WATCHING, Job.JobStatus.COMPLETED, InternalState.DELETE_MYSELF, Job.JobStatus.RESOURCE_IN_PROGRESS},
- {"mso call state that failed" ,InternalState.DELETE_MYSELF, Job.JobStatus.FAILED, null, Job.JobStatus.FAILED},
+ {"initial state with successful creating children" ,InternalState.INITIAL, COMPLETED, InternalState.WATCHING, RESOURCE_IN_PROGRESS},
+ {"initial state with failed creating children", InternalState.INITIAL, FAILED, null, FAILED},
+ {"watching state with children still in progress" ,InternalState.WATCHING, RESOURCE_IN_PROGRESS, InternalState.WATCHING, RESOURCE_IN_PROGRESS},
+ {"watching state with children that completed with errors" ,InternalState.WATCHING, COMPLETED_WITH_ERRORS, null, COMPLETED_WITH_ERRORS},
+ {"watching state with children that completed with no action" ,InternalState.WATCHING, COMPLETED_WITH_NO_ACTION, InternalState.DELETE_MYSELF, RESOURCE_IN_PROGRESS},
+ {"watching state with children that has completed" ,InternalState.WATCHING, COMPLETED, InternalState.DELETE_MYSELF, RESOURCE_IN_PROGRESS},
+ {"mso call state that failed" ,InternalState.DELETE_MYSELF, FAILED, null, FAILED},
//TODO handle AAI get unique name state {"mso call state that still in progress" ,InternalState.DELETE_MYSELF, Job.JobStatus.FAILED, null, Job.JobStatus.FAILED, false},
- {"mso call state that success" ,InternalState.DELETE_MYSELF, Job.JobStatus.COMPLETED, InternalState.IN_PROGRESS, Job.JobStatus.RESOURCE_IN_PROGRESS},
- {"in progress return in progress" ,InternalState.IN_PROGRESS, Job.JobStatus.IN_PROGRESS, InternalState.IN_PROGRESS, Job.JobStatus.RESOURCE_IN_PROGRESS},
- {"in progress return in pause" ,InternalState.IN_PROGRESS, Job.JobStatus.PAUSE, InternalState.IN_PROGRESS, Job.JobStatus.RESOURCE_IN_PROGRESS},
- {"in progress return in pause" ,InternalState.IN_PROGRESS, Job.JobStatus.STOPPED, null, Job.JobStatus.STOPPED},
- {"in progress return in pause" ,InternalState.IN_PROGRESS, Job.JobStatus.FAILED, null, Job.JobStatus.FAILED},
- {"in progress return in pause" ,InternalState.IN_PROGRESS, Job.JobStatus.COMPLETED, null, Job.JobStatus.COMPLETED},
+ {"mso call state that success" ,InternalState.DELETE_MYSELF, COMPLETED, InternalState.IN_PROGRESS, RESOURCE_IN_PROGRESS},
+ {"in progress return in progress" ,InternalState.IN_PROGRESS, IN_PROGRESS, InternalState.IN_PROGRESS, RESOURCE_IN_PROGRESS},
+ {"in progress return in pause" ,InternalState.IN_PROGRESS, PAUSE, InternalState.IN_PROGRESS, RESOURCE_IN_PROGRESS},
+ {"in progress return in pause" ,InternalState.IN_PROGRESS, STOPPED, null, STOPPED},
+ {"in progress return in pause" ,InternalState.IN_PROGRESS, FAILED, null, FAILED},
+ {"in progress return in pause" ,InternalState.IN_PROGRESS, COMPLETED, null, COMPLETED},
};
}
@@ -409,18 +417,24 @@ public class ResourceCommandTest {
@Test(dataProvider = "InProgressDataProvider")
public void whenGetResultFromMso_InProgressReturnThem(Job.JobStatus mockedJobStatus) {
- Job.JobStatus expectedJobStatus = (mockedJobStatus== Job.JobStatus.PAUSE) ? Job.JobStatus.IN_PROGRESS : mockedJobStatus;
+ Job.JobStatus expectedJobStatus = (mockedJobStatus== PAUSE) ? IN_PROGRESS : mockedJobStatus;
MockCommand underTest = new MockCommand(InternalState.IN_PROGRESS, Delete, mockedJobStatus);
when(underTest.getInProgressStatusService().call(any(), any(), any())).thenReturn(mockedJobStatus);
+
+ // we need to mock the request for pause after completion only when the status is completed
+ if(mockedJobStatus == COMPLETED){
+ BaseResource mockedBaseResource = mock(BaseResource.class);
+ when(underTest.getSharedData().getRequest()).thenReturn(mockedBaseResource);
+ }
assertEquals(expectedJobStatus, underTest.inProgress());
}
@DataProvider
public static Object[][] InProgressExceptionsDataProvider() {
return new Object[][]{
- {new ProcessingException(""), Job.JobStatus.IN_PROGRESS},
- {new InProgressStatusService.BadResponseFromMso(null), Job.JobStatus.IN_PROGRESS},
- {new GenericUncheckedException(""),Job.JobStatus.STOPPED }
+ {new ProcessingException(""), IN_PROGRESS},
+ {new InProgressStatusService.BadResponseFromMso(null), IN_PROGRESS},
+ {new GenericUncheckedException(""), STOPPED }
};
}
@@ -441,7 +455,7 @@ public class ResourceCommandTest {
@Test(dataProvider = "testIsNeedToDeleteMySelfDataProvider")
public void testIsNeedToDeleteMySelf(Action action) {
boolean expectedResult = (action== Delete);
- MockCommand underTest = new MockCommand(InternalState.DELETE_MYSELF, Delete, Job.JobStatus.IN_PROGRESS);
+ MockCommand underTest = new MockCommand(InternalState.DELETE_MYSELF, Delete, IN_PROGRESS);
BaseResource mockedBaseResource = mock(BaseResource.class);
when(underTest.getSharedData().getRequest()).thenReturn(mockedBaseResource);
when(mockedBaseResource.getAction()).thenReturn(action);
@@ -451,15 +465,15 @@ public class ResourceCommandTest {
@DataProvider
public static Object[][] testWatchingDataProvider() {
return new Object[][]{
- {"all children final, no failed child ", Job.JobStatus.COMPLETED, Job.JobStatus.COMPLETED},
- {"all children final, there is failed child ", Job.JobStatus.COMPLETED_WITH_ERRORS, Job.JobStatus.COMPLETED_WITH_ERRORS},
- {"not all children final", Job.JobStatus.IN_PROGRESS, Job.JobStatus.IN_PROGRESS},
+ {"all children final, no failed child ", COMPLETED, COMPLETED},
+ {"all children final, there is failed child ", COMPLETED_WITH_ERRORS, COMPLETED_WITH_ERRORS},
+ {"not all children final", IN_PROGRESS, IN_PROGRESS},
};
}
@Test(dataProvider = "testWatchingDataProvider")
public void testWatching(String desc, Job.JobStatus childrenJobsStatus, Job.JobStatus expectedJobStatus) {
- MockCommand underTest = new MockCommand(InternalState.WATCHING, Delete, Job.JobStatus.IN_PROGRESS);
+ MockCommand underTest = new MockCommand(InternalState.WATCHING, Delete, IN_PROGRESS);
when(underTest.getWatchChildrenJobsBL().retrieveChildrenJobsStatus(any())).thenReturn(childrenJobsStatus);
assertEquals(expectedJobStatus, underTest.watchChildren());
}
@@ -502,7 +516,7 @@ public class ResourceCommandTest {
private final RuntimeException exceptionToThrow;
public MockCommandThrowExceptionOnCreateChildren(RuntimeException exceptionToThrow) {
- super(InternalState.CREATING_CHILDREN, Delete, Job.JobStatus.COMPLETED, true);
+ super(InternalState.CREATING_CHILDREN, Delete, COMPLETED, true);
this.exceptionToThrow = exceptionToThrow;
doAnswer(returnsFirstArg()).when(this.getWatchChildrenJobsBL()).cumulateJobStatus(any(), any());
}
@@ -517,8 +531,8 @@ public class ResourceCommandTest {
@DataProvider
public static Object[][] exceptionAndStateProvider() {
return new Object[][]{
- {new TryAgainException(new Exception()), Job.JobStatus.RESOURCE_IN_PROGRESS},
- {new AbortingException(new Exception()), Job.JobStatus.FAILED},
+ {new TryAgainException(new Exception()), RESOURCE_IN_PROGRESS},
+ {new AbortingException(new Exception()), FAILED},
};
}
@@ -548,7 +562,7 @@ public class ResourceCommandTest {
BaseResource mockedRequest3 = mock(BaseResource.class);
when(mockedRequest3.getPosition()).thenReturn(thirdPosition);
- MockCommand underTest = new MockCommand(InternalState.CREATING_CHILDREN, Create, Job.JobStatus.IN_PROGRESS);
+ MockCommand underTest = new MockCommand(InternalState.CREATING_CHILDREN, Create, IN_PROGRESS);
List<Pair<BaseResource, Integer>> sortedList = underTest.setPositionWhereIsMissing(ImmutableList.of(mockedRequest1, mockedRequest2, mockedRequest3));
assertEquals(sortedList.get(0).getSecond(),expectedPositions.get(0));
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/WatchChildrenJobsBLTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/WatchChildrenJobsBLTest.java
index a9a961db8..fad32bba6 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/command/WatchChildrenJobsBLTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/command/WatchChildrenJobsBLTest.java
@@ -20,27 +20,28 @@
package org.onap.vid.job.command;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+import static org.testng.AssertJUnit.assertEquals;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.vid.job.Job.JobStatus;
import org.onap.vid.job.impl.JobDaoImpl;
import org.onap.vid.utils.DaoUtils;
-import org.onap.portalsdk.core.service.DataAccessService;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-import static org.mockito.ArgumentMatchers.*;
-import static org.mockito.Mockito.when;
-import static org.testng.AssertJUnit.assertEquals;
-
public class WatchChildrenJobsBLTest {
@Mock
private DataAccessService dataAccessService;
@@ -90,8 +91,9 @@ public class WatchChildrenJobsBLTest {
{Arrays.asList(JobStatus.COMPLETED_WITH_ERRORS, JobStatus.COMPLETED_WITH_ERRORS), JobStatus.COMPLETED_WITH_ERRORS},
{Arrays.asList(JobStatus.COMPLETED_WITH_ERRORS, JobStatus.COMPLETED_WITH_NO_ACTION), JobStatus.COMPLETED_WITH_ERRORS},
{Arrays.asList(JobStatus.COMPLETED_WITH_NO_ACTION, JobStatus.COMPLETED_WITH_NO_ACTION), JobStatus.COMPLETED_WITH_NO_ACTION},
-
-
+ {Arrays.asList(JobStatus.COMPLETED_AND_PAUSED, JobStatus.RESOURCE_IN_PROGRESS), JobStatus.IN_PROGRESS},
+ {Arrays.asList(JobStatus.COMPLETED_AND_PAUSED, JobStatus.COMPLETED), JobStatus.COMPLETED_AND_PAUSED},
+ {Arrays.asList(JobStatus.COMPLETED_AND_PAUSED, JobStatus.IN_PROGRESS), JobStatus.IN_PROGRESS},
};
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java b/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java
index 061b62af2..ce94a7096 100644
--- a/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java
@@ -47,6 +47,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.onap.vid.job.Job.JobStatus.COMPLETED;
+import static org.onap.vid.job.Job.JobStatus.COMPLETED_AND_PAUSED;
import static org.onap.vid.job.Job.JobStatus.COMPLETED_WITH_ERRORS;
import static org.onap.vid.job.Job.JobStatus.COMPLETED_WITH_NO_ACTION;
import static org.onap.vid.job.Job.JobStatus.FAILED;
@@ -1033,16 +1034,16 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes
@DataProvider
public static Object[][] pauseInstantiation(Method test) {
return new Object[][]{
- {true, 2},
- {false, 3}
+ {true, 2, COMPLETED_AND_PAUSED},
+ {false, 3, COMPLETED}
};
}
@Test (dataProvider = "pauseInstantiation")
- public void viewEdit_existingVnfCreate3VfModulesPauseAfterTheSecond(boolean flag, int expectedNumberOfInvocation) {
+ public void viewEdit_existingVnfCreate3VfModulesPauseAfterTheSecond(boolean flag, int expectedNumberOfInvocation,
+ JobStatus expectedJobStatus) {
RestObject<RequestReferencesContainer> createVfModuleResponse = createResponseRandomIds(202);
RestObject<AsyncRequestStatus> createStatusResponse = asyncRequestStatusResponseAsRestObject(COMPLETE_STR);
- JobStatus expectedJobStatus = COMPLETED;
when(featureManager.isActive(Features.FLAG_2006_PAUSE_VFMODULE_INSTANTIATION_CREATION)).thenReturn(flag);