diff options
author | 2019-04-05 09:03:15 -0400 | |
---|---|---|
committer | 2019-04-05 09:03:15 -0400 | |
commit | 457c9b19c058877ca59c9b0826d22f3f97392daf (patch) | |
tree | 0ba8edbec3f194d7a8643a3bd450268de129e9c4 /main/src | |
parent | 0621ae5c8a1dfcfa81b678ae6cc8679b88f58cc4 (diff) |
Fixes per latest models updates
Changes made per the scrum call on 4/4 moved things around. In
addition, filter classes were added to the tosca provider. Both
of these necessitated changes to policy/pap so that things compile.
Change-Id: Iba4c52b650dab0f8d242b06be3fede42dd5b7264
Issue-ID: POLICY-1542
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'main/src')
5 files changed, 24 insertions, 26 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java index c25ef97d..711b32a4 100644 --- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java +++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java @@ -23,22 +23,22 @@ package org.onap.policy.pap.main.comm; import java.util.ArrayList; import java.util.List; import java.util.Optional; - import org.apache.commons.lang3.tuple.Pair; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.pdp.concepts.Pdp; import org.onap.policy.models.pdp.concepts.PdpGroup; +import org.onap.policy.models.pdp.concepts.PdpGroupFilter; import org.onap.policy.models.pdp.concepts.PdpStateChange; import org.onap.policy.models.pdp.concepts.PdpStatistics; import org.onap.policy.models.pdp.concepts.PdpStatus; import org.onap.policy.models.pdp.concepts.PdpSubGroup; import org.onap.policy.models.pdp.concepts.PdpUpdate; -import org.onap.policy.models.pdp.concepts.ToscaPolicyIdentifier; -import org.onap.policy.models.pdp.concepts.ToscaPolicyTypeIdentifier; import org.onap.policy.models.pdp.enums.PdpState; import org.onap.policy.models.provider.PolicyModelsProvider; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; import org.onap.policy.pap.main.PapConstants; import org.onap.policy.pap.main.PolicyModelsProviderFactoryWrapper; import org.onap.policy.pap.main.PolicyPapException; @@ -90,8 +90,10 @@ public class PdpStatusMessageHandler { boolean pdpGroupFound = false; Optional<PdpSubGroup> subGroup = null; final List<Pair<String, String>> supportedPolicyTypesPair = createSupportedPolictTypesPair(message); + final PdpGroupFilter filter = PdpGroupFilter.builder().pdpType(message.getPdpType()).build(); + // TODO setSupportedTypes(supportedPolicyTypesPair) final List<PdpGroup> pdpGroups = - databaseProvider.getFilteredPdpGroups(message.getPdpType(), supportedPolicyTypesPair); + databaseProvider.getFilteredPdpGroups(filter); for (final PdpGroup pdpGroup : pdpGroups) { subGroup = findPdpSubGroup(message, pdpGroup); if (subGroup.isPresent()) { @@ -99,7 +101,7 @@ public class PdpStatusMessageHandler { if (!findPdpInstance(message, subGroup.get()).isPresent()) { updatePdpSubGroup(pdpGroup, subGroup.get(), message, databaseProvider); } - sendPdpMessage(pdpGroup.getName(), subGroup.get(), message.getInstance(), null, databaseProvider); + sendPdpMessage(pdpGroup.getName(), subGroup.get(), message.getName(), null, databaseProvider); pdpGroupFound = true; break; } @@ -119,7 +121,7 @@ public class PdpStatusMessageHandler { final PolicyModelsProvider databaseProvider) throws PfModelException { final Pdp pdpInstance = new Pdp(); - pdpInstance.setInstanceId(message.getInstance()); + pdpInstance.setInstanceId(message.getName()); pdpInstance.setPdpState(message.getState()); pdpInstance.setHealthy(message.getHealthy()); pdpInstance.setMessage(message.getDescription()); @@ -138,7 +140,9 @@ public class PdpStatusMessageHandler { Optional<PdpSubGroup> pdpSubgroup = null; Optional<Pdp> pdpInstance = null; - final List<PdpGroup> pdpGroups = databaseProvider.getLatestPdpGroups(message.getPdpGroup()); + final PdpGroupFilter filter = PdpGroupFilter.builder().name(message.getPdpGroup()).build(); + // TODO setLatestVersion() + final List<PdpGroup> pdpGroups = databaseProvider.getFilteredPdpGroups(filter); if (!pdpGroups.isEmpty()) { final PdpGroup pdpGroup = pdpGroups.get(0); pdpSubgroup = findPdpSubGroup(message, pdpGroup); @@ -171,7 +175,7 @@ public class PdpStatusMessageHandler { private Optional<Pdp> findPdpInstance(final PdpStatus message, final PdpSubGroup subGroup) { Pdp pdpInstance = null; for (final Pdp pdpInstanceDetails : subGroup.getPdpInstances()) { - if (message.getInstance().equals(pdpInstanceDetails.getInstanceId())) { + if (pdpInstanceDetails.getInstanceId().equals(message.getName())) { pdpInstance = pdpInstanceDetails; break; } @@ -213,7 +217,7 @@ public class PdpStatusMessageHandler { private void updatePdpStatistics(final PdpStatus message, final PdpSubGroup pdpSubgroup, final Pdp pdpInstance, final PdpGroup pdpGroup, final PolicyModelsProvider databaseProvider) throws PfModelException { final PdpStatistics pdpStatistics = new PdpStatistics(); - pdpStatistics.setPdpInstanceId(message.getInstance()); + pdpStatistics.setPdpInstanceId(message.getName()); pdpStatistics.setPolicyDeployCount(message.getStatistics().getPolicyDeployCount()); pdpStatistics.setPolicyDeploySuccessCount(message.getStatistics().getPolicyDeploySuccessCount()); pdpStatistics.setPolicyDeployFailCount(message.getStatistics().getPolicyDeployFailCount()); diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/UpdateData.java b/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/UpdateData.java index f439d254..0d861e21 100644 --- a/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/UpdateData.java +++ b/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/UpdateData.java @@ -24,8 +24,8 @@ import java.util.ArrayList; import java.util.List; import org.onap.policy.models.pdp.concepts.PdpStatus; import org.onap.policy.models.pdp.concepts.PdpUpdate; -import org.onap.policy.models.pdp.concepts.ToscaPolicyIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; import org.onap.policy.pap.main.parameters.PdpModifyRequestMapParams; @@ -76,7 +76,7 @@ public abstract class UpdateData extends MessageData { return null; } - + /** * Converts a ToscaPolicy list to ToscaPolicyIdentifier list. * diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java index 91d7d435..8f064035 100644 --- a/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java +++ b/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java @@ -42,7 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Queue; import java.util.function.Consumer; - import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -55,9 +54,9 @@ import org.onap.policy.models.pdp.concepts.PdpMessage; import org.onap.policy.models.pdp.concepts.PdpStateChange; import org.onap.policy.models.pdp.concepts.PdpStatus; import org.onap.policy.models.pdp.concepts.PdpUpdate; -import org.onap.policy.models.pdp.concepts.ToscaPolicyIdentifier; import org.onap.policy.models.pdp.enums.PdpState; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; import org.onap.policy.pap.main.PapConstants; import org.onap.policy.pap.main.comm.PdpModifyRequestMap.ModifyReqData; import org.onap.policy.pap.main.parameters.PdpModifyRequestMapParams; @@ -585,7 +584,7 @@ public class PdpModifyRequestMapTest { return cng; } - + /** * Converts a ToscaPolicy list to ToscaPolicyIdentifier list. * diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateDataTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateDataTest.java index 127843a0..352b92df 100644 --- a/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateDataTest.java +++ b/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/UpdateDataTest.java @@ -29,13 +29,13 @@ import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.Arrays; import java.util.List; - +import java.util.stream.Collectors; import org.junit.Before; import org.junit.Test; import org.onap.policy.models.pdp.concepts.PdpStatus; import org.onap.policy.models.pdp.concepts.PdpUpdate; -import org.onap.policy.models.pdp.concepts.ToscaPolicyIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; import org.onap.policy.pap.main.comm.TimerManager; import org.onap.policy.pap.main.parameters.PdpModifyRequestMapParams; import org.onap.policy.pap.main.parameters.PdpParameters; @@ -123,7 +123,7 @@ public class UpdateDataTest { @Test public void testUpdateDataCheckResponse_MismatchedPolicies() { ArrayList<ToscaPolicyIdentifier> policies = - new ArrayList<>(convertToscaPolicyToToscaPolicyIndentifier(update.getPolicies())); + new ArrayList<>(convertToscaPolicyToToscaPolicyIndentifier(update.getPolicies())); policies.set(0, new ToscaPolicyIdentifier(DIFFERENT, "10.0.0")); response.setPolicies(policies); @@ -184,7 +184,7 @@ public class UpdateDataTest { // do nothing } } - + /** * Converts a ToscaPolicy list to ToscaPolicyIdentifier list. * @@ -192,10 +192,7 @@ public class UpdateDataTest { * @return the ToscaPolicyIdentifier list */ private List<ToscaPolicyIdentifier> convertToscaPolicyToToscaPolicyIndentifier(List<ToscaPolicy> toscaPolicies) { - final List<ToscaPolicyIdentifier> toscaPolicyIdentifiers = new ArrayList<>(); - for (final ToscaPolicy toscaPolicy : toscaPolicies) { - toscaPolicyIdentifiers.add(new ToscaPolicyIdentifier(toscaPolicy.getName(), toscaPolicy.getVersion())); - } - return toscaPolicyIdentifiers; + return toscaPolicies.stream().map(policy -> new ToscaPolicyIdentifier(policy.getName(), policy.getVersion())) + .collect(Collectors.toList()); } } diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java index 18e17b09..09e91a99 100644 --- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java +++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployControllerV1.java @@ -25,18 +25,16 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import java.util.Arrays; - import javax.ws.rs.client.Entity; import javax.ws.rs.client.Invocation; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - import org.junit.Test; import org.onap.policy.models.pap.concepts.PdpDeployPolicies; import org.onap.policy.models.pap.concepts.PdpGroupDeployResponse; import org.onap.policy.models.pdp.concepts.PdpGroup; import org.onap.policy.models.pdp.concepts.PdpSubGroup; -import org.onap.policy.models.pdp.concepts.ToscaPolicyIdentifierOptVersion; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifierOptVersion; public class TestPdpGroupDeployControllerV1 extends CommonPapRestServer { |