From b4aaa6d004c4643e593fc789bbe9776a6226315d Mon Sep 17 00:00:00 2001 From: Dmitry Puzikov Date: Tue, 28 Jan 2020 18:04:40 +0100 Subject: Policies import when import VSP Polices import implemented. Error type added for invalid policies. Import tests added. Fix test failures. Got rid of Either in the new code. Change-Id: I3e91cc6d24433c2b3862f407348e71e1e67c3b4e Issue-ID: SDC-2728 Signed-off-by: Dmitry Puzikov --- .../sdc/be/model/ParsedToscaYamlInfo.java | 39 ++++------------------ .../be/model/cache/ApplicationDataTypeCache.java | 27 +++++++++++++++ .../model/cache/ApplicationDataTypeCacheTest.java | 4 +++ 3 files changed, 38 insertions(+), 32 deletions(-) (limited to 'catalog-model') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ParsedToscaYamlInfo.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ParsedToscaYamlInfo.java index f975806c88..a6f4165aeb 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ParsedToscaYamlInfo.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ParsedToscaYamlInfo.java @@ -21,41 +21,16 @@ package org.openecomp.sdc.be.model; import java.util.Map; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +@ToString +@Getter +@Setter public class ParsedToscaYamlInfo { Map inputs; - Map instances; - Map groups; - - public Map getInstances() { - return instances; - } - - public void setInstances(Map instances) { - this.instances = instances; - } - - public Map getGroups() { - return groups; - } - - public void setGroups(Map groups) { - this.groups = groups; - } - - public Map getInputs() { - return inputs; - } - - public void setInputs(Map inputs) { - this.inputs = inputs; - } - - @Override - public String toString() { - return "ParsedToscaYamlInfo [inputs=" + inputs + ", instances=" + instances + ", groups=" + groups + "]"; - } - + Map policies; } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java index fb49762736..25a305ed9b 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java @@ -21,6 +21,7 @@ package org.openecomp.sdc.be.model.cache; import fj.data.Either; +import lombok.Getter; import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.config.BeEcompErrorManager; @@ -34,6 +35,9 @@ import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.operations.impl.PropertyOperation; import org.openecomp.sdc.be.resources.data.DataTypeData; import org.openecomp.sdc.common.log.wrappers.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEvent; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; @@ -74,6 +78,9 @@ public class ApplicationDataTypeCache implements ApplicationCache newData) { + log.trace("Cache data has changed, sending event to all listening for this change."); + DataTypesCacheChangedEvent dataTypesCacheChangedEvent = new DataTypesCacheChangedEvent(this, newData); + applicationEventPublisher.publishEvent(dataTypesCacheChangedEvent); + } + + /** + * Custom event to notify all interested in cached data changes + */ + public static class DataTypesCacheChangedEvent extends ApplicationEvent { + @Getter + private Map newData; + + public DataTypesCacheChangedEvent(Object source, Map newData) { + super(source); + this.newData = newData; + } + } } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCacheTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCacheTest.java index 481894c0c3..7186d2a8bf 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCacheTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCacheTest.java @@ -39,6 +39,7 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import org.springframework.context.ApplicationEventPublisher; public class ApplicationDataTypeCacheTest extends ModelConfDependentTest{ @@ -48,6 +49,9 @@ public class ApplicationDataTypeCacheTest extends ModelConfDependentTest{ @Mock PropertyOperation propertyOperation; + @Mock + ApplicationEventPublisher applicationEventPublisher; + @Before public void setUpMocks() throws Exception { MockitoAnnotations.initMocks(this); -- cgit 1.2.3-korg