Use lombok in xacml-pdp 40/122640/2
authorJim Hahn <jrh3@att.com>
Wed, 14 Jul 2021 20:47:14 +0000 (16:47 -0400)
committerJim Hahn <jrh3@att.com>
Wed, 14 Jul 2021 21:25:45 +0000 (17:25 -0400)
Also:
- changed a few fields to private/protected.
- swwapped out gson for coder

Issue-ID: POLICY-3400
Change-Id: I9a4dba939b77078f78583ada00af182b1a7d95c5
Signed-off-by: Jim Hahn <jrh3@att.com>
25 files changed:
applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapPolicyFinderFactory.java
applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtils.java
applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java
applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchableProperty.java
applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeList.java
applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeMap.java
applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyRequest.java
applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java
applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchablePolicyRequest.java
applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPip.java
applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java
applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/OnapPolicyFinderFactoryTest.java
applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java
applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardPolicyRequest.java
applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/GuardTranslator.java
applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTranslator.java
applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationSubscriberRequest.java
main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpPapRegistration.java
main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java
main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterHandler.java
main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpStatisticsManager.java
main/src/main/java/org/onap/policy/pdpx/main/rest/serialization/XacmlExceptionMapper.java
main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpCommandLineArguments.java
main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java

index a4fc03f..0e2a532 100644 (file)
@@ -67,16 +67,6 @@ public class OnapPolicyFinderFactory extends PolicyFinderFactory {
 
     private Properties properties;
 
-    /**
-     * Empty private constructor. We do not want to create
-     * an instance of this without giving Properties object.
-     *
-     * @throws OnapPolicyFinderFactoryException Exception will be thrown
-     */
-    public OnapPolicyFinderFactory() throws OnapPolicyFinderFactoryException {
-        throw new OnapPolicyFinderFactoryException("Please use the constructor with Properties object.");
-    }
-
     /**
      * Constructor with properties passed. This will be preferred.
      *
index 860189f..596a3cc 100644 (file)
@@ -47,7 +47,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class XacmlPolicyUtils {
+public final class XacmlPolicyUtils {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(XacmlPolicyUtils.class);
 
index fe79e86..ca29c96 100644 (file)
@@ -69,8 +69,8 @@ public class MatchablePolicyType {
             );
     //@formatter:on
 
-    ToscaConceptIdentifier policyId;
-    Map<String, MatchableProperty> matchables = new HashMap<>();
+    private ToscaConceptIdentifier policyId;
+    private Map<String, MatchableProperty> matchables = new HashMap<>();
 
     public MatchablePolicyType(@NonNull ToscaPolicyType policyType, @NonNull MatchableCallback callback) {
         this.policyId = new ToscaConceptIdentifier(policyType.getName(), policyType.getVersion());
index 9b5de5c..6e9c455 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -30,7 +30,7 @@ import lombok.RequiredArgsConstructor;
 @RequiredArgsConstructor
 public class MatchableProperty {
     @NonNull
-    String property;
+    private String property;
     @NonNull
-    MatchablePropertyType<?> type;
+    private MatchablePropertyType<?> type;
 }
index 52f4ae1..0c42d35 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2020 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,7 +33,7 @@ import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionExcepti
 import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslatorUtils;
 
 public class MatchablePropertyTypeList extends MatchablePropertyTypeBase<List<MatchablePropertyType<?>>> {
-    MatchableProperty primitiveProperty;
+    private MatchableProperty primitiveProperty;
 
     /**
      * constructor.
index f6d8414..79b3452 100644 (file)
@@ -36,7 +36,7 @@ import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionExcepti
 import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslatorUtils;
 
 public class MatchablePropertyTypeMap extends MatchablePropertyTypeBase<Map<String, MatchablePropertyType<?>>> {
-    MatchableProperty primitiveProperty;
+    private MatchableProperty primitiveProperty;
 
     /**
      * constructor.
index 9618d5b..3e7c10a 100644 (file)
@@ -31,6 +31,7 @@ import java.util.Collection;
 import java.util.Map;
 import java.util.Map.Entry;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 import lombok.Setter;
 import lombok.ToString;
 import org.onap.policy.models.decisions.concepts.DecisionRequest;
@@ -38,6 +39,7 @@ import org.onap.policy.models.decisions.concepts.DecisionRequest;
 @Getter
 @Setter
 @ToString
+@NoArgsConstructor
 @XACMLRequest(ReturnPolicyIdList = true)
 public class StdCombinedPolicyRequest {
 
@@ -62,10 +64,6 @@ public class StdCombinedPolicyRequest {
     @XACMLResource(attributeId = "urn:org:onap:policy-type", includeInResults = true)
     private Collection<String> resourcePolicyType = new ArrayList<>();
 
-    public StdCombinedPolicyRequest() {
-        super();
-    }
-
     /**
      * Parses the DecisionRequest into a MonitoringRequest.
      *
index 5756071..5bf9151 100644 (file)
@@ -32,6 +32,7 @@ import com.att.research.xacml.std.annotations.RequestParser;
 import com.google.common.base.Strings;
 import java.util.Collection;
 import java.util.Map;
+import lombok.NoArgsConstructor;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.EffectType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
@@ -49,14 +50,11 @@ import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslatorUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@NoArgsConstructor
 public class StdCombinedPolicyResultsTranslator extends StdBaseTranslator {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(StdCombinedPolicyResultsTranslator.class);
 
-    public StdCombinedPolicyResultsTranslator() {
-        super();
-    }
-
     @Override
     public Object convertPolicy(ToscaPolicy toscaPolicy) throws ToscaPolicyConversionException {
         //
index c038f38..42e3d43 100644 (file)
@@ -43,6 +43,7 @@ import java.util.Collection;
 import java.util.Map;
 import java.util.Map.Entry;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 import lombok.Setter;
 import lombok.ToString;
 import org.onap.policy.models.decisions.concepts.DecisionRequest;
@@ -54,6 +55,7 @@ import org.slf4j.LoggerFactory;
 @Getter
 @Setter
 @ToString
+@NoArgsConstructor
 @XACMLRequest(ReturnPolicyIdList = true)
 public class StdMatchablePolicyRequest {
 
@@ -75,10 +77,6 @@ public class StdMatchablePolicyRequest {
 
     protected static DataTypeFactory dataTypeFactory        = null;
 
-    public StdMatchablePolicyRequest() {
-        super();
-    }
-
     protected static synchronized DataTypeFactory getDataTypeFactory() {
         try {
             if (dataTypeFactory != null) {
index 8d71276..cca2d21 100644 (file)
@@ -43,6 +43,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import lombok.NoArgsConstructor;
 import lombok.Setter;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
@@ -83,6 +84,7 @@ import org.slf4j.LoggerFactory;
  * @author pameladragosh
  *
  */
+@NoArgsConstructor
 public class StdMatchableTranslator  extends StdBaseTranslator implements MatchableCallback {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(StdMatchableTranslator.class);
@@ -96,10 +98,6 @@ public class StdMatchableTranslator  extends StdBaseTranslator implements Matcha
     @Setter
     private Path pathForData;
 
-    public StdMatchableTranslator() {
-        super();
-    }
-
     @Override
     public Request convertRequest(DecisionRequest request) throws ToscaPolicyConversionException {
         LOGGER.info("Converting Request {}", request);
index e8839ec..d57da30 100644 (file)
@@ -42,11 +42,13 @@ import java.util.Iterator;
 import java.util.Properties;
 import javax.persistence.EntityManager;
 import javax.persistence.Persistence;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.onap.policy.pdp.xacml.application.common.ToscaDictionary;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
+@NoArgsConstructor(access = AccessLevel.PROTECTED)
 public abstract class StdOnapPip extends StdConfigurableEngine {
     protected static Logger logger = LoggerFactory.getLogger(StdOnapPip.class);
 
@@ -70,10 +72,6 @@ public abstract class StdOnapPip extends StdConfigurableEngine {
     protected String issuer;
     protected boolean shutdown = false;
 
-    protected StdOnapPip() {
-        super();
-    }
-
     @Override
     public Collection<PIPRequest> attributesProvided() {
         return Collections.emptyList();
index f29c4e7..4096875 100644 (file)
@@ -39,7 +39,9 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import lombok.AccessLevel;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 import org.apache.commons.lang3.tuple.Pair;
 import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
 import org.onap.policy.models.decisions.concepts.DecisionRequest;
@@ -54,6 +56,7 @@ import org.onap.policy.pdp.xacml.application.common.XacmlPolicyUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@NoArgsConstructor(access = AccessLevel.PROTECTED)
 public abstract class StdXacmlApplicationServiceProvider implements XacmlApplicationServiceProvider {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(StdXacmlApplicationServiceProvider.class);
@@ -69,10 +72,6 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
     private PDPEngine pdpEngine = null;
     private Map<ToscaPolicy, Path> mapLoadedPolicies = new HashMap<>();
 
-    protected StdXacmlApplicationServiceProvider() {
-        super();
-    }
-
     @Override
     public String applicationName() {
         return applicationName;
index b5b8f7b..5df2552 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2019-2020 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.
@@ -23,7 +23,6 @@
 package org.onap.policy.pdp.xacml.application.common;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 
 import java.io.FileInputStream;
 import java.util.Properties;
@@ -31,13 +30,6 @@ import org.junit.Test;
 
 public class OnapPolicyFinderFactoryTest {
 
-    @Test
-    public void testNoUseConstructor() throws Exception {
-        assertThatExceptionOfType(OnapPolicyFinderFactoryException.class).isThrownBy(() -> {
-            new OnapPolicyFinderFactory();
-        }).withMessageContaining("Please use the constructor with Properties object.");
-    }
-
     @Test
     public void testFinder() throws Exception {
         //
index 90f56a9..162b062 100644 (file)
@@ -34,6 +34,7 @@ import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+import lombok.NoArgsConstructor;
 import org.apache.commons.io.IOUtils;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardYamlCoder;
@@ -46,14 +47,11 @@ import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@NoArgsConstructor
 public class CoordinationGuardTranslator implements ToscaPolicyTranslator {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(CoordinationGuardTranslator.class);
 
-    public CoordinationGuardTranslator() {
-        super();
-    }
-
     @Override
     public Object convertPolicy(ToscaPolicy toscaPolicy) throws ToscaPolicyConversionException {
         LOGGER.debug("Using CoordinationGuardTranslator.convertPolicy");
index 8a77449..58fe00b 100644 (file)
@@ -33,6 +33,7 @@ import java.time.OffsetTime;
 import java.time.ZoneOffset;
 import java.util.Map;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 import lombok.Setter;
 import lombok.ToString;
 import org.onap.policy.models.decisions.concepts.DecisionRequest;
@@ -41,6 +42,7 @@ import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionExcepti
 @Getter
 @Setter
 @ToString
+@NoArgsConstructor
 @XACMLRequest(ReturnPolicyIdList = true)
 public class GuardPolicyRequest {
     private static final String STR_GUARD = "guard";
@@ -109,10 +111,6 @@ public class GuardPolicyRequest {
 
     public static final String PREFIX_RESOURCE_ATTRIBUTE_ID = "urn:org:onap:guard:target:";
 
-    public GuardPolicyRequest() {
-        super();
-    }
-
     /**
      * Parses the DecisionRequest into a StdMetadataPolicyRequest.
      *
index df5fe43..3aae5fc 100644 (file)
@@ -39,6 +39,7 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType;
@@ -67,6 +68,7 @@ import org.onap.policy.pdp.xacml.application.common.operationshistory.CountRecen
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@NoArgsConstructor
 public class GuardTranslator implements ToscaPolicyTranslator {
     private static final Logger LOGGER = LoggerFactory.getLogger(GuardTranslator.class);
 
@@ -118,9 +120,6 @@ public class GuardTranslator implements ToscaPolicyTranslator {
     //
     private static final String VARIABLE_TIMEINRANGE = "timeInRange";
 
-    public GuardTranslator() {
-        super();
-    }
 
     /**
      * Convert the policy.
index 06e324d..3caf28f 100644 (file)
@@ -31,6 +31,7 @@ import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.util.Base64;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 import org.onap.policy.common.parameters.annotations.NotBlank;
 import org.onap.policy.common.parameters.annotations.NotNull;
 import org.onap.policy.models.decisions.concepts.DecisionRequest;
@@ -48,14 +49,11 @@ import org.slf4j.LoggerFactory;
  * @author Chenfei Gao (cgao@research.att.com)
  *
  */
+@NoArgsConstructor
 public class NativePdpApplicationTranslator implements ToscaPolicyTranslator {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(NativePdpApplicationTranslator.class);
 
-    public NativePdpApplicationTranslator() {
-        super();
-    }
-
     @Override
     public Object convertPolicy(ToscaPolicy toscaPolicy) throws ToscaPolicyConversionException {
         //
index 5eda767..6d86bdb 100644 (file)
@@ -46,7 +46,7 @@ import org.onap.policy.pdp.xacml.application.common.std.StdMatchablePolicyReques
 public class OptimizationSubscriberRequest extends StdMatchablePolicyRequest {
 
     @XACMLSubject(attributeId = "urn:org:onap:optimization:subscriber:name", includeInResults = true)
-    List<String> subscriberRoles;
+    private List<String> subscriberRoles;
 
     /**
      * Create an instance of xacml request.
index a848f52..d477ed0 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * 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.
 
 package org.onap.policy.pdpx.main.comm;
 
+import lombok.AllArgsConstructor;
 import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
 import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClientException;
 import org.onap.policy.models.pdp.concepts.PdpStatus;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@AllArgsConstructor
 public class XacmlPdpPapRegistration {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(XacmlPdpPapRegistration.class);
     private final TopicSinkClient client;
 
-    /**
-     * Constructs the object.
-     * @param client name of the TopickSinkClient
-     */
-    public XacmlPdpPapRegistration(TopicSinkClient client) {
-        this.client = client;
-    }
-
     /**
      * Sends PDP register and unregister message to the PAP.
      * @param status of the PDP
index 39af6fd..da6fdb2 100644 (file)
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.stream.Collectors;
+import lombok.AllArgsConstructor;
 import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
 import org.onap.policy.models.pdp.concepts.PdpStatus;
 import org.onap.policy.models.pdp.concepts.PdpUpdate;
@@ -39,6 +40,7 @@ import org.onap.policy.pdpx.main.rest.XacmlPdpStatisticsManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@AllArgsConstructor
 public class XacmlPdpUpdatePublisher {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(XacmlPdpUpdatePublisher.class);
@@ -47,18 +49,6 @@ public class XacmlPdpUpdatePublisher {
     private final XacmlState state;
     private final XacmlPdpApplicationManager appManager;
 
-    /**
-     * Constructs the object.
-     * @param client messages are published to this client
-     * @param state tracks the state of this PDP
-     * @param appManager application manager
-     */
-    public XacmlPdpUpdatePublisher(TopicSinkClient client, XacmlState state, XacmlPdpApplicationManager appManager) {
-        this.client = client;
-        this.state = state;
-        this.appManager = appManager;
-    }
-
     /**
      * Handle the PDP Update message.
      *
index aac0575..539716b 100644 (file)
 
 package org.onap.policy.pdpx.main.parameters;
 
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import java.io.FileReader;
+import java.io.File;
 import org.onap.policy.common.parameters.ValidationResult;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.pdpx.main.PolicyXacmlPdpException;
 import org.onap.policy.pdpx.main.startstop.XacmlPdpCommandLineArguments;
 import org.slf4j.Logger;
@@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory;
  */
 public class XacmlPdpParameterHandler {
     private static final Logger LOGGER = LoggerFactory.getLogger(XacmlPdpParameterHandler.class);
-    private static final Gson gson = new GsonBuilder().create();
+    private static final Coder CODER = new StandardCoder();
 
     /**
      * Read the parameters from the parameter file.
@@ -51,8 +51,8 @@ public class XacmlPdpParameterHandler {
         XacmlPdpParameterGroup xacmlPdpParameterGroup = null;
 
         try {
-            // Read the parameters from JSON using Gson
-            xacmlPdpParameterGroup = gson.fromJson(new FileReader(arguments.getFullConfigurationFilePath()),
+            // Read the parameters from JSON
+            xacmlPdpParameterGroup = CODER.decode(new File(arguments.getFullConfigurationFilePath()),
                     XacmlPdpParameterGroup.class);
         } catch (final Exception e) {
             final String errorMessage = "error reading parameters from \"" + arguments.getConfigurationFilePath()
index a696ea4..63d9f51 100644 (file)
@@ -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.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ import lombok.Setter;
  * Class to hold statistical data for xacmlPdp component.
  *
  */
+@Getter
 public class XacmlPdpStatisticsManager {
     @Getter
     @Setter
@@ -34,7 +35,7 @@ public class XacmlPdpStatisticsManager {
 
     private long totalPolicyTypesCount;
     private long totalPoliciesCount;
-    private long errorsCount;
+    private long errorCount;
     private long permitDecisionsCount;
     private long denyDecisionsCount;
     private long indeterminantDecisionsCount;
@@ -70,7 +71,7 @@ public class XacmlPdpStatisticsManager {
      * @return the errorDecisionsCount
      */
     public long updateErrorCount() {
-        return ++errorsCount;
+        return ++errorCount;
     }
 
     /**
@@ -109,76 +110,13 @@ public class XacmlPdpStatisticsManager {
         return ++notApplicableDecisionsCount;
     }
 
-    /**
-     * Returns the current value of totalPolicyTypesCount.
-
-     * @return the totalPolicyTypesCount
-     */
-    public long getTotalPolicyTypesCount() {
-        return totalPolicyTypesCount;
-    }
-
-    /**
-     * Returns the current value of totalPoliciesCount.
-
-     * @return the totalPoliciesCount
-     */
-    public long getTotalPoliciesCount() {
-        return totalPoliciesCount;
-    }
-
-    /**
-     * Returns the current value of errorDecisionsCount.
-
-     * @return the permitDecisionsCount
-     */
-    public long getErrorCount() {
-        return errorsCount;
-    }
-
-    /**
-     * Returns the current value of permitDecisionsCount.
-
-     * @return the permitDecisionsCount
-     */
-    public long getPermitDecisionsCount() {
-        return permitDecisionsCount;
-    }
-
-    /**
-     * Returns the current value of denyDecisionsCount.
-
-     * @return the denyDecisionsCount
-     */
-    public long getDenyDecisionsCount() {
-        return denyDecisionsCount;
-    }
-
-    /**
-     * Returns the current value of indeterminantDecisionsCount.
-
-     * @return the indeterminantDecisionsCount
-     */
-    public long getIndeterminantDecisionsCount() {
-        return indeterminantDecisionsCount;
-    }
-
-    /**
-     * Returns the current value of notApplicableDecisionsCount.
-
-     * @return the notApplicableDecisionsCount
-     */
-    public long getNotApplicableDecisionsCount() {
-        return notApplicableDecisionsCount;
-    }
-
     /**
      * Reset all the statistics counts to 0.
      */
     public void resetAllStatistics() {
         totalPolicyTypesCount = 0L;
         totalPoliciesCount = 0L;
-        errorsCount = 0L;
+        errorCount = 0L;
         permitDecisionsCount = 0L;
         denyDecisionsCount = 0L;
         indeterminantDecisionsCount = 0L;
index 4112e64..a2a78a8 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -36,9 +36,9 @@ public abstract class XacmlExceptionMapper implements ExceptionMapper<IOExceptio
     private static final Logger LOGGER = LoggerFactory.getLogger(XacmlExceptionMapper.class);
 
     @Getter
-    String invalidRequest;
+    protected String invalidRequest;
     @Getter
-    String invalidResponse;
+    protected String invalidResponse;
 
     public abstract boolean isInvalidRequest(String message);
 
index 1267d85..24545d3 100644 (file)
@@ -24,6 +24,8 @@ import java.io.File;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.Arrays;
+import lombok.Getter;
+import lombok.Setter;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.DefaultParser;
 import org.apache.commons.cli.HelpFormatter;
@@ -46,7 +48,11 @@ public class XacmlPdpCommandLineArguments {
     private final Options options;
 
     // The command line options
+    @Getter
+    @Setter
     private String configurationFilePath = null;
+    @Getter
+    @Setter
     private String propertyFilePath = null;
 
     /**
@@ -189,15 +195,6 @@ public class XacmlPdpCommandLineArguments {
         return stringWriter.toString();
     }
 
-    /**
-     * Gets the configuration file path.
-     *
-     * @return the configuration file path
-     */
-    public String getConfigurationFilePath() {
-        return configurationFilePath;
-    }
-
     /**
      * Gets the full expanded configuration file path.
      *
@@ -207,16 +204,6 @@ public class XacmlPdpCommandLineArguments {
         return ResourceUtils.getFilePath4Resource(getConfigurationFilePath());
     }
 
-    /**
-     * Sets the configuration file path.
-     *
-     * @param configurationFilePath the configuration file path
-     */
-    public void setConfigurationFilePath(final String configurationFilePath) {
-        this.configurationFilePath = configurationFilePath;
-
-    }
-
     /**
      * Check set configuration file path.
      *
@@ -226,15 +213,6 @@ public class XacmlPdpCommandLineArguments {
         return configurationFilePath != null && !configurationFilePath.isEmpty();
     }
 
-    /**
-     * Gets the property file path.
-     *
-     * @return the property file path
-     */
-    public String getPropertyFilePath() {
-        return propertyFilePath;
-    }
-
     /**
      * Gets the full expanded property file path.
      *
@@ -244,16 +222,6 @@ public class XacmlPdpCommandLineArguments {
         return ResourceUtils.getFilePath4Resource(getPropertyFilePath());
     }
 
-    /**
-     * Sets the property file path.
-     *
-     * @param propertyFilePath the property file path
-     */
-    public void setPropertyFilePath(final String propertyFilePath) {
-        this.propertyFilePath = propertyFilePath;
-
-    }
-
     /**
      * Validate readable file.
      *
index 570b431..1e86fee 100644 (file)
@@ -67,9 +67,9 @@ public class TestXacmlPdpParameterHandler {
         badArguments.parse(badArgumentString);
 
         assertThatThrownBy(() -> new XacmlPdpParameterHandler().getParameters(badArguments))
-                .hasMessage("error reading parameters from \"parameters/BadParameters.json\"\n"
-                        + "(JsonSyntaxException):java.lang.IllegalStateException: "
-                        "Expected a string but was BEGIN_ARRAY at line 2 column 14 path $.name");
+                .hasMessageContaining("error reading parameters from", "parameters/BadParameters.json",
+                        "JsonSyntaxException", "java.lang.IllegalStateException",
+                        "Expected a string but was BEGIN_ARRAY at line 2 column 14 path $.name");
 
     }
 
@@ -81,9 +81,9 @@ public class TestXacmlPdpParameterHandler {
         invalidArguments.parse(invalidArgumentString);
 
         assertThatThrownBy(() -> new XacmlPdpParameterHandler().getParameters(invalidArguments))
-                .hasMessage("error reading parameters from \"parameters/InvalidParameters.json\"\n"
-                        + "(JsonSyntaxException):java.lang.IllegalStateException: "
-                        "Expected a string but was BEGIN_ARRAY at line 2 column 14 path $.name");
+                .hasMessageContaining("error reading parameters from", "parameters/InvalidParameters.json",
+                        "JsonSyntaxException", "java.lang.IllegalStateException",
+                        "Expected a string but was BEGIN_ARRAY at line 2 column 14 path $.name");
     }
 
     @Test