aboutsummaryrefslogtreecommitdiffstats
path: root/models-tosca/src/main/java/org
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-04-08 13:58:53 +0000
committerliamfallon <liam.fallon@est.tech>2019-04-08 13:58:53 +0000
commit9ce39af891ccf063d46e18ecf5a2a47eb1408930 (patch)
treeeb55cc63c83ea34f73aeaaae5039c96283b66ef8 /models-tosca/src/main/java/org
parenteb7127ac85b3df30a09277721a5f9271033843e7 (diff)
Add bug fixes and tests for filters
Fixed bugs on filtering where lack of null checks was blocking all results. Added unit test for PDP related JPA objects. Fixed cascading and orphan control on JPA objects. Added partial testing of PdpProvider. Added partial testing of filters. Changed tag for content of operational policies from "Content" to "content". Issue-ID: POLICY-1095 Change-Id: Ieb22e06955a8434b490bae7d0f6b77d4479515e8 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-tosca/src/main/java/org')
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java9
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java5
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java8
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);