aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2019-12-19 07:13:57 +0000
committerGerrit Code Review <gerrit@onap.org>2019-12-19 07:13:57 +0000
commitfa71335438b9425fbf50c79be92dc541b7b103ce (patch)
treee627a819b69b127c55d0770b5cd94e0f93df72fe
parent50f08102564af0938a66071af6c1d1fbf6667943 (diff)
parentfbb6e45a9186104f50162472e05b4bd76d20de5c (diff)
Merge "on templates - filter only Action==INSTANTIATE"
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt9
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java24
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java24
4 files changed, 41 insertions, 18 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
index 96e777a13..c73a01877 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/AsyncInstantiationController.java
@@ -92,7 +92,7 @@ public class AsyncInstantiationController extends VidRestrictedBaseController {
if (serviceModelId == null) {
return asyncInstantiationBL.getAllServicesInfo();
} else {
- return asyncInstantiationRepository.listServicesByServiceModelId(serviceModelId);
+ return asyncInstantiationRepository.listInstantiatedServicesByServiceModelId(serviceModelId);
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt b/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt
index c26b88a5e..e26247281 100644
--- a/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt
@@ -90,9 +90,10 @@ class AsyncInstantiationRepository @Autowired constructor(val dataAccessService:
" and created >= '" + filterDate + "' "
}
- private fun filterByServiceModelId(serviceModelUuid: UUID): String {
+ private fun filterInstantiatedServiceByServiceModelId(serviceModelUuid: UUID): String {
return filterServicesByNotHiddenAndNotDeleted() +
- " and SERVICE_MODEL_ID = '$serviceModelUuid'"
+ " and SERVICE_MODEL_ID = '$serviceModelUuid'" +
+ " and ACTION = 'INSTANTIATE'"
}
private fun filterServicesByNotHiddenAndNotDeleted(): String {
@@ -154,6 +155,6 @@ class AsyncInstantiationRepository @Autowired constructor(val dataAccessService:
return dataAccessService.getList(className, " WHERE $condition", orderBy, null) as List<T>
}
- fun listServicesByServiceModelId(serviceModelId: UUID): List<ServiceInfo> =
- dataAccessService.getList(ServiceInfo::class.java, filterByServiceModelId(serviceModelId), orderByCreatedDateAndStatus(), null) as List<ServiceInfo>;
+ fun listInstantiatedServicesByServiceModelId(serviceModelId: UUID): List<ServiceInfo> =
+ dataAccessService.getList(ServiceInfo::class.java, filterInstantiatedServiceByServiceModelId(serviceModelId), orderByCreatedDateAndStatus(), null) as List<ServiceInfo>;
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java b/vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java
index 012c37f4d..27be3fb50 100644
--- a/vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java
@@ -45,6 +45,7 @@ import org.onap.vid.config.MockedAaiClientAndFeatureManagerConfig;
import org.onap.vid.job.Job;
import org.onap.vid.model.ResourceInfo;
import org.onap.vid.model.ServiceInfo;
+import org.onap.vid.model.ServiceInfo.ServiceAction;
import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
import org.onap.vid.mso.rest.AsyncRequestStatus;
import org.onap.vid.mso.rest.RequestStatus;
@@ -73,14 +74,16 @@ public class AsyncInstantiationRepositoryTest extends AsyncInstantiationBaseTest
LocalDateTime NOW = LocalDateTime.now();
- addNewServiceInfo(UUID.randomUUID(), "abc", "1", NOW.minusYears(1L), NOW, COMPLETED, false, false,
- MODEL_UUID);
- addNewServiceInfo(UUID.randomUUID(), "abc", "2", NOW, NOW, COMPLETED, false, false,
- MODEL_UUID_2);
- addNewServiceInfo(UUID.randomUUID(), "abc", "3", NOW, NOW, COMPLETED, false, false,
- MODEL_UUID);
- addNewServiceInfo(UUID.randomUUID(), "abc", "hidden", NOW, NOW, COMPLETED, true, false,
- MODEL_UUID);
+ addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "0", NOW.minusYears(1L), NOW, COMPLETED, false, false,
+ MODEL_UUID, ServiceAction.RESUME);
+ addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "1", NOW.minusYears(1L), NOW, COMPLETED, false, false,
+ MODEL_UUID, ServiceAction.INSTANTIATE);
+ addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "2", NOW, NOW, COMPLETED, false, false,
+ MODEL_UUID_2, ServiceAction.INSTANTIATE);
+ addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "3", NOW, NOW, COMPLETED, false, false,
+ MODEL_UUID, ServiceAction.INSTANTIATE);
+ addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "hidden", NOW, NOW, COMPLETED, true, false,
+ MODEL_UUID, ServiceAction.INSTANTIATE);
}
@DataProvider
@@ -93,14 +96,15 @@ public class AsyncInstantiationRepositoryTest extends AsyncInstantiationBaseTest
@Test(dataProvider = "listServicesByServiceModelIdDataProvider")
public void testListServicesByServiceModelId(String desc, String modelUUID, String... expectedResult) {
- List<ServiceInfo> serviceInfoListResult = asyncInstantiationRepository.listServicesByServiceModelId(UUID.fromString(modelUUID));
+ List<ServiceInfo> serviceInfoListResult = asyncInstantiationRepository.
+ listInstantiatedServicesByServiceModelId(UUID.fromString(modelUUID));
assertThat(desc, serviceInfoListResult.stream().map(ServiceInfo::getServiceInstanceName).collect(toList()),
contains(expectedResult));
}
@Test
public void whenFilterServiceByNotExistUUID_emptyListIsReturned() {
- List<ServiceInfo> serviceInfoListResult = asyncInstantiationRepository.listServicesByServiceModelId(UUID.randomUUID());
+ List<ServiceInfo> serviceInfoListResult = asyncInstantiationRepository.listInstantiatedServicesByServiceModelId(UUID.randomUUID());
assertThat(serviceInfoListResult, is(empty()));
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
index d41ce87bf..7c0abbe6e 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
@@ -23,7 +23,6 @@ package org.onap.vid.services;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.IsEqual.equalTo;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -49,6 +48,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.inject.Inject;
import org.hibernate.SessionFactory;
+import org.jetbrains.annotations.NotNull;
import org.onap.portalsdk.core.domain.FusionObject;
import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.vid.aai.AaiClientInterface;
@@ -56,6 +56,7 @@ import org.onap.vid.aai.ExceptionWithRequestInfo;
import org.onap.vid.job.Job.JobStatus;
import org.onap.vid.model.Action;
import org.onap.vid.model.ServiceInfo;
+import org.onap.vid.model.ServiceInfo.ServiceAction;
import org.onap.vid.model.VidNotions;
import org.onap.vid.model.serviceInstantiation.InstanceGroup;
import org.onap.vid.model.serviceInstantiation.Network;
@@ -67,7 +68,6 @@ import org.onap.vid.mso.model.ModelInfo;
import org.onap.vid.mso.rest.AsyncRequestStatus;
import org.onap.vid.mso.rest.RequestStatus;
import org.onap.vid.properties.Features;
-import org.onap.vid.services.AsyncInstantiationBusinessLogicTest.ServiceInfoComparator;
import org.onap.vid.utils.DaoUtils;
import org.onap.vid.utils.TimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -149,9 +149,19 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
});
}
+
protected void addNewServiceInfo(UUID uuid, String userId, String serviceName, LocalDateTime createDate,
LocalDateTime statusModifiedDate, JobStatus status, boolean isHidden, boolean retryEnabled,
String modelUUID) {
+ ServiceInfo serviceInfo = createServiceInfo(uuid, userId, serviceName, createDate, statusModifiedDate, status,
+ isHidden, retryEnabled, modelUUID);
+ dataAccessService.saveDomainObject(serviceInfo, getPropsMap());
+ setCreateDateToServiceInfo(uuid, createDate);
+ serviceCount++;
+ }
+ @NotNull
+ private ServiceInfo createServiceInfo(UUID uuid, String userId, String serviceName, LocalDateTime createDate,
+ LocalDateTime statusModifiedDate, JobStatus status, boolean isHidden, boolean retryEnabled, String modelUUID) {
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setJobId(uuid);
serviceInfo.setUserId(userId);
@@ -164,10 +174,18 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
serviceInfo.setRetryEnabled(retryEnabled);
serviceInfo.setServiceModelId(modelUUID);
serviceInfo.setHidden(isHidden);
+ return serviceInfo;
+ }
+
+ protected void addNewServiceInfoWithAction(UUID uuid, String userId, String serviceName, LocalDateTime createDate,
+ LocalDateTime statusModifiedDate, JobStatus status, boolean isHidden, boolean retryEnabled,
+ String modelUUID, ServiceAction action) {
+ ServiceInfo serviceInfo = createServiceInfo(uuid, userId, serviceName, createDate, statusModifiedDate, status,
+ isHidden, retryEnabled, modelUUID);
+ serviceInfo.setAction(action);
dataAccessService.saveDomainObject(serviceInfo, getPropsMap());
setCreateDateToServiceInfo(uuid, createDate);
serviceCount++;
-
}