From 0dbffafcc772e363fa6318c982a4b298ddab88cb Mon Sep 17 00:00:00 2001 From: Alexey Sandler Date: Wed, 1 Jan 2020 14:23:00 +0200 Subject: Add DB query for all model-service-ids which have a template Issue-ID: VID-739 Change-Id: Ib401f1fd312afb9652793854d49c8c7e5e115149 Signed-off-by: Alexey Sandler --- .../org/onap/vid/dal/AsyncInstantiationRepositoryTest.java | 11 +++++++++++ .../org/onap/vid/services/AsyncInstantiationBaseTest.java | 1 + 2 files changed, 12 insertions(+) (limited to 'vid-app-common/src/test/java') 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 27be3fb50..5f425fa3e 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 @@ -32,10 +32,12 @@ import static org.hamcrest.core.IsEqual.equalTo; import static org.onap.vid.job.Job.JobStatus.COMPLETED; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import java.time.LocalDateTime; import java.time.ZonedDateTime; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.UUID; import javax.inject.Inject; import org.onap.portalsdk.core.service.DataAccessService; @@ -84,6 +86,8 @@ public class AsyncInstantiationRepositoryTest extends AsyncInstantiationBaseTest MODEL_UUID, ServiceAction.INSTANTIATE); addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "hidden", NOW, NOW, COMPLETED, true, false, MODEL_UUID, ServiceAction.INSTANTIATE); + addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "4", NOW, NOW, COMPLETED, false, false, + MODEL_UUID_3, ServiceAction.UPDATE); } @DataProvider @@ -102,6 +106,13 @@ public class AsyncInstantiationRepositoryTest extends AsyncInstantiationBaseTest contains(expectedResult)); } + @Test + public void getAllTemplatesServiceModelIds_givenDbWithSeveralModelIDs_2ReturnedAnd1OmittedAndDuplicatesRemoved() { + Set actual = asyncInstantiationRepository.getAllTemplatesServiceModelIds(); + // MODEL_UUID3 is Action=UPDATE, therefore omitted + assertThat(actual, equalTo(ImmutableSet.of(MODEL_UUID, MODEL_UUID_2))); + } + @Test public void whenFilterServiceByNotExistUUID_emptyListIsReturned() { List serviceInfoListResult = asyncInstantiationRepository.listInstantiatedServicesByServiceModelId(UUID.randomUUID()); 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 7c0abbe6e..b9535000a 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 @@ -79,6 +79,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests public static final String MODEL_UUID = "337be3fc-293e-43ec-af0b-cf932dad07e6"; public static final String MODEL_UUID_2 = "ce052844-22ba-4030-a838-822f2b39eb9b"; + public static final String MODEL_UUID_3 = "47a071cd-99f7-49bb-bc8b-f957979d6fe1"; public static final String OWNING_ENTITY_ID = "038d99af-0427-42c2-9d15-971b99b9b489"; public static final String JULIO_ERICKSON = "JULIO ERICKSON"; -- cgit 1.2.3-korg