From 6b6eb52ef3111142ba2dc9afb85cdd48dc0454ca Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 10 May 2021 11:39:27 -0400 Subject: [PATCH] Fix sonars in policy models Fixed: - use "var" Issue-ID: POLICY-3094 Change-Id: Id5ea7ab049c2018744afa75a55d44e47f216d5bc Signed-off-by: Jim Hahn --- .../models/pdp/concepts/DeploymentGroup.java | 8 +++--- .../models/pdp/concepts/DeploymentGroups.java | 4 +-- .../models/pdp/concepts/DeploymentSubGroup.java | 4 +-- .../onap/policy/models/pdp/concepts/PdpGroup.java | 2 +- .../policy/models/pdp/concepts/PdpGroupFilter.java | 4 +-- .../policy/models/pdp/concepts/PdpSubGroup.java | 2 +- .../models/pdp/persistence/concepts/JpaPdp.java | 2 +- .../pdp/persistence/concepts/JpaPdpGroup.java | 4 +-- .../persistence/concepts/JpaPdpPolicyStatus.java | 6 ++-- .../pdp/persistence/concepts/JpaPdpStatistics.java | 4 +-- .../pdp/persistence/concepts/JpaPdpSubGroup.java | 8 +++--- .../pdp/persistence/provider/PdpProvider.java | 23 ++++++++-------- .../provider/PdpStatisticsProvider.java | 11 ++++---- .../provider/impl/AbstractModelsProvider.java | 6 ++-- .../impl/DatabasePolicyModelsProviderImpl.java | 6 ++-- .../impl/DummyPolicyModelsProviderImpl.java | 2 +- .../impl/DatabasePolicyModelsProviderTest.java | 2 +- .../concepts/ToscaConceptIdentifier.java | 2 +- .../provider/AuthorativeToscaProvider.java | 10 +++---- .../concepts/JpaToscaCapabilityAssignment.java | 2 +- .../simple/concepts/JpaToscaConstraintLogical.java | 3 +- .../concepts/JpaToscaConstraintValidValues.java | 4 +-- .../tosca/simple/concepts/JpaToscaDataType.java | 2 +- .../simple/concepts/JpaToscaNodeTemplate.java | 2 +- .../tosca/simple/concepts/JpaToscaNodeType.java | 2 +- .../tosca/simple/concepts/JpaToscaParameter.java | 4 +-- .../tosca/simple/concepts/JpaToscaPolicy.java | 2 +- .../tosca/simple/concepts/JpaToscaPolicyType.java | 2 +- .../tosca/simple/concepts/JpaToscaProperty.java | 2 +- .../tosca/simple/concepts/JpaToscaRequirement.java | 2 +- .../simple/concepts/JpaToscaSchemaDefinition.java | 2 +- .../simple/concepts/JpaToscaServiceTemplate.java | 2 +- .../simple/concepts/JpaToscaTopologyTemplate.java | 4 +-- .../concepts/JpaToscaWithToscaProperties.java | 4 +-- .../JpaToscaWithTypeAndStringProperties.java | 2 +- .../tosca/simple/provider/SimpleToscaProvider.java | 32 +++++++++++----------- .../tosca/utils/ToscaServiceTemplateUtils.java | 8 +++--- .../onap/policy/models/tosca/utils/ToscaUtils.java | 3 +- 38 files changed, 95 insertions(+), 99 deletions(-) diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroup.java index 8746c0721..79e5e79b9 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroup.java @@ -63,7 +63,7 @@ public class DeploymentGroup { * @return the validation result */ public ValidationResult validatePapRest() { - BeanValidationResult result = new BeanValidationResult("group", this); + var result = new BeanValidationResult("group", this); result.validateNotNull("name", name); result.validateNotNullList(SUBGROUP_FIELD, deploymentSubgroups, DeploymentSubGroup::validatePapRest); @@ -94,15 +94,15 @@ public class DeploymentGroup { Map pdpType2action = new HashMap<>(); for (DeploymentSubGroup subgrp : deploymentSubgroups) { - Action action = subgrp.getAction(); + var action = subgrp.getAction(); pdpType2action.compute(subgrp.getPdpType(), (pdpType, curact) -> { if (curact != null && action == Action.PATCH) { - BeanValidationResult subResult = new BeanValidationResult(pdpType, pdpType); + var subResult = new BeanValidationResult(pdpType, pdpType); subResult.addResult("action", action, ValidationStatus.INVALID, "incompatible with previous action: " + curact); - BeanValidationResult subResult2 = new BeanValidationResult(SUBGROUP_FIELD, subgrp); + var subResult2 = new BeanValidationResult(SUBGROUP_FIELD, subgrp); subResult2.addResult(subResult); result.addResult(subResult2); } diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroups.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroups.java index 0d810d210..dfdf3ac19 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroups.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentGroups.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Models * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public class DeploymentGroups { * @return the validation result */ public ValidationResult validatePapRest() { - BeanValidationResult result = new BeanValidationResult(GROUPS_FIELD, this); + var result = new BeanValidationResult(GROUPS_FIELD, this); result.validateNotNullList(GROUPS_FIELD, groups, DeploymentGroup::validatePapRest); if (!result.isValid()) { diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroup.java index 35443a291..361f7daa9 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroup.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -72,7 +72,7 @@ public class DeploymentSubGroup { * @return the validation result */ public ValidationResult validatePapRest() { - BeanValidationResult result = new BeanValidationResult("group", this); + var result = new BeanValidationResult("group", this); result.validateNotNull("pdpType", pdpType); result.validateNotNull("action", action); 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 6d7607924..845b7ad76 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 @@ -84,7 +84,7 @@ public class PdpGroup implements PfNameVersion, Comparable { * @return the validation result */ public ValidationResult validatePapRest(boolean updateGroupFlow) { - BeanValidationResult result = new BeanValidationResult("group", this); + var result = new BeanValidationResult("group", this); /* * Don't care about state, because we override it. Ok if description is null. 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 a7ceaa9a5..ad64deb21 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 @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. - * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -143,7 +143,7 @@ public class PdpGroupFilter implements PfObjectFilter { for (ToscaConceptIdentifier supportedPolicyType : supportedPolicyTypes) { String supName = supportedPolicyType.getName(); if (supName.endsWith(".*")) { - String substr = supName.substring(0, supName.length() - 1); + var substr = supName.substring(0, supName.length() - 1); if (typeFilter.stream().anyMatch(type -> type.getName().startsWith(substr))) { return true; } diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java index 0e9554d03..3cf8b9b05 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java @@ -80,7 +80,7 @@ public class PdpSubGroup { * @return the validation result */ public ValidationResult validatePapRest(boolean updateGroupFlow) { - BeanValidationResult result = new BeanValidationResult("group", this); + var result = new BeanValidationResult("group", this); result.validateNotNull("pdpType", pdpType); // When doing PdpGroup Update operation, supported policy types and policies doesn't have to be validated. diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdp.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdp.java index 87a52fe38..daa327d9f 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdp.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdp.java @@ -131,7 +131,7 @@ public class JpaPdp extends PfConcept implements PfAuthorative, Serializabl @Override public Pdp toAuthorative() { - Pdp pdp = new Pdp(); + var pdp = new Pdp(); pdp.setInstanceId(key.getLocalName()); pdp.setPdpState(pdpState); diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java index c91bf9a62..c94cfdd91 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java @@ -153,7 +153,7 @@ public class JpaPdpGroup extends PfConcept implements PfAuthorative { @Override public PdpGroup toAuthorative() { - PdpGroup pdpGroup = new PdpGroup(); + var pdpGroup = new PdpGroup(); pdpGroup.setName(getKey().getName()); pdpGroup.setVersion(getKey().getVersion()); @@ -184,7 +184,7 @@ public class JpaPdpGroup extends PfConcept implements PfAuthorative { this.pdpSubGroups = new ArrayList<>(); for (PdpSubGroup pdpSubgroup : pdpGroup.getPdpSubgroups()) { - JpaPdpSubGroup jpaPdpSubGroup = new JpaPdpSubGroup(); + var jpaPdpSubGroup = new JpaPdpSubGroup(); jpaPdpSubGroup.setKey(new PfReferenceKey(getKey(), pdpSubgroup.getPdpType())); jpaPdpSubGroup.fromAuthorative(pdpSubgroup); this.pdpSubGroups.add(jpaPdpSubGroup); diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpPolicyStatus.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpPolicyStatus.java index 71ec6b8a9..536bb76a2 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpPolicyStatus.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpPolicyStatus.java @@ -154,10 +154,8 @@ public class JpaPdpPolicyStatus extends PfConcept implements PfAuthorative()); for (PfSearchableKey supportedPolicyTypeKey : supportedPolicyTypes) { - ToscaConceptIdentifier supportedPolicyTypeIdent = new ToscaConceptIdentifier( + var supportedPolicyTypeIdent = new ToscaConceptIdentifier( supportedPolicyTypeKey.getName(), supportedPolicyTypeKey.getVersion()); pdpSubgroup.getSupportedPolicyTypes().add(supportedPolicyTypeIdent); } pdpSubgroup.setPolicies(new ArrayList<>()); for (PfConceptKey policyKey : policies) { - ToscaConceptIdentifier toscaPolicyIdentifier = new ToscaConceptIdentifier(); + var toscaPolicyIdentifier = new ToscaConceptIdentifier(); toscaPolicyIdentifier.setName(policyKey.getName()); toscaPolicyIdentifier.setVersion(policyKey.getVersion()); pdpSubgroup.getPolicies().add(toscaPolicyIdentifier); @@ -233,7 +233,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative(); if (pdpSubgroup.getPdpInstances() != null) { for (Pdp pdp : pdpSubgroup.getPdpInstances()) { - JpaPdp jpaPdp = new JpaPdp(); + var jpaPdp = new JpaPdp(); jpaPdp.setKey(new PfReferenceKey(getKey(), pdp.getInstanceId())); jpaPdp.fromAuthorative(pdp); this.pdpInstances.add(jpaPdp); 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 7d59166e2..4ffb1e40e 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 @@ -95,7 +95,7 @@ public class PdpProvider { throws PfModelException { for (PdpGroup pdpGroup : pdpGroups) { - JpaPdpGroup jpaPdpGroup = new JpaPdpGroup(); + var jpaPdpGroup = new JpaPdpGroup(); jpaPdpGroup.fromAuthorative(pdpGroup); BeanValidationResult validationResult = jpaPdpGroup.validate("PDP group"); @@ -110,8 +110,7 @@ public class PdpProvider { List returnPdpGroups = new ArrayList<>(); for (PdpGroup pdpGroup : pdpGroups) { - JpaPdpGroup jpaPdpGroup = - dao.get(JpaPdpGroup.class, new PfConceptKey(pdpGroup.getName(), PfKey.NULL_KEY_VERSION)); + var jpaPdpGroup = dao.get(JpaPdpGroup.class, new PfConceptKey(pdpGroup.getName(), PfKey.NULL_KEY_VERSION)); returnPdpGroups.add(jpaPdpGroup.toAuthorative()); } @@ -130,7 +129,7 @@ public class PdpProvider { throws PfModelException { for (PdpGroup pdpGroup : pdpGroups) { - JpaPdpGroup jpaPdpGroup = new JpaPdpGroup(); + var jpaPdpGroup = new JpaPdpGroup(); jpaPdpGroup.fromAuthorative(pdpGroup); BeanValidationResult validationResult = jpaPdpGroup.validate("PDP group"); @@ -145,7 +144,7 @@ public class PdpProvider { List returnPdpGroups = new ArrayList<>(); for (PdpGroup pdpGroup : pdpGroups) { - JpaPdpGroup jpaPdpGroup = + var jpaPdpGroup = dao.get(JpaPdpGroup.class, new PfConceptKey(pdpGroup.getName(), PfKey.NULL_KEY_VERSION)); returnPdpGroups.add(jpaPdpGroup.toAuthorative()); } @@ -164,9 +163,9 @@ public class PdpProvider { public void updatePdpSubGroup(@NonNull final PfDao dao, @NonNull final String pdpGroupName, @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException { - final PfReferenceKey subGroupKey = + final var subGroupKey = new PfReferenceKey(pdpGroupName, PfKey.NULL_KEY_VERSION, pdpSubGroup.getPdpType()); - final JpaPdpSubGroup jpaPdpSubgroup = new JpaPdpSubGroup(subGroupKey); + final var jpaPdpSubgroup = new JpaPdpSubGroup(subGroupKey); jpaPdpSubgroup.fromAuthorative(pdpSubGroup); BeanValidationResult validationResult = jpaPdpSubgroup.validate("PDP sub group"); @@ -189,9 +188,9 @@ public class PdpProvider { public void updatePdp(@NonNull final PfDao dao, @NonNull final String pdpGroupName, @NonNull final String pdpSubGroup, @NonNull final Pdp pdp) { - final PfReferenceKey pdpKey = + final var pdpKey = new PfReferenceKey(pdpGroupName, PfKey.NULL_KEY_VERSION, pdpSubGroup, pdp.getInstanceId()); - final JpaPdp jpaPdp = new JpaPdp(pdpKey); + final var jpaPdp = new JpaPdp(pdpKey); jpaPdp.fromAuthorative(pdp); BeanValidationResult validationResult = jpaPdp.validate("PDP"); @@ -212,7 +211,7 @@ public class PdpProvider { */ public PdpGroup deletePdpGroup(@NonNull final PfDao dao, @NonNull final String name) { - PfConceptKey pdpGroupKey = new PfConceptKey(name, PfKey.NULL_KEY_VERSION); + var pdpGroupKey = new PfConceptKey(name, PfKey.NULL_KEY_VERSION); JpaPdpGroup jpaDeletePdpGroup = dao.get(JpaPdpGroup.class, pdpGroupKey); @@ -341,9 +340,9 @@ public class PdpProvider { List jpas = objs.stream().map(JpaPdpPolicyStatus::new).collect(Collectors.toList()); // validate the objects - BeanValidationResult result = new BeanValidationResult(fieldName, jpas); + var result = new BeanValidationResult(fieldName, jpas); - int count = 0; + var count = 0; for (JpaPdpPolicyStatus jpa: jpas) { result.addResult(jpa.validate(String.valueOf(count++))); } diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java index ece09b088..205761bf5 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019-2021 Nordix Foundation. - * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,6 @@ public class PdpStatisticsProvider { */ public List getPdpStatistics(@NonNull final PfDao dao, final String name, final Instant timeStamp) throws PfModelException { - List pdpStatistics = new ArrayList<>(); if (name != null && timeStamp != null) { return asPdpStatisticsList(dao.getByTimestamp(JpaPdpStatistics.class, new PfGeneratedIdKey(name, PfKey.NULL_KEY_VERSION), timeStamp)); @@ -130,7 +129,7 @@ public class PdpStatisticsProvider { public List createPdpStatistics(@NonNull final PfDao dao, @NonNull final List pdpStatisticsList) throws PfModelException { for (PdpStatistics pdpStatistics : pdpStatisticsList) { - JpaPdpStatistics jpaPdpStatistics = new JpaPdpStatistics(); + var jpaPdpStatistics = new JpaPdpStatistics(); jpaPdpStatistics.fromAuthorative(pdpStatistics); BeanValidationResult validationResult = jpaPdpStatistics.validate("pdp statistics"); if (!validationResult.isValid()) { @@ -145,7 +144,7 @@ public class PdpStatisticsProvider { List pdpStatistics = new ArrayList<>(pdpStatisticsList.size()); for (PdpStatistics pdpStatisticsItem : pdpStatisticsList) { - JpaPdpStatistics jpaPdpStatistics = + var jpaPdpStatistics = dao.get(JpaPdpStatistics.class, new PfGeneratedIdKey(pdpStatisticsItem.getPdpInstanceId(), PfKey.NULL_KEY_VERSION, pdpStatisticsItem.getGeneratedId())); pdpStatistics.add(jpaPdpStatistics.toAuthorative()); @@ -165,7 +164,7 @@ public class PdpStatisticsProvider { @NonNull final List pdpStatisticsList) throws PfModelException { for (PdpStatistics pdpStatistics : pdpStatisticsList) { - JpaPdpStatistics jpaPdpStatistics = new JpaPdpStatistics(); + var jpaPdpStatistics = new JpaPdpStatistics(); jpaPdpStatistics.fromAuthorative(pdpStatistics); BeanValidationResult validationResult = jpaPdpStatistics.validate("pdp statistics"); @@ -180,7 +179,7 @@ public class PdpStatisticsProvider { List pdpStatistics = new ArrayList<>(pdpStatisticsList.size()); for (PdpStatistics pdpStatisticsItem : pdpStatisticsList) { - JpaPdpStatistics jpaPdpStatistics = + var jpaPdpStatistics = dao.get(JpaPdpStatistics.class, new PfGeneratedIdKey(pdpStatisticsItem.getPdpInstanceId(), PfKey.NULL_KEY_VERSION, pdpStatisticsItem.getGeneratedId())); pdpStatistics.add(jpaPdpStatistics.toAuthorative()); diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/AbstractModelsProvider.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/AbstractModelsProvider.java index a0c5ce678..dc0a1f62e 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/AbstractModelsProvider.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/AbstractModelsProvider.java @@ -69,17 +69,17 @@ public abstract class AbstractModelsProvider implements Closeable { parameters.getPersistenceUnit()); if (pfDao != null) { - String errorMessage = "provider is already initialized"; + var errorMessage = "provider is already initialized"; throw new PfModelException(Response.Status.NOT_ACCEPTABLE, errorMessage); } // Parameters for the DAO - final DaoParameters daoParameters = new DaoParameters(); + final var daoParameters = new DaoParameters(); daoParameters.setPluginClass(DefaultPfDao.class.getName()); daoParameters.setPersistenceUnit(parameters.getPersistenceUnit()); // @formatter:off - Properties jdbcProperties = new Properties(); + var jdbcProperties = new Properties(); jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, parameters.getDatabaseDriver()); jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, parameters.getDatabaseUrl()); jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, parameters.getDatabaseUser()); 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 1839604aa..a90dc895c 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 @@ -146,7 +146,7 @@ public class DatabasePolicyModelsProviderImpl extends AbstractModelsProvider imp throws PfModelException { assertInitialized(); - ToscaConceptIdentifier policyTypeIdentifier = new ToscaConceptIdentifier(name, version); + var policyTypeIdentifier = new ToscaConceptIdentifier(name, version); assertPolicyTypeNotSupportedInPdpGroup(policyTypeIdentifier); return new AuthorativeToscaProvider().deletePolicyType(getPfDao(), name, version); @@ -197,7 +197,7 @@ public class DatabasePolicyModelsProviderImpl extends AbstractModelsProvider imp throws PfModelException { assertInitialized(); - ToscaConceptIdentifier policyIdentifier = new ToscaConceptIdentifier(name, version); + var policyIdentifier = new ToscaConceptIdentifier(name, version); assertPolicyNotDeployedInPdpGroup(policyIdentifier); return new AuthorativeToscaProvider().deletePolicy(getPfDao(), name, version); @@ -314,7 +314,7 @@ public class DatabasePolicyModelsProviderImpl extends AbstractModelsProvider imp */ private void assertInitialized() { if (getPfDao() == null) { - String errorMessage = "policy models provider is not initilaized"; + var errorMessage = "policy models provider is not initilaized"; throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage); } } 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 07617aad9..f47f4d464 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 @@ -274,7 +274,7 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider { * @return the ToscaServiceTemplate with the dummy response */ protected ToscaServiceTemplate getDummyResponse(final String fileName) { - StandardCoder standardCoder = new StandardCoder(); + var standardCoder = new StandardCoder(); ToscaServiceTemplate serviceTemplate; try { 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 a1102cb51..9e8ba0bbc 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 @@ -412,7 +412,7 @@ public class DatabasePolicyModelsProviderTest { List statisticsArrayList = makePdpStatisticsList(); - assertThat(databaseProvider.getPdpStatistics(null, null)).hasSize(0); + assertThat(databaseProvider.getPdpStatistics(null, null)).isEmpty(); assertThat(databaseProvider.createPdpStatistics(statisticsArrayList)).hasSize(1); assertThat(databaseProvider.updatePdpStatistics(statisticsArrayList)).hasSize(1); } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.java index 9033c8fa0..a24341458 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.java @@ -57,7 +57,7 @@ public class ToscaConceptIdentifier extends ToscaNameVersion * @return the validation result */ public ValidationResult validatePapRest() { - BeanValidationResult result = new BeanValidationResult("identifier", this); + var result = new BeanValidationResult("identifier", this); result.validateNotNull("name", getName()); result.validateNotNull("version", getVersion()); diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java index c43aadf0f..8171b7d78 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -243,7 +243,7 @@ public class AuthorativeToscaProvider { synchronized (providerLockObject) { LOGGER.debug("->getFilteredPolicyTypes: filter={}", filter); - SimpleToscaProvider simpleToscaProvider = new SimpleToscaProvider(); + var simpleToscaProvider = new SimpleToscaProvider(); final JpaToscaServiceTemplate dbServiceTemplate = simpleToscaProvider.getPolicyTypes(dao, null, null); @@ -255,7 +255,7 @@ public class AuthorativeToscaProvider { "policy types for filter " + filter.toString() + " do not exist"); } - JpaToscaServiceTemplate filteredServiceTemplate = new JpaToscaServiceTemplate(); + var filteredServiceTemplate = new JpaToscaServiceTemplate(); for (ToscaPolicyType policyType : filteredPolicyTypes) { JpaToscaServiceTemplate cascadedServiceTemplate = simpleToscaProvider @@ -430,7 +430,7 @@ public class AuthorativeToscaProvider { String version = ToscaTypedEntityFilter.LATEST_VERSION.equals(filter.getVersion()) ? null : filter.getVersion(); - SimpleToscaProvider simpleToscaProvider = new SimpleToscaProvider(); + var simpleToscaProvider = new SimpleToscaProvider(); final JpaToscaServiceTemplate dbServiceTemplate = simpleToscaProvider.getPolicies(dao, filter.getName(), version); @@ -443,7 +443,7 @@ public class AuthorativeToscaProvider { "policies for filter " + filter.toString() + " do not exist"); } - JpaToscaServiceTemplate filteredServiceTemplate = new JpaToscaServiceTemplate(); + var filteredServiceTemplate = new JpaToscaServiceTemplate(); for (ToscaPolicy policy : filteredPolicies) { JpaToscaServiceTemplate cascadedServiceTemplate = simpleToscaProvider diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignment.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignment.java index 76508dabe..3e0ec281b 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignment.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignment.java @@ -104,7 +104,7 @@ public class JpaToscaCapabilityAssignment extends JpaToscaWithTypeAndStringPrope @Override public ToscaCapabilityAssignment toAuthorative() { - ToscaCapabilityAssignment toscaCapabilityAssignment = new ToscaCapabilityAssignment(); + var toscaCapabilityAssignment = new ToscaCapabilityAssignment(); super.setToscaEntity(toscaCapabilityAssignment); super.toAuthorative(); diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogical.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogical.java index 73546f681..e8d16a705 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogical.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogical.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,7 +71,7 @@ public class JpaToscaConstraintLogical extends JpaToscaConstraint { @Override public ToscaConstraint toAuthorative() { - ToscaConstraint toscaConstraint = new ToscaConstraint(); + var toscaConstraint = new ToscaConstraint(); if (operation == null) { return null; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintValidValues.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintValidValues.java index 9941bc9fd..b5c2d10e5 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintValidValues.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintValidValues.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -68,7 +68,7 @@ public class JpaToscaConstraintValidValues extends JpaToscaConstraint { @Override public ToscaConstraint toAuthorative() { - ToscaConstraint toscaConstraint = new ToscaConstraint(); + var toscaConstraint = new ToscaConstraint(); toscaConstraint.setValidValues(validValues); diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataType.java index bcbf40086..c086c535a 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataType.java @@ -90,7 +90,7 @@ public class JpaToscaDataType extends JpaToscaWithToscaProperties @Override public ToscaDataType toAuthorative() { - ToscaDataType toscaDataType = new ToscaDataType(); + var toscaDataType = new ToscaDataType(); super.setToscaEntity(toscaDataType); super.toAuthorative(); diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java index f6cfc1258..bd1dfd4d5 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java @@ -126,7 +126,7 @@ public class JpaToscaNodeTemplate extends JpaToscaWithTypeAndStringProperties @Override public ToscaNodeType toAuthorative() { - ToscaNodeType toscaNodeType = new ToscaNodeType(); + var toscaNodeType = new ToscaNodeType(); super.setToscaEntity(toscaNodeType); super.toAuthorative(); diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaParameter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaParameter.java index 0348bb1d4..9b023dcba 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaParameter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaParameter.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix Foundation. - * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -116,7 +116,7 @@ public class JpaToscaParameter extends PfConcept implements PfAuthorative(); for (Map.Entry toscaInputEntry : toscaTopologyTemplate.getInputs().entrySet()) { - JpaToscaParameter jpaInput = new JpaToscaParameter(toscaInputEntry.getValue()); + var jpaInput = new JpaToscaParameter(toscaInputEntry.getValue()); jpaInput.setKey(new PfReferenceKey(getKey(), toscaInputEntry.getKey())); inputs.put(toscaInputEntry.getKey(), jpaInput); } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaProperties.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaProperties.java index 33e4e86b4..510287581 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaProperties.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaProperties.java @@ -107,7 +107,7 @@ public abstract class JpaToscaWithToscaProperties(); for (Entry toscaPropertyEntry : authorativeConcept.getProperties().entrySet()) { - JpaToscaProperty jpaProperty = new JpaToscaProperty(toscaPropertyEntry.getValue()); + var jpaProperty = new JpaToscaProperty(toscaPropertyEntry.getValue()); jpaProperty.setKey(new PfReferenceKey(getKey(), toscaPropertyEntry.getKey())); properties.put(toscaPropertyEntry.getKey(), jpaProperty); } @@ -116,7 +116,7 @@ public abstract class JpaToscaWithToscaProperties> ancestorList = ToscaUtils @@ -480,7 +480,7 @@ public class SimpleToscaProvider { new SimpleToscaServiceTemplateProvider().write(dao, serviceTemplate); dao.delete(policyType4Deletion); - JpaToscaServiceTemplate deletedServiceTemplate = new JpaToscaServiceTemplate(); + var deletedServiceTemplate = new JpaToscaServiceTemplate(); deletedServiceTemplate.setPolicyTypes(new JpaToscaPolicyTypes()); deletedServiceTemplate.getPolicyTypes().getConceptMap().put(policyTypeKey, policyType4Deletion); @@ -526,7 +526,7 @@ public class SimpleToscaProvider { public JpaToscaServiceTemplate getCascadedPolicies(final JpaToscaServiceTemplate dbServiceTemplate, final String name, final String version) throws PfModelException { - JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate(dbServiceTemplate); + var serviceTemplate = new JpaToscaServiceTemplate(dbServiceTemplate); serviceTemplate.setDataTypes(new JpaToscaDataTypes()); serviceTemplate.setPolicyTypes(new JpaToscaPolicyTypes()); @@ -537,7 +537,7 @@ public class SimpleToscaProvider { "policies for " + name + ":" + version + DO_NOT_EXIST); } - JpaToscaServiceTemplate returnServiceTemplate = new JpaToscaServiceTemplate(serviceTemplate); + var returnServiceTemplate = new JpaToscaServiceTemplate(serviceTemplate); returnServiceTemplate.getTopologyTemplate().setPolicies(new JpaToscaPolicies()); for (JpaToscaPolicy policy : serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().values()) { @@ -592,7 +592,7 @@ public class SimpleToscaProvider { } // Return the created policy types - JpaToscaPolicies returnPolicies = new JpaToscaPolicies(); + var returnPolicies = new JpaToscaPolicies(); returnPolicies.setKey(serviceTemplate.getTopologyTemplate().getPolicies().getKey()); for (PfConceptKey policyKey : serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().keySet()) { @@ -632,7 +632,7 @@ public class SimpleToscaProvider { new SimpleToscaServiceTemplateProvider().write(dao, serviceTemplate); dao.delete(policy4Deletion); - JpaToscaServiceTemplate deletedServiceTemplate = new JpaToscaServiceTemplate(); + var deletedServiceTemplate = new JpaToscaServiceTemplate(); deletedServiceTemplate.setTopologyTemplate(new JpaToscaTopologyTemplate()); deletedServiceTemplate.getTopologyTemplate().setPolicies(new JpaToscaPolicies()); deletedServiceTemplate.getTopologyTemplate().getPolicies().getConceptMap().put(policyKey, policy4Deletion); @@ -685,7 +685,7 @@ public class SimpleToscaProvider { } // Create a filter to get the latest version of the policy type - PfConceptFilter pfConceptFilter = PfConceptFilter.builder().version(PfConceptFilter.LATEST_VERSION).build(); + var pfConceptFilter = PfConceptFilter.builder().version(PfConceptFilter.LATEST_VERSION).build(); // FIlter the returned policy type list List policyTypeKeyList = new ArrayList<>(jpaPolicyTypeList); diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java index fe5299337..12e3a9d5a 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix Foundation. - * Modifications Copyright (C) 2020 AT&T + * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ public class ToscaServiceTemplateUtils { public static JpaToscaServiceTemplate addFragment(@NonNull final JpaToscaServiceTemplate originalTemplate, @NonNull final JpaToscaServiceTemplate fragmentTemplate) { - BeanValidationResult result = new BeanValidationResult("incoming fragment", fragmentTemplate); + var result = new BeanValidationResult("incoming fragment", fragmentTemplate); if (originalTemplate.compareToWithoutEntities(fragmentTemplate) != 0) { Validated.addResult(result, "service template", @@ -65,7 +65,7 @@ public class ToscaServiceTemplateUtils { "does not equal existing service template"); } - JpaToscaServiceTemplate compositeTemplate = new JpaToscaServiceTemplate(originalTemplate); + var compositeTemplate = new JpaToscaServiceTemplate(originalTemplate); compositeTemplate.setDataTypes( addFragmentEntitites(compositeTemplate.getDataTypes(), fragmentTemplate.getDataTypes(), result)); @@ -123,7 +123,7 @@ public class ToscaServiceTemplateUtils { return compositeContainer; } - BeanValidationResult result2 = new BeanValidationResult("incoming fragment", fragmentContainer); + var result2 = new BeanValidationResult("incoming fragment", fragmentContainer); for (Entry> fragmentEntry : fragmentContainer .getConceptMap().entrySet()) { diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java index 2fa2a557a..450b589c5 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java @@ -29,7 +29,6 @@ import javax.ws.rs.core.Response; import lombok.NonNull; import org.apache.commons.collections4.CollectionUtils; import org.onap.policy.common.parameters.BeanValidationResult; -import org.onap.policy.common.parameters.ObjectValidationResult; import org.onap.policy.common.parameters.ValidationStatus; import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.base.PfConceptContainer; @@ -259,7 +258,7 @@ public final class ToscaUtils { @NonNull final PfConceptContainer entityTypes, final String entityName, final String entityVersion) { - BeanValidationResult result = new BeanValidationResult("entity", entityName); + var result = new BeanValidationResult("entity", entityName); @SuppressWarnings("unchecked") Set> filteredEntitySet = -- 2.16.6