diff options
author | Einat Vinouze <einat.vinouze@intl.att.com> | 2020-01-07 11:57:32 +0200 |
---|---|---|
committer | Einat Vinouze <einat.vinouze@intl.att.com> | 2020-01-07 18:44:06 +0200 |
commit | 8e2ec29dece28c4b17b20f04b3c8377242996572 (patch) | |
tree | 37c718972904d4507881e803d69f70103d284221 /vid-app-common | |
parent | 6291d31b674ac0f1de86211ec801772f3de3abd1 (diff) |
templates button - rename from hasTemplates to isInstantiationTemplateExists on the FE side
Issue-ID: VID-741
Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com>
Change-Id: I09e0579d96cf5265519eaa69646afef7b511593a
Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com>
Diffstat (limited to 'vid-app-common')
3 files changed, 15 insertions, 4 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java index 092cfe4e2..f5dd5d85f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java +++ b/vid-app-common/src/main/java/org/onap/vid/asdc/beans/Service.java @@ -20,6 +20,9 @@ package org.onap.vid.asdc.beans; +import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; + +import com.fasterxml.jackson.annotation.JsonInclude; import java.util.Collection; import java.util.UUID; @@ -77,6 +80,7 @@ public class Service { private String orchestrationType; + @JsonInclude(NON_NULL) private Boolean isInstantiationTemplateExists; diff --git a/vid-app-common/src/main/java/org/onap/vid/services/InstantiationTemplatesService.java b/vid-app-common/src/main/java/org/onap/vid/services/InstantiationTemplatesService.java index c033fbd59..17520eef4 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/InstantiationTemplatesService.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/InstantiationTemplatesService.java @@ -29,6 +29,7 @@ import java.util.Map; import java.util.Set; import java.util.UUID; import javax.inject.Inject; +import org.jetbrains.annotations.NotNull; import org.onap.vid.asdc.beans.Service; import org.onap.vid.dal.AsyncInstantiationRepository; import org.onap.vid.model.ModelUtil; @@ -76,7 +77,8 @@ public class InstantiationTemplatesService { public Collection<Service> setOnEachServiceIsTemplateExists(Collection<Service> services){ if (!featureManager.isActive(Features.FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE)){ - return services; + return unsetTemplateExistsToAllServices(services); + } Set<String> serviceModelIdsFromDB = asyncInstantiationRepository.getAllTemplatesServiceModelIds(); @@ -84,8 +86,13 @@ public class InstantiationTemplatesService { return services.stream().map(it -> setTemplateExistForService(it, serviceModelIdsFromDB)).collect(toList()); } - protected Service setTemplateExistForService(Service service, Set<String> serviceModelIdsFromDb) { + @NotNull + protected Collection<Service> unsetTemplateExistsToAllServices(Collection<Service> services) { + services.forEach(it -> it.setIsInstantiationTemplateExists(false)); + return services; + } + protected Service setTemplateExistForService(Service service, Set<String> serviceModelIdsFromDb) { service.setIsInstantiationTemplateExists(serviceModelIdsFromDb.contains(service.getUuid())); return service; } diff --git a/vid-app-common/src/test/java/org/onap/vid/services/InstantiationTemplatesServiceTest.java b/vid-app-common/src/test/java/org/onap/vid/services/InstantiationTemplatesServiceTest.java index 0c66f9550..de9fc2bcb 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/InstantiationTemplatesServiceTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/InstantiationTemplatesServiceTest.java @@ -154,8 +154,8 @@ public class InstantiationTemplatesServiceTest { when(featureManager.isActive(Features.FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE)).thenReturn(false); Collection<Service> actualCollection = instantiationTemplatesService.setOnEachServiceIsTemplateExists(createGivenCollection()); assertThat("was " + actualCollection, actualCollection, containsInAnyOrder( - allOf(hasProperty("uuid", is("1")), hasProperty("isInstantiationTemplateExists", nullValue())), - allOf(hasProperty("uuid", is("3")), hasProperty("isInstantiationTemplateExists", nullValue())) + allOf(hasProperty("uuid", is("1")), hasProperty("isInstantiationTemplateExists", is(false))), + allOf(hasProperty("uuid", is("3")), hasProperty("isInstantiationTemplateExists", is(false))) )); } |