diff options
16 files changed, 235 insertions, 652 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java index 53bf3c1c6..3c1aec258 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroup.java @@ -1,7 +1,7 @@ -/* +/*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,36 +32,28 @@ import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.ObjectValidationResult; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.common.parameters.ValidationStatus; +import org.onap.policy.models.base.PfKey; import org.onap.policy.models.base.PfNameVersion; import org.onap.policy.models.base.PfUtils; import org.onap.policy.models.pdp.enums.PdpState; /** - * Class to represent a PDPGroup, which groups multiple PDPSubGroup entities together for - * a particular domain. + * Class to represent a PDPGroup, which groups multiple PDPSubGroup entities together for a particular domain. * * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ @Data @NoArgsConstructor public class PdpGroup implements PfNameVersion, Comparable<PdpGroup> { - /** - * In the future, we'll eliminate the "version" field. Until then, the version of - * every group should always be this fixed value. - */ - public static final String VERSION = "1.0.0"; - private String name; - private String version; private String description; private PdpState pdpGroupState; private Map<String, String> properties; private List<PdpSubGroup> pdpSubgroups; /* - * Note: removed "@NotNull" annotation from the constructor argument, because it - * cannot be covered by a junit test, as the superclass does the check and throws an - * exception first. + * Note: removed "@NotNull" annotation from the constructor argument, because it cannot be covered by a junit test, + * as the superclass does the check and throws an exception first. */ /** @@ -71,7 +63,6 @@ public class PdpGroup implements PfNameVersion, Comparable<PdpGroup> { */ public PdpGroup(PdpGroup source) { this.name = source.name; - this.version = source.version; this.description = source.description; this.pdpGroupState = source.pdpGroupState; this.properties = (source.properties == null ? null : new LinkedHashMap<>(source.properties)); @@ -84,8 +75,7 @@ public class PdpGroup implements PfNameVersion, Comparable<PdpGroup> { } /** - * Validates that appropriate fields are populated for an incoming call to the PAP - * REST API. + * Validates that appropriate fields are populated for an incoming call to the PAP REST API. * * @return the validation result */ @@ -93,8 +83,7 @@ public class PdpGroup implements PfNameVersion, Comparable<PdpGroup> { BeanValidationResult result = new BeanValidationResult("group", this); /* - * Don't care about version or state, because we override them. Ok if description - * is null. + * Don't care about version or state, because we override them. Ok if description is null. */ result.validateNotNull("name", name); @@ -118,19 +107,27 @@ public class PdpGroup implements PfNameVersion, Comparable<PdpGroup> { Set<String> set = new HashSet<>(); for (PdpSubGroup subgrp : pdpSubgroups) { - if (subgrp == null) { - continue; - } + String pdpType = (subgrp == null ? null : subgrp.getPdpType()); - String pdpType = subgrp.getPdpType(); if (pdpType == null) { continue; } if (!set.add(pdpType)) { result.addResult(new ObjectValidationResult("subgroups", pdpType, ValidationStatus.INVALID, - "duplicate subgroup")); + "duplicate subgroup")); } } } + + @Override + public String getVersion() { + // We need to pass a version for keying in the database + return PfKey.NULL_KEY_VERSION; + } + + @Override + public void setVersion(String version) { + // Just ignore any version that is set + } } diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java index 0f86c6890..d67f2d4cb 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java @@ -41,14 +41,9 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifi @Builder @Data public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { - public static final String LATEST_VERSION = "LATEST"; - // Name to find private String name; - // Version to find, set to LATEST_VERSION to get the latest version - private String version; - // State to find private PdpState groupState; @@ -76,10 +71,8 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { public List<PdpGroup> filter(@NonNull final List<PdpGroup> originalList) { // @formatter:off - List<PdpGroup> returnList = originalList.stream() + return originalList.stream() .filter(p -> filterString(p.getName(), name)) - .filter(p -> LATEST_VERSION.equals(version) - || filterString(p.getVersion(), version)) .filter(p -> groupState == null || ObjectUtils.compare(p.getPdpGroupState(), groupState) == 0) .filter(p -> filterOnPdpType(p, pdpType)) .filter(p -> filterOnPolicyTypeList(p, policyTypeList, matchPolicyTypesExactly)) @@ -87,12 +80,6 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { .filter(p -> filterOnPdpState(p, pdpState)) .collect(Collectors.toList()); // @formatter:on - - if (LATEST_VERSION.equals(version)) { - returnList = this.latestVersionFilter(returnList); - } - - return returnList; } /** diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java index bfdeda984..0a0f5f7ef 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java @@ -28,6 +28,7 @@ import javax.ws.rs.core.Response; import lombok.NonNull; import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfKey; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfModelRuntimeException; import org.onap.policy.models.base.PfReferenceKey; @@ -60,14 +61,12 @@ public class PdpProvider { * * @param dao the DAO to use to access the database * @param name the name of the PDP group to get, null to get all PDP groups - * @param version the version of the policy to get, null to get all versions of a PDP group * @return the PDP groups found * @throws PfModelException on errors getting PDP groups */ - public List<PdpGroup> getPdpGroups(@NonNull final PfDao dao, final String name, final String version) - throws PfModelException { + public List<PdpGroup> getPdpGroups(@NonNull final PfDao dao, final String name) throws PfModelException { - return asPdpGroupList(dao.getFiltered(JpaPdpGroup.class, name, version)); + return asPdpGroupList(dao.getFiltered(JpaPdpGroup.class, name, PfKey.NULL_KEY_VERSION)); } /** @@ -115,7 +114,7 @@ public class PdpProvider { for (PdpGroup pdpGroup : pdpGroups) { JpaPdpGroup jpaPdpGroup = - dao.get(JpaPdpGroup.class, new PfConceptKey(pdpGroup.getName(), pdpGroup.getVersion())); + dao.get(JpaPdpGroup.class, new PfConceptKey(pdpGroup.getName(), PfKey.NULL_KEY_VERSION)); returnPdpGroups.add(jpaPdpGroup.toAuthorative()); } @@ -152,7 +151,7 @@ public class PdpProvider { for (PdpGroup pdpGroup : pdpGroups) { JpaPdpGroup jpaPdpGroup = - dao.get(JpaPdpGroup.class, new PfConceptKey(pdpGroup.getName(), pdpGroup.getVersion())); + dao.get(JpaPdpGroup.class, new PfConceptKey(pdpGroup.getName(), PfKey.NULL_KEY_VERSION)); returnPdpGroups.add(jpaPdpGroup.toAuthorative()); } @@ -164,14 +163,14 @@ public class PdpProvider { * * @param dao the DAO to use to access the database * @param pdpGroupName the name of the PDP group of the PDP subgroup - * @param pdpGroupVersion the version of the PDP group of the PDP subgroup * @param pdpSubGroup the PDP subgroup to be updated * @throws PfModelException on errors updating PDP subgroups */ public void updatePdpSubGroup(@NonNull final PfDao dao, @NonNull final String pdpGroupName, - @NonNull final String pdpGroupVersion, @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException { + @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException { - final PfReferenceKey subGroupKey = new PfReferenceKey(pdpGroupName, pdpGroupVersion, pdpSubGroup.getPdpType()); + final PfReferenceKey subGroupKey = + new PfReferenceKey(pdpGroupName, PfKey.NULL_KEY_VERSION, pdpSubGroup.getPdpType()); final JpaPdpSubGroup jpaPdpSubgroup = new JpaPdpSubGroup(subGroupKey); jpaPdpSubgroup.fromAuthorative(pdpSubGroup); @@ -190,16 +189,15 @@ public class PdpProvider { * * @param dao the DAO to use to access the database * @param pdpGroupName the name of the PDP group of the PDP subgroup - * @param pdpGroupVersion the version of the PDP group of the PDP subgroup * @param pdpSubGroup the PDP subgroup to be updated * @param pdp the PDP to be updated * @throws PfModelException on errors updating PDP subgroups */ public void updatePdp(@NonNull final PfDao dao, @NonNull final String pdpGroupName, - @NonNull final String pdpGroupVersion, @NonNull final String pdpSubGroup, @NonNull final Pdp pdp) { + @NonNull final String pdpSubGroup, @NonNull final Pdp pdp) { final PfReferenceKey pdpKey = - new PfReferenceKey(pdpGroupName, pdpGroupVersion, pdpSubGroup, pdp.getInstanceId()); + new PfReferenceKey(pdpGroupName, PfKey.NULL_KEY_VERSION, pdpSubGroup, pdp.getInstanceId()); final JpaPdp jpaPdp = new JpaPdp(pdpKey); jpaPdp.fromAuthorative(pdp); @@ -218,14 +216,12 @@ public class PdpProvider { * * @param dao the DAO to use to access the database * @param name the name of the policy to get, null to get all PDP groups - * @param version the version of the policy to get, null to get all versions of a PDP group * @return the PDP group deleted * @throws PfModelException on errors deleting PDP groups */ - public PdpGroup deletePdpGroup(@NonNull final PfDao dao, @NonNull final String name, - @NonNull final String version) { + public PdpGroup deletePdpGroup(@NonNull final PfDao dao, @NonNull final String name) { - PfConceptKey pdpGroupKey = new PfConceptKey(name, version); + PfConceptKey pdpGroupKey = new PfConceptKey(name, PfKey.NULL_KEY_VERSION); JpaPdpGroup jpaDeletePdpGroup = dao.get(JpaPdpGroup.class, pdpGroupKey); @@ -245,12 +241,10 @@ public class PdpProvider { * * @param dao the DAO to use to access the database * @param name the name of the PDP group to get statistics for, null to get all PDP groups - * @param version the version of the PDP group to get statistics for, null to get all versions of a PDP group * @return the statistics found * @throws PfModelException on errors getting statistics */ - public List<PdpStatistics> getPdpStatistics(@NonNull final PfDao dao, final String name, final String version) - throws PfModelException { + public List<PdpStatistics> getPdpStatistics(@NonNull final PfDao dao, final String name) throws PfModelException { return new ArrayList<>(); } @@ -259,14 +253,13 @@ public class PdpProvider { * * @param dao the DAO to use to access the database * @param pdpGroupName the name of the PDP group containing the PDP that the statistics are for - * @param pdpGroupVersion the version of the PDP group containing the PDP that the statistics are for * @param pdpType the PDP type of the subgroup containing the PDP that the statistics are for * @param pdpInstanceId the instance ID of the PDP to update statistics for * @param pdpStatistics the statistics to update * @throws PfModelException on errors updating statistics */ public void updatePdpStatistics(@NonNull final PfDao dao, @NonNull final String pdpGroupName, - @NonNull final String pdpGroupVersion, @NonNull final String pdpType, @NonNull final String pdpInstanceId, + @NonNull final String pdpType, @NonNull final String pdpInstanceId, @NonNull final PdpStatistics pdpStatistics) throws PfModelException { // Not implemented yet } diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java index 75ec4d169..89ee5b90d 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java @@ -74,38 +74,28 @@ public class PdpGroupFilterTest { } @Test - public void testFilterLatestVersion() { - PdpGroupFilter filter = PdpGroupFilter.builder().version(PdpGroupFilter.LATEST_VERSION).build(); - - List<PdpGroup> filteredList = filter.filter(pdpGroupList); - assertEquals(2, filteredList.size()); - assertEquals("1.2.4", filteredList.get(0).getVersion()); - assertEquals("1.2.3", filteredList.get(1).getVersion()); - } - - @Test - public void testFilterNameVersion() { + public void testFilterName() { PdpGroupFilter filter = PdpGroupFilter.builder().name("PdpGroup0").build(); List<PdpGroup> filteredList = filter.filter(pdpGroupList); - assertEquals(3, filteredList.size()); + assertEquals(1, filteredList.size()); filter = PdpGroupFilter.builder().name("PdpGroup1").build(); filteredList = filter.filter(pdpGroupList); - assertEquals(2, filteredList.size()); + assertEquals(1, filteredList.size()); - filter = PdpGroupFilter.builder().name("PdpGroup2").build(); + filter = PdpGroupFilter.builder().name("PdpGroup20").build(); filteredList = filter.filter(pdpGroupList); - assertEquals(0, filteredList.size()); + assertEquals(1, filteredList.size()); - filter = PdpGroupFilter.builder().version("1.2.3").build(); + filter = PdpGroupFilter.builder().build(); filteredList = filter.filter(pdpGroupList); - assertEquals(2, filteredList.size()); + assertEquals(5, filteredList.size()); - filter = PdpGroupFilter.builder().name("PdpGroup0").version("1.2.3").build(); + filter = PdpGroupFilter.builder().name("PdpGroup0").build(); filteredList = filter.filter(pdpGroupList); assertEquals(1, filteredList.size()); - filter = PdpGroupFilter.builder().name("PdpGroup1").version("1.2.9").build(); + filter = PdpGroupFilter.builder().name("PdpGroup19").build(); filteredList = filter.filter(pdpGroupList); assertEquals(0, filteredList.size()); } diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java index 3082bb228..0df2d34d9 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupTest.java @@ -55,8 +55,8 @@ public class PdpGroupTest { PdpGroup orig = new PdpGroup(); // verify with null values - assertEquals("PdpGroup(name=null, version=null, description=null, pdpGroupState=null, " - + "properties=null, pdpSubgroups=[])", new PdpGroup(orig).toString()); + assertEquals("PdpGroup(name=null, description=null, pdpGroupState=null, " + "properties=null, pdpSubgroups=[])", + new PdpGroup(orig).toString()); // verify with all values orig.setDescription("my-descript"); @@ -76,7 +76,7 @@ public class PdpGroupTest { props.put("key-B", "value-B"); orig.setProperties(props); - assertEquals("PdpGroup(name=my-name, version=1.2.3, description=my-description, " + assertEquals("PdpGroup(name=my-name, description=my-description, " + "pdpGroupState=SAFE, properties={key-A=value-A, key-B=value-B}, " + "pdpSubgroups=[PdpSubGroup(pdpType=null, supportedPolicyTypes=[], policies=[], " + "currentInstanceCount=10, desiredInstanceCount=0, properties=null, pdpInstances=[]), " diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroupTest.java index e75743e40..c0545fa36 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroupTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroupTest.java @@ -98,16 +98,8 @@ public class JpaPdpGroupTest { JpaPdpGroup testJpaPdpGroup = new JpaPdpGroup(); testJpaPdpGroup.setKey(null); - assertThatThrownBy(() -> { - testJpaPdpGroup.fromAuthorative(testPdpGroup); - }).hasMessage("version is marked @NonNull but is null"); - testJpaPdpGroup.setKey(new PfConceptKey()); - assertThatThrownBy(() -> { - testJpaPdpGroup.fromAuthorative(testPdpGroup); - }).hasMessage("version is marked @NonNull but is null"); - testPdpGroup.setVersion("1.0.0"); testJpaPdpGroup.fromAuthorative(testPdpGroup); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java index ee9c76b98..f0af69ea4 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java @@ -106,15 +106,11 @@ public class PdpProviderTest { @Test public void testGroupsGet() throws Exception { assertThatThrownBy(() -> { - new PdpProvider().getPdpGroups(null, null, null); + new PdpProvider().getPdpGroups(null, null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().getPdpGroups(null, null, "version"); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().getPdpGroups(null, "name", "version"); + new PdpProvider().getPdpGroups(null, "name"); }).hasMessage("dao is marked @NonNull but is null"); String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroups0.json"); @@ -126,7 +122,7 @@ public class PdpProviderTest { assertEquals(originalJson.replaceAll("\\s+", ""), createdJson.replaceAll("\\s+", "")); PdpGroups gotPdpGroups0 = new PdpGroups(); - gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0", "1.2.3")); + gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0")); String gotJson = standardCoder.encode(gotPdpGroups0); @@ -162,7 +158,6 @@ public class PdpProviderTest { final PdpGroupFilter filter = PdpGroupFilter.builder() .groupState(PdpState.PASSIVE) .name("PdpGroup0") - .version("1.2.3") .matchPoliciesExactly(false) .matchPolicyTypesExactly(false) .pdpState(PdpState.PASSIVE) @@ -197,7 +192,7 @@ public class PdpProviderTest { assertEquals(originalJson.replaceAll("\\s+", ""), createdJson.replaceAll("\\s+", "")); PdpGroups gotPdpGroups0 = new PdpGroups(); - gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0", "1.2.3")); + gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0")); String gotJson = standardCoder.encode(gotPdpGroups0); assertEquals(originalJson.replaceAll("\\s+", ""), gotJson.replaceAll("\\s+", "")); @@ -223,7 +218,7 @@ public class PdpProviderTest { assertEquals(originalTweakedJson.replaceAll("\\s+", ""), createdJson.replaceAll("\\s+", "")); PdpGroups gotPdpGroups0 = new PdpGroups(); - gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "TestPdpGroup", "1.2.3")); + gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "TestPdpGroup")); String gotJson = standardCoder.encode(gotPdpGroups0); assertEquals(originalTweakedJson.replaceAll("\\s+", ""), gotJson.replaceAll("\\s+", "")); @@ -252,7 +247,7 @@ public class PdpProviderTest { assertEquals(originalJson.replaceAll("\\s+", ""), createdJson.replaceAll("\\s+", "")); PdpGroups gotPdpGroups0 = new PdpGroups(); - gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0", "1.2.3")); + gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0")); String gotJson = standardCoder.encode(gotPdpGroups0); assertEquals(originalJson.replaceAll("\\s+", ""), gotJson.replaceAll("\\s+", "")); @@ -276,32 +271,20 @@ public class PdpProviderTest { @Test public void testPoliciesDelete() throws Exception { assertThatThrownBy(() -> { - new PdpProvider().deletePdpGroup(null, null, null); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().deletePdpGroup(null, null, "version"); + new PdpProvider().deletePdpGroup(null, null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().deletePdpGroup(null, "name", null); + new PdpProvider().deletePdpGroup(null, "name"); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().deletePdpGroup(null, "name", "version"); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().deletePdpGroup(pfDao, null, "version"); + new PdpProvider().deletePdpGroup(pfDao, null); }).hasMessage("name is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().deletePdpGroup(pfDao, "name", null); - }).hasMessage("version is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().deletePdpGroup(pfDao, "name", "version"); - }).hasMessage("delete of PDP group \"name:version\" failed, PDP group does not exist"); + new PdpProvider().deletePdpGroup(pfDao, "name"); + }).hasMessage("delete of PDP group \"name:0.0.0\" failed, PDP group does not exist"); String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroups0.json"); PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class); @@ -312,82 +295,54 @@ public class PdpProviderTest { assertEquals(originalJson.replaceAll("\\s+", ""), createdJson.replaceAll("\\s+", "")); PdpGroups gotPdpGroups0 = new PdpGroups(); - gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0", "1.2.3")); + gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0")); String gotJson = standardCoder.encode(gotPdpGroups0); assertEquals(originalJson.replaceAll("\\s+", ""), gotJson.replaceAll("\\s+", "")); - PdpGroup deletedPdpGroup = new PdpProvider().deletePdpGroup(pfDao, "PdpGroup0", "1.2.3"); + PdpGroup deletedPdpGroup = new PdpProvider().deletePdpGroup(pfDao, "PdpGroup0"); assertEquals(createdPdpGroups0.getGroups().get(0), deletedPdpGroup); - assertEquals(0, new PdpProvider().getPdpGroups(pfDao, "PdpGroup0", "1.2.3").size()); + assertEquals(0, new PdpProvider().getPdpGroups(pfDao, "PdpGroup0").size()); assertThatThrownBy(() -> { - new PdpProvider().deletePdpGroup(pfDao, "PdpGroup0", "1.2.3"); - }).hasMessage("delete of PDP group \"PdpGroup0:1.2.3\" failed, PDP group does not exist"); + new PdpProvider().deletePdpGroup(pfDao, "PdpGroup0"); + }).hasMessage("delete of PDP group \"PdpGroup0:0.0.0\" failed, PDP group does not exist"); } @Test public void testPdpSubgroupUpdate() throws Exception { assertThatThrownBy(() -> { - new PdpProvider().updatePdpSubGroup(null, null, null, null); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpSubGroup(null, null, null, new PdpSubGroup()); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpSubGroup(null, null, "version", null); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpSubGroup(null, null, "version", new PdpSubGroup()); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpSubGroup(null, "name", null, null); + new PdpProvider().updatePdpSubGroup(null, null, null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpSubGroup(null, "name", null, new PdpSubGroup()); + new PdpProvider().updatePdpSubGroup(null, null, new PdpSubGroup()); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpSubGroup(null, "name", "version", null); + new PdpProvider().updatePdpSubGroup(null, "name", null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpSubGroup(null, "name", "version", new PdpSubGroup()); + new PdpProvider().updatePdpSubGroup(null, "name", new PdpSubGroup()); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpSubGroup(pfDao, null, null, new PdpSubGroup()); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpSubGroup(pfDao, null, "version", null); + new PdpProvider().updatePdpSubGroup(pfDao, null, null); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpSubGroup(pfDao, null, "version", new PdpSubGroup()); + new PdpProvider().updatePdpSubGroup(pfDao, null, new PdpSubGroup()); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpSubGroup(pfDao, "name", null, null); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpSubGroup(pfDao, "name", null, new PdpSubGroup()); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpSubGroup(pfDao, "name", "version", null); + new PdpProvider().updatePdpSubGroup(pfDao, "name", null); }).hasMessage("pdpSubGroup is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpSubGroup(pfDao, "name", "version", new PdpSubGroup()); + new PdpProvider().updatePdpSubGroup(pfDao, "name", new PdpSubGroup()); }).hasMessage("parameter \"localName\" is null"); String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroups0.json"); @@ -399,7 +354,7 @@ public class PdpProviderTest { assertEquals(originalJson.replaceAll("\\s+", ""), createdJson.replaceAll("\\s+", "")); PdpGroups gotPdpGroups0 = new PdpGroups(); - gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0", "1.2.3")); + gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0")); String gotJson = standardCoder.encode(gotPdpGroups0); assertEquals(originalJson.replaceAll("\\s+", ""), gotJson.replaceAll("\\s+", "")); @@ -407,15 +362,15 @@ public class PdpProviderTest { PdpSubGroup existingSubGroup = gotPdpGroups0.getGroups().get(0).getPdpSubgroups().get(0); existingSubGroup.setCurrentInstanceCount(10); existingSubGroup.setDesiredInstanceCount(10); - new PdpProvider().updatePdpSubGroup(pfDao, "PdpGroup0", "1.2.3", existingSubGroup); + new PdpProvider().updatePdpSubGroup(pfDao, "PdpGroup0", existingSubGroup); - List<PdpGroup> afterUpdatePdpGroups = new PdpProvider().getPdpGroups(pfDao, "PdpGroup0", "1.2.3"); + List<PdpGroup> afterUpdatePdpGroups = new PdpProvider().getPdpGroups(pfDao, "PdpGroup0"); assertEquals(10, afterUpdatePdpGroups.get(0).getPdpSubgroups().get(0).getCurrentInstanceCount()); assertEquals(10, afterUpdatePdpGroups.get(0).getPdpSubgroups().get(0).getDesiredInstanceCount()); existingSubGroup.setDesiredInstanceCount(-1); assertThatThrownBy(() -> { - new PdpProvider().updatePdpSubGroup(pfDao, "PdpGroup0", "1.2.3", existingSubGroup); + new PdpProvider().updatePdpSubGroup(pfDao, "PdpGroup0", existingSubGroup); }).hasMessageContaining("INVALID:the desired instance count of a PDP sub group may not be negative"); existingSubGroup.setDesiredInstanceCount(10); } @@ -423,131 +378,67 @@ public class PdpProviderTest { @Test public void testPdpUpdate() throws Exception { assertThatThrownBy(() -> { - new PdpProvider().updatePdp(null, null, null, null, null); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdp(null, null, null, null, new Pdp()); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdp(null, null, null, "TYPE", null); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdp(null, null, null, "TYPE", new Pdp()); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdp(null, null, "version", null, null); + new PdpProvider().updatePdp(null, null, null, null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdp(null, null, "version", null, new Pdp()); + new PdpProvider().updatePdp(null, null, null, new Pdp()); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdp(null, null, "version", "TYPE", null); + new PdpProvider().updatePdp(null, null, "TYPE", null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdp(null, null, "version", "TYPE", new Pdp()); + new PdpProvider().updatePdp(null, null, "TYPE", new Pdp()); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdp(null, "name", null, null, null); + new PdpProvider().updatePdp(null, "name", null, null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdp(null, "name", null, null, new Pdp()); + new PdpProvider().updatePdp(null, "name", null, new Pdp()); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdp(null, "name", null, "TYPE", null); + new PdpProvider().updatePdp(null, "name", "TYPE", null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdp(null, "name", null, "TYPE", new Pdp()); + new PdpProvider().updatePdp(null, "name", "TYPE", new Pdp()); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdp(null, "name", "version", null, null); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdp(null, "name", "version", null, new Pdp()); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdp(null, "name", "version", "TYPE", null); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdp(null, "name", "version", "TYPE", new Pdp()); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, null, null, null, null); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, null, null, null, new Pdp()); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, null, null, "TYPE", null); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, null, null, "TYPE", new Pdp()); + new PdpProvider().updatePdp(pfDao, null, null, null); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, null, "version", null, null); + new PdpProvider().updatePdp(pfDao, null, null, new Pdp()); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, null, "version", null, new Pdp()); + new PdpProvider().updatePdp(pfDao, null, "TYPE", null); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, null, "version", "TYPE", null); + new PdpProvider().updatePdp(pfDao, null, "TYPE", new Pdp()); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, null, "version", "TYPE", new Pdp()); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, "name", null, null, null); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, "name", null, null, new Pdp()); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, "name", null, "TYPE", null); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, "name", null, "TYPE", new Pdp()); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, "name", "version", null, null); + new PdpProvider().updatePdp(pfDao, "name", null, null); }).hasMessage("pdpSubGroup is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, "name", "version", null, new Pdp()); + new PdpProvider().updatePdp(pfDao, "name", null, new Pdp()); }).hasMessage("pdpSubGroup is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, "name", "version", "TYPE", null); + new PdpProvider().updatePdp(pfDao, "name", "TYPE", null); }).hasMessage("pdp is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, "name", "version", "TYPE", new Pdp()); + new PdpProvider().updatePdp(pfDao, "name", "TYPE", new Pdp()); }).hasMessage("parameter \"localName\" is null"); String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroups0.json"); @@ -559,7 +450,7 @@ public class PdpProviderTest { assertEquals(originalJson.replaceAll("\\s+", ""), createdJson.replaceAll("\\s+", "")); PdpGroups gotPdpGroups0 = new PdpGroups(); - gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0", "1.2.3")); + gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0")); String gotJson = standardCoder.encode(gotPdpGroups0); assertEquals(originalJson.replaceAll("\\s+", ""), gotJson.replaceAll("\\s+", "")); @@ -567,9 +458,9 @@ public class PdpProviderTest { Pdp existingPdp = gotPdpGroups0.getGroups().get(0).getPdpSubgroups().get(0).getPdpInstances().get(0); existingPdp.setPdpState(PdpState.TEST); existingPdp.setHealthy(PdpHealthStatus.TEST_IN_PROGRESS); - new PdpProvider().updatePdp(pfDao, "PdpGroup0", "1.2.3", "APEX", existingPdp); + new PdpProvider().updatePdp(pfDao, "PdpGroup0", "APEX", existingPdp); - List<PdpGroup> afterUpdatePdpGroups = new PdpProvider().getPdpGroups(pfDao, "PdpGroup0", "1.2.3"); + List<PdpGroup> afterUpdatePdpGroups = new PdpProvider().getPdpGroups(pfDao, "PdpGroup0"); assertEquals(PdpState.TEST, afterUpdatePdpGroups.get(0).getPdpSubgroups().get(0).getPdpInstances().get(0).getPdpState()); assertEquals(PdpHealthStatus.TEST_IN_PROGRESS, @@ -577,7 +468,7 @@ public class PdpProviderTest { existingPdp.setMessage(""); assertThatThrownBy(() -> { - new PdpProvider().updatePdp(pfDao, "PdpGroup0", "1.2.3", "APEX", existingPdp); + new PdpProvider().updatePdp(pfDao, "PdpGroup0", "APEX", existingPdp); }).hasMessageContaining("INVALID:message may not be blank"); existingPdp.setMessage("A Message"); } @@ -585,274 +476,142 @@ public class PdpProviderTest { @Test public void testGetPdpStatistics() throws PfModelException { assertThatThrownBy(() -> { - new PdpProvider().getPdpStatistics(null, null, null); + new PdpProvider().getPdpStatistics(null, null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().getPdpStatistics(null, null, "version"); + new PdpProvider().getPdpStatistics(null, "name"); }).hasMessage("dao is marked @NonNull but is null"); - assertThatThrownBy(() -> { - new PdpProvider().getPdpStatistics(null, "name", null); - }).hasMessage("dao is marked @NonNull but is null"); - - assertEquals(0, new PdpProvider().getPdpStatistics(pfDao, "name", "version").size()); + assertEquals(0, new PdpProvider().getPdpStatistics(pfDao, "name").size()); } @Test public void testUpdatePdpStatistics() throws PfModelException { assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, null, null, null, null); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, null, null, null, new PdpStatistics()); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, null, null, "inst", null); + new PdpProvider().updatePdpStatistics(null, null, null, null, null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, null, null, "inst", new PdpStatistics()); + new PdpProvider().updatePdpStatistics(null, null, null, null, new PdpStatistics()); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, null, "TYPE", null, null); + new PdpProvider().updatePdpStatistics(null, null, null, "inst", null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, null, "TYPE", null, new PdpStatistics()); + new PdpProvider().updatePdpStatistics(null, null, null, "inst", new PdpStatistics()); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, null, "TYPE", "inst", null); + new PdpProvider().updatePdpStatistics(null, null, "TYPE", null, null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, null, "TYPE", "inst", new PdpStatistics()); + new PdpProvider().updatePdpStatistics(null, null, "TYPE", null, new PdpStatistics()); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, "version", null, null, null); + new PdpProvider().updatePdpStatistics(null, null, "TYPE", "inst", null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, "version", null, null, new PdpStatistics()); + new PdpProvider().updatePdpStatistics(null, null, "TYPE", "inst", new PdpStatistics()); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, "version", null, "inst", null); + new PdpProvider().updatePdpStatistics(null, "name", null, null, null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, "version", null, "inst", new PdpStatistics()); + new PdpProvider().updatePdpStatistics(null, "name", null, null, new PdpStatistics()); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, "version", "TYPE", null, null); + new PdpProvider().updatePdpStatistics(null, "name", null, "inst", null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, "version", "TYPE", null, new PdpStatistics()); + new PdpProvider().updatePdpStatistics(null, "name", null, "inst", new PdpStatistics()); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, "version", "TYPE", "inst", null); + new PdpProvider().updatePdpStatistics(null, "name", "TYPE", null, null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, "version", "TYPE", "inst", new PdpStatistics()); + new PdpProvider().updatePdpStatistics(null, "name", "TYPE", null, new PdpStatistics()); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", null, null, null, null); + new PdpProvider().updatePdpStatistics(null, "name", "TYPE", "inst", null); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", null, null, null, new PdpStatistics()); + new PdpProvider().updatePdpStatistics(null, "name", "TYPE", "inst", new PdpStatistics()); }).hasMessage("dao is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", null, null, "inst", null); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", null, null, "inst", new PdpStatistics()); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", null, "TYPE", null, null); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", null, "TYPE", null, new PdpStatistics()); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", null, "TYPE", "inst", null); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", null, "TYPE", "inst", new PdpStatistics()); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", "version", null, null, null); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", "version", null, null, new PdpStatistics()); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", "version", null, "inst", null); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", "version", null, "inst", new PdpStatistics()); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", "version", "TYPE", null, null); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", "version", "TYPE", null, new PdpStatistics()); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", "version", "TYPE", "inst", null); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", "version", "TYPE", "inst", new PdpStatistics()); - }).hasMessage("dao is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, null, null, null, null); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, null, null, null, new PdpStatistics()); + new PdpProvider().updatePdpStatistics(pfDao, null, null, null, null); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, null, null, "inst", null); + new PdpProvider().updatePdpStatistics(pfDao, null, null, null, new PdpStatistics()); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, null, null, "inst", new PdpStatistics()); + new PdpProvider().updatePdpStatistics(pfDao, null, null, "inst", null); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, null, "TYPE", null, null); + new PdpProvider().updatePdpStatistics(pfDao, null, null, "inst", new PdpStatistics()); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, null, "TYPE", null, new PdpStatistics()); + new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", null, null); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, null, "TYPE", "inst", null); + new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", null, new PdpStatistics()); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, null, "TYPE", "inst", new PdpStatistics()); + new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", "inst", null); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, "version", null, null, null); + new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", "inst", new PdpStatistics()); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, "version", null, null, new PdpStatistics()); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, "version", null, "inst", null); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, "version", null, "inst", new PdpStatistics()); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, "version", "TYPE", null, null); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, "version", "TYPE", null, new PdpStatistics()); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, "version", "TYPE", "inst", null); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, "version", "TYPE", "inst", new PdpStatistics()); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", null, null, null, null); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", null, null, null, new PdpStatistics()); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", null, null, "inst", null); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", null, null, "inst", new PdpStatistics()); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", null, "TYPE", null, null); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", null, "TYPE", null, new PdpStatistics()); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", null, "TYPE", "inst", null); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", null, "TYPE", "inst", new PdpStatistics()); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", "version", null, null, null); + new PdpProvider().updatePdpStatistics(pfDao, "name", null, null, null); }).hasMessage("pdpType is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", "version", null, null, new PdpStatistics()); + new PdpProvider().updatePdpStatistics(pfDao, "name", null, null, new PdpStatistics()); }).hasMessage("pdpType is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", "version", null, "inst", null); + new PdpProvider().updatePdpStatistics(pfDao, "name", null, "inst", null); }).hasMessage("pdpType is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", "version", null, "inst", new PdpStatistics()); + new PdpProvider().updatePdpStatistics(pfDao, "name", null, "inst", new PdpStatistics()); }).hasMessage("pdpType is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", "version", "TYPE", null, null); + new PdpProvider().updatePdpStatistics(pfDao, "name", "TYPE", null, null); }).hasMessage("pdpInstanceId is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", "version", "TYPE", null, new PdpStatistics()); + new PdpProvider().updatePdpStatistics(pfDao, "name", "TYPE", null, new PdpStatistics()); }).hasMessage("pdpInstanceId is marked @NonNull but is null"); assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", "version", "TYPE", "inst", null); + new PdpProvider().updatePdpStatistics(pfDao, "name", "TYPE", "inst", null); }).hasMessage("pdpStatistics is marked @NonNull but is null"); - new PdpProvider().updatePdpStatistics(pfDao, "name", "version", "TYPE", "inst", new PdpStatistics()); + new PdpProvider().updatePdpStatistics(pfDao, "name", "TYPE", "inst", new PdpStatistics()); } } diff --git a/models-pdp/src/test/resources/testdata/PdpGroups0.json b/models-pdp/src/test/resources/testdata/PdpGroups0.json index 6ebdd6c7a..01e140cd8 100644 --- a/models-pdp/src/test/resources/testdata/PdpGroups0.json +++ b/models-pdp/src/test/resources/testdata/PdpGroups0.json @@ -2,7 +2,6 @@ "groups": [ { "name": "PdpGroup0", - "version": "1.2.3", "description": "group description", "pdpGroupState": "PASSIVE", "properties": { diff --git a/models-pdp/src/test/resources/testdata/PdpGroups0Update.json b/models-pdp/src/test/resources/testdata/PdpGroups0Update.json index a54ec53ea..05594fa47 100644 --- a/models-pdp/src/test/resources/testdata/PdpGroups0Update.json +++ b/models-pdp/src/test/resources/testdata/PdpGroups0Update.json @@ -2,7 +2,6 @@ "groups": [ { "name": "PdpGroup0", - "version": "1.2.3", "description": "group description", "pdpGroupState": "PASSIVE", "properties": { diff --git a/models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json b/models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json index f9c822b06..f1d4378fd 100644 --- a/models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json +++ b/models-pdp/src/test/resources/testdata/PdpGroupsForFiltering.json @@ -2,7 +2,6 @@ "groups": [ { "name": "PdpGroup0", - "version": "1.2.3", "description": "group description", "pdpGroupState": "PASSIVE", "properties": { @@ -70,8 +69,7 @@ ] }, { - "name": "PdpGroup0", - "version": "1.2.4", + "name": "PdpGroup10", "description": "group description", "pdpGroupState": "ACTIVE", "properties": { @@ -117,8 +115,7 @@ ] }, { - "name": "PdpGroup0", - "version": "1.2.1", + "name": "PdpGroup20", "description": "group description", "pdpGroupState": "SAFE", "properties": { @@ -193,7 +190,6 @@ }, { "name": "PdpGroup1", - "version": "1.2.1", "description": "group description", "pdpGroupState": "PASSIVE", "properties": { @@ -235,8 +231,7 @@ ] }, { - "name": "PdpGroup1", - "version": "1.2.3", + "name": "PdpGroup11", "description": "group description", "pdpGroupState": "TEST", "properties": { diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java index b186e2b36..a7d414533 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java @@ -278,11 +278,10 @@ public interface PolicyModelsProvider extends AutoCloseable { * Get PDP groups. * * @param name the name of the policy to get, null to get all PDP groups - * @param version the version of the policy to get, null to get all versions of a PDP group * @return the PDP groups found * @throws PfModelException on errors getting PDP groups */ - public List<PdpGroup> getPdpGroups(final String name, final String version) throws PfModelException; + public List<PdpGroup> getPdpGroups(final String name) throws PfModelException; /** * Get filtered PDP groups. @@ -315,56 +314,50 @@ public interface PolicyModelsProvider extends AutoCloseable { * Update a PDP subgroup. * * @param pdpGroupName the name of the PDP group of the PDP subgroup - * @param pdpGroupVersion the version of the PDP group of the PDP subgroup * @param pdpSubGroup the PDP subgroup to be updated * @throws PfModelException on errors updating PDP subgroups */ - public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion, - @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException; + public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final PdpSubGroup pdpSubGroup) + throws PfModelException; /** * Update a PDP. * * @param pdpGroupName the name of the PDP group of the PDP subgroup - * @param pdpGroupVersion the version of the PDP group of the PDP subgroup * @param pdpSubGroup the PDP subgroup to be updated * @param pdp the PDP to be updated * @throws PfModelException on errors updating PDP subgroups */ - public void updatePdp(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion, - @NonNull final String pdpSubGroup, @NonNull final Pdp pdp) throws PfModelException; + public void updatePdp(@NonNull final String pdpGroupName, @NonNull final String pdpSubGroup, @NonNull final Pdp pdp) + throws PfModelException; /** * Delete a PDP group. * * @param name the name of the policy to get, null to get all PDP groups - * @param version the version of the policy to get, null to get all versions of a PDP group * @return the PDP group deleted * @throws PfModelException on errors deleting PDP groups */ - public PdpGroup deletePdpGroup(@NonNull final String name, @NonNull final String version) throws PfModelException; + public PdpGroup deletePdpGroup(@NonNull final String name) throws PfModelException; /** * Get PDP statistics. * * @param name the name of the PDP group to get statistics for, null to get all PDP groups - * @param version the version of the PDP group to get statistics for, null to get all versions of a PDP group * @return the statistics found * @throws PfModelException on errors getting statistics */ - public List<PdpStatistics> getPdpStatistics(final String name, final String version) throws PfModelException; + public List<PdpStatistics> getPdpStatistics(final String name) throws PfModelException; /** * Update PDP statistics for a PDP. * * @param pdpGroupName the name of the PDP group containing the PDP that the statistics are for - * @param pdpGroupVersion the version of the PDP group containing the PDP that the statistics are for * @param pdpType the PDP type of the subgroup containing the PDP that the statistics are for * @param pdpInstanceId the instance ID of the PDP to update statistics for * @param pdpStatistics the PDP statistics * @throws PfModelException on errors updating statistics */ - public void updatePdpStatistics(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion, - @NonNull final String pdpType, @NonNull final String pdpInstanceId, - @NonNull final PdpStatistics pdpStatistics) throws PfModelException; + public void updatePdpStatistics(@NonNull final String pdpGroupName, @NonNull final String pdpType, + @NonNull final String pdpInstanceId, @NonNull final PdpStatistics pdpStatistics) throws PfModelException; } diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java index cd7b7f38e..a6e8f325b 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java @@ -284,9 +284,9 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider { } @Override - public List<PdpGroup> getPdpGroups(final String name, final String version) throws PfModelException { + public List<PdpGroup> getPdpGroups(final String name) throws PfModelException { assertInitilized(); - return new PdpProvider().getPdpGroups(pfDao, name, version); + return new PdpProvider().getPdpGroups(pfDao, name); } @Override @@ -308,36 +308,35 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider { } @Override - public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion, - @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException { + public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final PdpSubGroup pdpSubGroup) + throws PfModelException { assertInitilized(); - new PdpProvider().updatePdpSubGroup(pfDao, pdpGroupName, pdpGroupVersion, pdpSubGroup); + new PdpProvider().updatePdpSubGroup(pfDao, pdpGroupName, pdpSubGroup); } @Override - public void updatePdp(@NonNull String pdpGroupName, @NonNull String pdpGroupVersion, @NonNull String pdpSubGroup, - @NonNull Pdp pdp) throws PfModelException { - new PdpProvider().updatePdp(pfDao, pdpGroupName, pdpGroupVersion, pdpSubGroup, pdp); + public void updatePdp(@NonNull String pdpGroupName, @NonNull String pdpSubGroup, @NonNull Pdp pdp) + throws PfModelException { + new PdpProvider().updatePdp(pfDao, pdpGroupName, pdpSubGroup, pdp); } @Override - public PdpGroup deletePdpGroup(@NonNull final String name, @NonNull final String version) throws PfModelException { + public PdpGroup deletePdpGroup(@NonNull final String name) throws PfModelException { assertInitilized(); - return new PdpProvider().deletePdpGroup(pfDao, name, version); + return new PdpProvider().deletePdpGroup(pfDao, name); } @Override - public List<PdpStatistics> getPdpStatistics(final String name, final String version) throws PfModelException { + public List<PdpStatistics> getPdpStatistics(final String name) throws PfModelException { assertInitilized(); - return new PdpProvider().getPdpStatistics(pfDao, name, version); + return new PdpProvider().getPdpStatistics(pfDao, name); } @Override - public void updatePdpStatistics(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion, - @NonNull final String pdpType, @NonNull final String pdpInstanceId, - @NonNull final PdpStatistics pdpStatistics) throws PfModelException { + public void updatePdpStatistics(@NonNull final String pdpGroupName, @NonNull final String pdpType, + @NonNull final String pdpInstanceId, @NonNull final PdpStatistics pdpStatistics) throws PfModelException { assertInitilized(); - new PdpProvider().updatePdpStatistics(pfDao, pdpGroupName, pdpGroupVersion, pdpType, pdpInstanceId, + new PdpProvider().updatePdpStatistics(pfDao, pdpGroupName, pdpType, pdpInstanceId, pdpStatistics); } diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java index 90545f389..9b1ca7669 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java @@ -93,20 +93,17 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider { } @Override - public ToscaServiceTemplate createPolicyTypes(final ToscaServiceTemplate serviceTemplate) - throws PfModelException { + public ToscaServiceTemplate createPolicyTypes(final ToscaServiceTemplate serviceTemplate) throws PfModelException { return serviceTemplate; } @Override - public ToscaServiceTemplate updatePolicyTypes(final ToscaServiceTemplate serviceTemplate) - throws PfModelException { + public ToscaServiceTemplate updatePolicyTypes(final ToscaServiceTemplate serviceTemplate) throws PfModelException { return serviceTemplate; } @Override - public ToscaServiceTemplate deletePolicyType(final String name, final String version) - throws PfModelException { + public ToscaServiceTemplate deletePolicyType(final String name, final String version) throws PfModelException { return getDummyResponse("dummyimpl/DummyToscaPolicyTypeDeleteResponse.json"); } @@ -131,20 +128,17 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider { } @Override - public ToscaServiceTemplate createPolicies(final ToscaServiceTemplate serviceTemplate) - throws PfModelException { + public ToscaServiceTemplate createPolicies(final ToscaServiceTemplate serviceTemplate) throws PfModelException { return serviceTemplate; } @Override - public ToscaServiceTemplate updatePolicies(final ToscaServiceTemplate serviceTemplate) - throws PfModelException { + public ToscaServiceTemplate updatePolicies(final ToscaServiceTemplate serviceTemplate) throws PfModelException { return serviceTemplate; } @Override - public ToscaServiceTemplate deletePolicy(final String name, final String version) - throws PfModelException { + public ToscaServiceTemplate deletePolicy(final String name, final String version) throws PfModelException { return getDummyResponse("dummyimpl/DummyToscaPolicyDeleteResponse.json"); } @@ -155,14 +149,14 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider { } @Override - public LegacyOperationalPolicy createOperationalPolicy( - final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException { + public LegacyOperationalPolicy createOperationalPolicy(final LegacyOperationalPolicy legacyOperationalPolicy) + throws PfModelException { return legacyOperationalPolicy; } @Override - public LegacyOperationalPolicy updateOperationalPolicy( - final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException { + public LegacyOperationalPolicy updateOperationalPolicy(final LegacyOperationalPolicy legacyOperationalPolicy) + throws PfModelException { return legacyOperationalPolicy; } @@ -177,25 +171,24 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider { } @Override - public Map<String, LegacyGuardPolicyOutput> createGuardPolicy( - final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException { + public Map<String, LegacyGuardPolicyOutput> createGuardPolicy(final LegacyGuardPolicyInput legacyGuardPolicy) + throws PfModelException { return new HashMap<>(); } @Override - public Map<String, LegacyGuardPolicyOutput> updateGuardPolicy( - final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException { + public Map<String, LegacyGuardPolicyOutput> updateGuardPolicy(final LegacyGuardPolicyInput legacyGuardPolicy) + throws PfModelException { return new HashMap<>(); } @Override - public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(final String policyId) - throws PfModelException { + public Map<String, LegacyGuardPolicyOutput> deleteGuardPolicy(final String policyId) throws PfModelException { return new HashMap<>(); } @Override - public List<PdpGroup> getPdpGroups(final String name, final String version) throws PfModelException { + public List<PdpGroup> getPdpGroups(final String name) throws PfModelException { return new ArrayList<>(); } @@ -215,30 +208,27 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider { } @Override - public void updatePdpSubGroup(final String pdpGroupName, final String pdpGroupVersion, - final PdpSubGroup pdpSubGroup) throws PfModelException { + public void updatePdpSubGroup(final String pdpGroupName, final PdpSubGroup pdpSubGroup) throws PfModelException { // Not implemented } @Override - public void updatePdp(String pdpGroupName, String pdpGroupVersion, - String pdpSubGroup, Pdp pdp) throws PfModelException { + public void updatePdp(String pdpGroupName, String pdpSubGroup, Pdp pdp) throws PfModelException { // Not implemented } @Override - public PdpGroup deletePdpGroup(final String name, final String version) throws PfModelException { + public PdpGroup deletePdpGroup(final String name) throws PfModelException { return null; } @Override - public List<PdpStatistics> getPdpStatistics(final String name, final String version) throws PfModelException { + public List<PdpStatistics> getPdpStatistics(final String name) throws PfModelException { return new ArrayList<>(); } @Override - public void updatePdpStatistics(final String pdpGroupName, final String pdpGroupVersion, - final String pdpType, final String pdpInstanceId, + public void updatePdpStatistics(final String pdpGroupName, final String pdpType, final String pdpInstanceId, final PdpStatistics pdppStatistics) throws PfModelException { // Not implemented } diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java index ff8dfe322..ccdf45af4 100644 --- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java +++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java @@ -234,229 +234,119 @@ public class DatabasePolicyModelsProviderTest { }).hasMessage("pdpGroups is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpSubGroup(null, null, null); + databaseProvider.updatePdpSubGroup(null, null); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpSubGroup(null, null, new PdpSubGroup()); + databaseProvider.updatePdpSubGroup(null, new PdpSubGroup()); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpSubGroup(null, "version", null); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpSubGroup(null, "version", new PdpSubGroup()); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpSubGroup("name", null, null); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpSubGroup("name", null, new PdpSubGroup()); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpSubGroup("name", "version", null); + databaseProvider.updatePdpSubGroup("name", null); }).hasMessage("pdpSubGroup is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdp(null, null, null, null); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); + databaseProvider.updatePdpSubGroup("name", new PdpSubGroup()); + }).hasMessage("parameter \"localName\" is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdp(null, null, null, new Pdp()); + databaseProvider.updatePdp(null, null, null); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdp(null, null, "sub", null); + databaseProvider.updatePdp(null, null, new Pdp()); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdp(null, null, "sub", new Pdp()); + databaseProvider.updatePdp(null, "sub", null); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdp(null, "version", null, null); + databaseProvider.updatePdp(null, "sub", new Pdp()); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdp(null, "version", null, new Pdp()); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdp(null, "version", "sub", null); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdp(null, "version", "sub", new Pdp()); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdp("name", null, null, null); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdp("name", null, null, new Pdp()); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdp("name", null, "sub", null); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdp("name", null, "sub", new Pdp()); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdp("name", "version", null, null); + databaseProvider.updatePdp("name", null, null); }).hasMessage("pdpSubGroup is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdp("name", "version", null, new Pdp()); + databaseProvider.updatePdp("name", null, new Pdp()); }).hasMessage("pdpSubGroup is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdp("name", "version", "sub", null); + databaseProvider.updatePdp("name", "sub", null); }).hasMessage("pdp is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.deletePdpGroup(null, null); - }).hasMessage("name is marked @NonNull but is null"); + databaseProvider.updatePdp("name", "sub", new Pdp()); + }).hasMessage("parameter \"localName\" is null"); assertThatThrownBy(() -> { - databaseProvider.deletePdpGroup(null, "version"); + databaseProvider.deletePdpGroup(null); }).hasMessage("name is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.deletePdpGroup("name", null); - }).hasMessage("version is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, null, null, null, null); + databaseProvider.updatePdpStatistics(null, null, null, null); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, null, null, null, new PdpStatistics()); + databaseProvider.updatePdpStatistics(null, null, null, new PdpStatistics()); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, null, null, "Instance", null); + databaseProvider.updatePdpStatistics(null, null, "Instance", null); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, null, null, "Instance", new PdpStatistics()); + databaseProvider.updatePdpStatistics(null, null, "Instance", new PdpStatistics()); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, null, "type", null, null); + databaseProvider.updatePdpStatistics(null, "type", null, null); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, null, "type", null, new PdpStatistics()); + databaseProvider.updatePdpStatistics(null, "type", null, new PdpStatistics()); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, null, "type", "Instance", null); + databaseProvider.updatePdpStatistics(null, "type", "Instance", null); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, null, "type", "Instance", new PdpStatistics()); + databaseProvider.updatePdpStatistics(null, "type", "Instance", new PdpStatistics()); }).hasMessage("pdpGroupName is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, "ver", null, null, null); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, "ver", null, null, new PdpStatistics()); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, "ver", null, "Instance", null); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, "ver", null, "Instance", new PdpStatistics()); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, "ver", "type", null, null); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, "ver", "type", null, new PdpStatistics()); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, "ver", "type", "Instance", null); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics(null, "ver", "type", "Instance", new PdpStatistics()); - }).hasMessage("pdpGroupName is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics("name", null, null, null, null); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics("name", null, null, null, new PdpStatistics()); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics("name", null, null, "Instance", null); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics("name", null, null, "Instance", new PdpStatistics()); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics("name", null, "type", null, null); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics("name", null, "type", null, new PdpStatistics()); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics("name", null, "type", "Instance", null); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics("name", null, "type", "Instance", new PdpStatistics()); - }).hasMessage("pdpGroupVersion is marked @NonNull but is null"); - - assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics("name", "ver", null, null, null); + databaseProvider.updatePdpStatistics("name", null, null, null); }).hasMessage("pdpType is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics("name", "ver", null, null, new PdpStatistics()); + databaseProvider.updatePdpStatistics("name", null, null, new PdpStatistics()); }).hasMessage("pdpType is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics("name", "ver", null, "Instance", null); + databaseProvider.updatePdpStatistics("name", null, "Instance", null); }).hasMessage("pdpType is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics("name", "ver", null, "Instance", new PdpStatistics()); + databaseProvider.updatePdpStatistics("name", null, "Instance", new PdpStatistics()); }).hasMessage("pdpType is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics("name", "ver", "type", null, null); + databaseProvider.updatePdpStatistics("name", "type", null, null); }).hasMessage("pdpInstanceId is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics("name", "ver", "type", null, new PdpStatistics()); + databaseProvider.updatePdpStatistics("name", "type", null, new PdpStatistics()); }).hasMessage("pdpInstanceId is marked @NonNull but is null"); assertThatThrownBy(() -> { - databaseProvider.updatePdpStatistics("name", "ver", "type", "Instance", null); + databaseProvider.updatePdpStatistics("name", "type", "Instance", null); }).hasMessage("pdpStatistics is marked @NonNull but is null"); + databaseProvider.updatePdpStatistics("name", "type", "Instance", new PdpStatistics()); + databaseProvider.close(); } @@ -545,7 +435,7 @@ public class DatabasePolicyModelsProviderTest { databaseProvider.deleteGuardPolicy("policy_id"); }).hasMessage("no policy found for policy ID: policy_id"); - assertEquals(0, databaseProvider.getPdpGroups("name", "version").size()); + assertEquals(0, databaseProvider.getPdpGroups("name").size()); assertEquals(0, databaseProvider.getFilteredPdpGroups(PdpGroupFilter.builder().build()).size()); assertNotNull(databaseProvider.createPdpGroups(new ArrayList<>())); @@ -576,29 +466,29 @@ public class DatabasePolicyModelsProviderTest { assertEquals(123, databaseProvider.createPdpGroups(groupList).get(0).getPdpSubgroups().get(0) .getDesiredInstanceCount()); - assertEquals(1, databaseProvider.getPdpGroups("group", "1.2.3").size()); + assertEquals(1, databaseProvider.getPdpGroups("group").size()); pdpSubGroup.setDesiredInstanceCount(234); - databaseProvider.updatePdpSubGroup("group", "1.2.3", pdpSubGroup); - assertEquals(234, databaseProvider.getPdpGroups("group", "1.2.3").get(0).getPdpSubgroups() + databaseProvider.updatePdpSubGroup("group", pdpSubGroup); + assertEquals(234, databaseProvider.getPdpGroups("group").get(0).getPdpSubgroups() .get(0).getDesiredInstanceCount()); - assertEquals("Hello", databaseProvider.getPdpGroups("group", "1.2.3").get(0).getPdpSubgroups() + assertEquals("Hello", databaseProvider.getPdpGroups("group").get(0).getPdpSubgroups() .get(0).getPdpInstances().get(0).getMessage()); pdp.setMessage("Howdy"); - databaseProvider.updatePdp("group", "1.2.3", "type", pdp); - assertEquals("Howdy", databaseProvider.getPdpGroups("group", "1.2.3").get(0).getPdpSubgroups() + databaseProvider.updatePdp("group", "type", pdp); + assertEquals("Howdy", databaseProvider.getPdpGroups("group").get(0).getPdpSubgroups() .get(0).getPdpInstances().get(0).getMessage()); assertThatThrownBy(() -> { - databaseProvider.deletePdpGroup("name", "version"); - }).hasMessage("delete of PDP group \"name:version\" failed, PDP group does not exist"); + databaseProvider.deletePdpGroup("name"); + }).hasMessage("delete of PDP group \"name:0.0.0\" failed, PDP group does not exist"); - assertEquals(pdpGroup.getName(), databaseProvider.deletePdpGroup("group", "1.2.3").getName()); + assertEquals(pdpGroup.getName(), databaseProvider.deletePdpGroup("group").getName()); - assertEquals(0, databaseProvider.getPdpStatistics(null, null).size()); + assertEquals(0, databaseProvider.getPdpStatistics(null).size()); - databaseProvider.updatePdpStatistics("group", "1.2.3", "type", "type-0", new PdpStatistics()); + databaseProvider.updatePdpStatistics("group", "type", "type-0", new PdpStatistics()); } catch (Exception exc) { LOGGER.warn("test should not throw an exception", exc); fail("test should not throw an exception"); diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java index 61f88741c..3e182c02d 100644 --- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java +++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java @@ -147,7 +147,7 @@ public class DummyBadProviderImpl implements PolicyModelsProvider { } @Override - public List<PdpGroup> getPdpGroups(String name, String version) throws PfModelException { + public List<PdpGroup> getPdpGroups(String name) throws PfModelException { return null; } @@ -162,11 +162,11 @@ public class DummyBadProviderImpl implements PolicyModelsProvider { } @Override - public void updatePdp(@NonNull String pdpGroupName, @NonNull String pdpGroupVersion, @NonNull String pdpSubGroup, + public void updatePdp(@NonNull String pdpGroupName, @NonNull String pdpSubGroup, @NonNull Pdp pdp) throws PfModelException {} @Override - public PdpGroup deletePdpGroup(@NonNull String name, @NonNull String verison) throws PfModelException { + public PdpGroup deletePdpGroup(@NonNull String name) throws PfModelException { return null; } @@ -207,15 +207,15 @@ public class DummyBadProviderImpl implements PolicyModelsProvider { } @Override - public void updatePdpSubGroup(@NonNull String pdpGroupName, @NonNull String pdpGroupVersion, + public void updatePdpSubGroup(@NonNull String pdpGroupName, @NonNull PdpSubGroup pdpSubGroup) throws PfModelException {} @Override - public List<PdpStatistics> getPdpStatistics(String name, String version) throws PfModelException { + public List<PdpStatistics> getPdpStatistics(String name) throws PfModelException { return null; } @Override - public void updatePdpStatistics(@NonNull String pdpGroupName, @NonNull String pdpGroupVersion, + public void updatePdpStatistics(@NonNull String pdpGroupName, @NonNull String pdpType, @NonNull String pdpInstanceId, @NonNull PdpStatistics pdppStatistics) {} } diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java index 5a0cddb03..9f02fd7a4 100644 --- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java +++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java @@ -104,16 +104,16 @@ public class DummyPolicyModelsProviderTest { assertNotNull(dummyProvider.updateGuardPolicy(new LegacyGuardPolicyInput())); assertNotNull(dummyProvider.deleteGuardPolicy("policy_id")); - assertTrue(dummyProvider.getPdpGroups("name", "version").isEmpty()); + assertTrue(dummyProvider.getPdpGroups("name").isEmpty()); assertTrue(dummyProvider.getFilteredPdpGroups(PdpGroupFilter.builder().build()).isEmpty()); assertTrue(dummyProvider.createPdpGroups(new ArrayList<>()).isEmpty()); assertTrue(dummyProvider.updatePdpGroups(new ArrayList<>()).isEmpty()); - assertNull(dummyProvider.deletePdpGroup("name", "version")); + assertNull(dummyProvider.deletePdpGroup("name")); - dummyProvider.updatePdpSubGroup("name", "version", new PdpSubGroup()); - dummyProvider.updatePdp("name", "version", "type", new Pdp()); - dummyProvider.updatePdpStatistics("name", "version", "type", "type-0", new PdpStatistics()); - assertTrue(dummyProvider.getPdpStatistics("name", "version").isEmpty()); + dummyProvider.updatePdpSubGroup("name", new PdpSubGroup()); + dummyProvider.updatePdp("name", "type", new Pdp()); + dummyProvider.updatePdpStatistics("name", "type", "type-0", new PdpStatistics()); + assertTrue(dummyProvider.getPdpStatistics("name").isEmpty()); dummyProvider.close(); } |