diff options
author | Jorge Hernandez <jorge.hernandez-herrero@att.com> | 2019-04-08 16:54:06 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-04-08 16:54:06 +0000 |
commit | a32b49c3ec54e5f3bf23634a5fb538909905f8e6 (patch) | |
tree | 1a865fd043ccbda577cf5b9c4ac1649ba6b4aba5 /models-tosca/src | |
parent | 59e8be2fdc958156eaac43a0e78627fa187af3e4 (diff) | |
parent | 9ce39af891ccf063d46e18ecf5a2a47eb1408930 (diff) |
Merge "Add bug fixes and tests for filters"
Diffstat (limited to 'models-tosca/src')
3 files changed, 14 insertions, 8 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java index b4d1b3ee3..102b1fe2e 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java @@ -57,10 +57,11 @@ public class ToscaPolicyFilter implements PfObjectFilter<ToscaPolicy> { // @formatter:off List<ToscaPolicy> returnList = originalList.stream() - .filter(p -> filterOnRegexp(p.getName(), name)) - .filter(p -> version.equals(LATEST_VERSION) || filterOnRegexp(p.getVersion(), version)) - .filter(p -> filterOnRegexp(p.getType(), type)) - .filter(p -> filterOnRegexp(p.getTypeVersion(), typeVersion)) + .filter(p -> filterString(p.getName(), name)) + .filter(p -> (version != null && LATEST_VERSION.equals(version)) + || filterString(p.getVersion(), version)) + .filter(p -> filterString(p.getType(), type)) + .filter(p -> filterString(p.getTypeVersion(), typeVersion)) .collect(Collectors.toList()); // @formatter:off diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java index 041179513..7d6fbacee 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java @@ -51,8 +51,9 @@ public class ToscaPolicyTypeFilter implements PfObjectFilter<ToscaPolicyType> { // @formatter:off List<ToscaPolicyType> returnList = originalList.stream() - .filter(p -> filterOnRegexp(p.getName(), name)) - .filter(p -> version.equals(LATEST_VERSION) || filterOnRegexp(p.getVersion(), version)) + .filter(p -> filterString(p.getName(), name)) + .filter(p -> (version != null && LATEST_VERSION.equals(version)) + || filterString(p.getVersion(), version)) .collect(Collectors.toList()); // @formatter:off diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java index 4ddcd60cc..b6c5d3bba 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java @@ -44,6 +44,10 @@ import org.slf4j.LoggerFactory; */ public class LegacyOperationalPolicyMapper implements JpaToscaServiceTemplateMapper<LegacyOperationalPolicy, LegacyOperationalPolicy> { + + // Property name for the operational policy content + private static final String CONTENT_PROPERTY = "content"; + private static final Logger LOGGER = LoggerFactory.getLogger(LegacyOperationalPolicyMapper.class); private static final PfConceptKey LEGACY_OPERATIONAL_TYPE = @@ -64,7 +68,7 @@ public class LegacyOperationalPolicyMapper final Map<String, String> propertyMap = new HashMap<>(); toscaPolicy.setProperties(propertyMap); - toscaPolicy.getProperties().put("Content", legacyOperationalPolicy.getContent()); + toscaPolicy.getProperties().put(CONTENT_PROPERTY, legacyOperationalPolicy.getContent()); final JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate(); serviceTemplate.setToscaDefinitionsVersion("tosca_simple_yaml_1_0"); @@ -101,7 +105,7 @@ public class LegacyOperationalPolicyMapper throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage); } - final String content = toscaPolicy.getProperties().get("Content"); + final String content = toscaPolicy.getProperties().get(CONTENT_PROPERTY); if (toscaPolicy.getProperties() == null) { String errorMessage = "property \"Content\" not defined on TOSCA policy"; LOGGER.warn(errorMessage); |