" and created >= '" + filterDate + "' "
}
- private fun filterInstantiatedServiceByServiceModelId(serviceModelUuid: UUID): String {
+ private fun filterByInstantiateActionStatus(): String{
return filterServicesByNotHiddenAndNotDeleted() +
- " and SERVICE_MODEL_ID = '$serviceModelUuid'" +
" and ACTION = 'INSTANTIATE'"
}
+ private fun filterInstantiatedServiceByServiceModelId(serviceModelUuid: UUID): String {
+ return filterByInstantiateActionStatus() +
+ " and SERVICE_MODEL_ID = '$serviceModelUuid'"
+ }
+
private fun filterServicesByNotHiddenAndNotDeleted(): String {
return " WHERE" +
" hidden = false" +
fun listInstantiatedServicesByServiceModelId(serviceModelId: UUID): List<ServiceInfo> =
dataAccessService.getList(ServiceInfo::class.java, filterInstantiatedServiceByServiceModelId(serviceModelId), orderByCreatedDateAndStatus(), null) as List<ServiceInfo>;
+
+ fun getAllTemplatesServiceModelIds(): Set<String> {
+ val allTemplatesInfo =
+ dataAccessService.getList(ServiceInfo::class.java, filterByInstantiateActionStatus(), null, null) as List<ServiceInfo>
+
+ return allTemplatesInfo
+ .map { it.serviceModelId }
+ .toHashSet()
+ }
}
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;
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
contains(expectedResult));
}
+ @Test
+ public void getAllTemplatesServiceModelIds_givenDbWithSeveralModelIDs_2ReturnedAnd1OmittedAndDuplicatesRemoved() {
+ Set<String> 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<ServiceInfo> serviceInfoListResult = asyncInstantiationRepository.listInstantiatedServicesByServiceModelId(UUID.randomUUID());