aboutsummaryrefslogtreecommitdiffstats
path: root/feature-state-management
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-08-05 14:53:19 -0400
committerJim Hahn <jrh3@att.com>2021-08-05 15:25:14 -0400
commitda1b7d9f04453e94fb77ebe4213f456a0be63fc2 (patch)
treee59daec0050c7ce88c07f1d7f97168aa849128a7 /feature-state-management
parent1744dac574fb771301027be74c9257eb070125f7 (diff)
Use lombok in drools-pdp #2
Updated feature-session-persistence thru drools-domains. Issue-ID: POLICY-3397 Change-Id: I0b1c6da8b2301c00dd792675e8cf1f49888edb9f Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-state-management')
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DbAudit.java18
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPdpIntegrityMonitor.java31
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java30
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementProperties.java14
-rw-r--r--feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java4
5 files changed, 24 insertions, 73 deletions
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DbAudit.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DbAudit.java
index 2dc751b1..0c750065 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DbAudit.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DbAudit.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* feature-state-management
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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,8 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import java.util.UUID;
+import lombok.Getter;
+import lombok.Setter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,7 +44,9 @@ public class DbAudit extends DroolsPdpIntegrityMonitor.AuditBase {
// invoked -- doing this avoids the need to create the table in advance.
private static boolean createTableNeeded = true;
- private static boolean isJunit = false;
+ @Getter
+ @Setter
+ private static boolean junit = false;
/** Constructor - set the name to 'Database'. */
private DbAudit() {
@@ -53,14 +57,6 @@ public class DbAudit extends DroolsPdpIntegrityMonitor.AuditBase {
DbAudit.createTableNeeded = isNeeded;
}
- public static synchronized void setIsJunit(boolean isJUnit) {
- DbAudit.isJunit = isJUnit;
- }
-
- public static boolean isJunit() {
- return DbAudit.isJunit;
- }
-
/**
* Get the instance.
*
@@ -77,7 +73,7 @@ public class DbAudit extends DroolsPdpIntegrityMonitor.AuditBase {
@Override
public void invoke(Properties properties) {
logger.debug("Running 'DbAudit.invoke'");
- boolean doCreate = createTableNeeded && !isJunit;
+ boolean doCreate = createTableNeeded && !isJunit();
if (!isActive()) {
logger.info("DbAudit.invoke: exiting because isActive = false");
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPdpIntegrityMonitor.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPdpIntegrityMonitor.java
index 09dd275e..da94302f 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPdpIntegrityMonitor.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPdpIntegrityMonitor.java
@@ -23,6 +23,8 @@ package org.onap.policy.drools.statemanagement;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.common.capabilities.Startable;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
@@ -305,11 +307,13 @@ public class DroolsPdpIntegrityMonitor extends IntegrityMonitor {
/**
* This is the base class for audits invoked in 'subsystemTest'.
*/
+ @Getter
public abstract static class AuditBase {
// name of the audit
protected String name;
// non-null indicates the error response
+ @Setter
protected String response;
/**
@@ -323,33 +327,6 @@ public class DroolsPdpIntegrityMonitor extends IntegrityMonitor {
}
/**
- * Get the name.
- *
- * @return the name of this audit
- */
- public String getName() {
- return name;
- }
-
- /**
- * Get the response.
- *
- * @return the response String (non-null indicates the error message)
- */
- public String getResponse() {
- return response;
- }
-
- /**
- * Set the response string to the specified value.
- *
- * @param value the new value of the response string (null = no errors)
- */
- public void setResponse(String value) {
- response = value;
- }
-
- /**
* Abstract method to invoke the audit.
*
* @param persistenceProperties Used for DB access
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
index 438b6ec8..29576c4d 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* feature-state-management
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -37,6 +37,8 @@ import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
import org.onap.policy.common.im.IntegrityMonitorException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,6 +54,7 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase {
private static final Logger logger = LoggerFactory.getLogger(RepositoryAudit.class);
// single global instance of this audit object
+ @Getter
private static RepositoryAudit instance = new RepositoryAudit();
// Regex pattern used to find additional repos in the form "repository(number).id.url"
@@ -65,15 +68,6 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase {
}
/**
- * Get the integrity monitor instance.
- *
- * @return the single 'RepositoryAudit' instance
- */
- public static DroolsPdpIntegrityMonitor.AuditBase getInstance() {
- return instance;
- }
-
- /**
* First, get the names of each property from StateManagementProperties. For each property name, check if it is of
* the form "repository(number).audit.id" If so, we extract the number and determine if there exists another
* property in the form "repository(number).audit.url" with the same "number". Only the
@@ -560,6 +554,7 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase {
/**
* An instance of this class exists for each artifact that we are trying to download.
*/
+ @AllArgsConstructor
static class Artifact {
String groupId;
String artifactId;
@@ -567,21 +562,6 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase {
String type;
/**
- * Constructor - populate the 'Artifact' instance.
- *
- * @param groupId groupId of artifact
- * @param artifactId artifactId of artifact
- * @param version version of artifact
- * @param type type of the artifact (e.g. "jar")
- */
- Artifact(String groupId, String artifactId, String version, String type) {
- this.groupId = groupId;
- this.artifactId = artifactId;
- this.version = version;
- this.type = type;
- }
-
- /**
* Constructor - populate an 'Artifact' instance.
*
* @param artifact a string of the form: {@code"<groupId>/<artifactId>/<version>[/<type>]"}
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementProperties.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementProperties.java
index 20494b0f..1582ace0 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementProperties.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementProperties.java
@@ -21,12 +21,16 @@
package org.onap.policy.drools.statemanagement;
import java.util.Properties;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class StateManagementProperties {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class StateManagementProperties {
// get an instance of logger
private static final Logger logger = LoggerFactory.getLogger(StateManagementProperties.class);
@@ -62,11 +66,9 @@ public class StateManagementProperties {
public static final String WRITE_FPC_INTERVAL = "write_fpc_interval";
public static final String DEPENDENCY_GROUPS = "dependency_groups";
+ @Getter
private static Properties properties = null;
- private StateManagementProperties() {
- }
-
/**
* Initialize the parameter values from the feature-state-management.properties file values.
*
@@ -88,8 +90,4 @@ public class StateManagementProperties {
public static String getProperty(String key) {
return properties.getProperty(key);
}
-
- public static Properties getProperties() {
- return properties;
- }
}
diff --git a/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java b/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java
index 8d47e1d6..578b6222 100644
--- a/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java
+++ b/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-persistence
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -110,7 +110,7 @@ public class StateManagementTest {
String configDir = "src/test/resources";
- DbAudit.setIsJunit(true);
+ DbAudit.setJunit(true);
Properties fsmProperties = new Properties();
fsmProperties.load(new FileInputStream(new File(