diff options
author | Jim Hahn <jrh3@att.com> | 2021-08-05 14:53:19 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-08-05 15:25:14 -0400 |
commit | da1b7d9f04453e94fb77ebe4213f456a0be63fc2 (patch) | |
tree | e59daec0050c7ce88c07f1d7f97168aa849128a7 | |
parent | 1744dac574fb771301027be74c9257eb070125f7 (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>
26 files changed, 141 insertions, 335 deletions
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsPersistenceProperties.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsPersistenceProperties.java index 93440dad..ab85864f 100644 --- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsPersistenceProperties.java +++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsPersistenceProperties.java @@ -20,9 +20,12 @@ package org.onap.policy.drools.persistence; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.eclipse.persistence.config.PersistenceUnitProperties; -public class DroolsPersistenceProperties { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class DroolsPersistenceProperties { /* * feature-session-persistence.properties parameter key values */ @@ -32,8 +35,4 @@ public class DroolsPersistenceProperties { public static final String DB_PWD = PersistenceUnitProperties.JDBC_PASSWORD; public static final String DB_SESSIONINFO_TIMEOUT = "persistence.sessioninfo.timeout"; public static final String JTA_OBJECTSTORE_DIR = "persistence.objectstore.dir"; - - private DroolsPersistenceProperties() { - super(); - } } diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java index ec9e5b76..9ac68567 100644 --- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java +++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionEntity.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * feature-session-persistence * ================================================================================ - * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018, 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. @@ -29,14 +29,23 @@ import javax.persistence.PrePersist; import javax.persistence.PreUpdate; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; @Entity +@Getter +@Setter +@EqualsAndHashCode(onlyExplicitlyIncluded = true) +@NoArgsConstructor public class DroolsSessionEntity implements Serializable, DroolsSession { private static final long serialVersionUID = -5495057038819948709L; @Id @Column(name = "sessionName", nullable = false) + @EqualsAndHashCode.Include private String sessionName = "-1"; @Column(name = "sessionId", nullable = false) @@ -50,9 +59,6 @@ public class DroolsSessionEntity implements Serializable, DroolsSession { @Column(name = "updatedDate", nullable = false) private Date updatedDate; - public DroolsSessionEntity() { - } - public DroolsSessionEntity(String sessionName, long sessionId) { this.sessionName = sessionName; this.sessionId = sessionId; @@ -70,64 +76,6 @@ public class DroolsSessionEntity implements Serializable, DroolsSession { } @Override - public String getSessionName() { - return sessionName; - } - - @Override - public void setSessionName(String sessionName) { - this.sessionName = sessionName; - } - - @Override - public long getSessionId() { - return sessionId; - } - - @Override - public void setSessionId(long sessionId) { - this.sessionId = sessionId; - } - - @Override - public Date getCreatedDate() { - return createdDate; - } - - @Override - public void setCreatedDate(Date createdDate) { - this.createdDate = createdDate; - } - - @Override - public Date getUpdatedDate() { - return updatedDate; - } - - @Override - public void setUpdatedDate(Date updatedDate) { - this.updatedDate = updatedDate; - } - - @Override - public boolean equals(Object other) { - if (other instanceof DroolsSession) { - DroolsSession session = (DroolsSession) other; - return this.getSessionName().equals(session.getSessionName()); - } else { - return false; - } - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + getSessionName().hashCode(); - return result; - } - - @Override public String toString() { return "{name=" + getSessionName() + ", id=" + getSessionId() + "}"; } diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/EntityMgrTrans.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/EntityMgrTrans.java index 988cd9c2..7103c47c 100644 --- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/EntityMgrTrans.java +++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/EntityMgrTrans.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * feature-session-persistence * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018, 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. @@ -28,6 +28,9 @@ import javax.transaction.RollbackException; import javax.transaction.Status; import javax.transaction.SystemException; import javax.transaction.UserTransaction; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; import org.onap.policy.common.utils.jpa.EntityMgrCloser; /** @@ -40,6 +43,8 @@ public class EntityMgrTrans extends EntityMgrCloser { /** * Transaction to be rolled back. */ + @Getter(AccessLevel.PROTECTED) + @Setter(AccessLevel.PROTECTED) private static UserTransaction userTrans = com.arjuna.ats.jta.UserTransaction.userTransaction(); /** @@ -71,24 +76,6 @@ public class EntityMgrTrans extends EntityMgrCloser { } /** - * Gets the user transaction. For use by junit tests. - * - * @return the user transaction - */ - protected static UserTransaction getUserTrans() { - return userTrans; - } - - /** - * Sets the user transaction. For use by junit tests. - * - * @param userTrans the new user transaction - */ - protected static void setUserTrans(UserTransaction userTrans) { - EntityMgrTrans.userTrans = userTrans; - } - - /** * Commits the transaction. */ public void commit() { @@ -146,7 +133,7 @@ public class EntityMgrTrans extends EntityMgrCloser { /** * Constructor. - * + * * @param ex exception to be wrapped */ public EntityMgrException(Exception ex) { diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java index d682e563..8fcbc795 100644 --- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java +++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnector.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * feature-session-persistence * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018, 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. @@ -22,19 +22,17 @@ package org.onap.policy.drools.persistence; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; +import lombok.AllArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@AllArgsConstructor public class JpaDroolsSessionConnector implements DroolsSessionConnector { private static Logger logger = LoggerFactory.getLogger(JpaDroolsSessionConnector.class); private final EntityManagerFactory emf; - public JpaDroolsSessionConnector(EntityManagerFactory emf) { - this.emf = emf; - } - @Override public DroolsSession get(String sessName) { diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java index 3c3e5008..a929c712 100644 --- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java +++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java @@ -151,7 +151,7 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine @Override public PolicySession.ThreadModel selectThreadModel(PolicySession session) { - var policyContainer = session.getPolicyContainer(); + var policyContainer = session.getContainer(); if (isPersistenceEnabled(policyContainer, session.getName())) { return new PersistentThreadModel(session, getProperties(policyContainer)); } @@ -165,7 +165,7 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine public void disposeKieSession(PolicySession policySession) { ContainerAdjunct contAdj = - (ContainerAdjunct) policySession.getPolicyContainer().getAdjunct(this); + (ContainerAdjunct) policySession.getContainer().getAdjunct(this); if (contAdj != null) { contAdj.disposeKieSession(policySession.getName()); } @@ -178,7 +178,7 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine public void destroyKieSession(PolicySession policySession) { ContainerAdjunct contAdj = - (ContainerAdjunct) policySession.getPolicyContainer().getAdjunct(this); + (ContainerAdjunct) policySession.getContainer().getAdjunct(this); if (contAdj != null) { contAdj.destroyKieSession(policySession.getName()); } diff --git a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/DroolsSessionEntityTest.java b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/DroolsSessionEntityTest.java index 2cc7d33a..bd979162 100644 --- a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/DroolsSessionEntityTest.java +++ b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/DroolsSessionEntityTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * feature-session-persistence * ================================================================================ - * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018, 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. @@ -173,20 +173,7 @@ public class DroolsSessionEntityTest { * @param sessid session id * @return a new session Entity */ - @SuppressWarnings("serial") private DroolsSessionEntity makeEnt2(String sessnm, long sessid) { - - return new DroolsSessionEntity() { - - @Override - public String getSessionName() { - return sessnm; - } - - @Override - public long getSessionId() { - return sessid; - } - }; + return new DroolsSessionEntity(sessnm, sessid); } } diff --git a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/PersistenceFeatureTest.java b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/PersistenceFeatureTest.java index ec261982..4450b8c8 100644 --- a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/PersistenceFeatureTest.java +++ b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/PersistenceFeatureTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * feature-session-persistence * ================================================================================ - * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018, 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. @@ -188,7 +188,7 @@ public class PersistenceFeatureTest { KieContainer kiecont = mock(KieContainer.class); when(polcont.getKieContainer()).thenReturn(kiecont); - when(polsess.getPolicyContainer()).thenReturn(polcont); + when(polsess.getContainer()).thenReturn(polcont); when(kiecont.getKieBase(anyString())).thenReturn(kiebase); } @@ -1167,7 +1167,7 @@ public class PersistenceFeatureTest { when(sess.getSessionId()).thenReturn(sessid); - when(polsess.getPolicyContainer()).thenReturn(polcont); + when(polsess.getContainer()).thenReturn(polcont); when(polsess.getName()).thenReturn(sessnm); if (loadOk) { 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( diff --git a/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransactionConstants.java b/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransactionConstants.java index 9b5ad251..a02cf498 100644 --- a/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransactionConstants.java +++ b/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransactionConstants.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * feature-test-transaction * ================================================================================ - * 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. @@ -20,9 +20,12 @@ package org.onap.policy.drools.testtransaction; +import lombok.AccessLevel; import lombok.Getter; +import lombok.NoArgsConstructor; -public class TestTransactionConstants { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class TestTransactionConstants { public static final String TT_FPC = "TT.FPC"; public static final String TT_COUNTER = "$ttc"; @@ -31,8 +34,4 @@ public class TestTransactionConstants { @Getter private static final TestTransaction manager = new TtImpl(); - - private TestTransactionConstants() { - // do nothing - } } diff --git a/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TtControllerTask.java b/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TtControllerTask.java index baecdfd9..bfd94df6 100644 --- a/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TtControllerTask.java +++ b/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TtControllerTask.java @@ -23,6 +23,7 @@ package org.onap.policy.drools.testtransaction; import java.util.EventObject; import java.util.HashMap; import java.util.List; +import lombok.Getter; import org.onap.policy.drools.controller.DroolsController; import org.onap.policy.drools.system.PolicyController; import org.slf4j.Logger; @@ -32,6 +33,7 @@ import org.slf4j.LoggerFactory; * TtControllerTask implements the Runnabale interface Carries out the injection of an event into a * drools session and subsequent query of a counter to ensure that forward progress is occuring. */ +@Getter public class TtControllerTask implements Runnable { // get an instance of logger @@ -53,14 +55,6 @@ public class TtControllerTask implements Runnable { this.thread.start(); } - public PolicyController getController() { - return this.controller; - } - - public synchronized boolean isAlive() { - return this.alive; - } - /** * Stops the task. */ @@ -75,10 +69,6 @@ public class TtControllerTask implements Runnable { } } - public Thread getThread() { - return this.thread; - } - @Override public void run() { try { diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/DroolsExecutor.java b/policy-core/src/main/java/org/onap/policy/drools/core/DroolsExecutor.java index 538970d6..d996d5a3 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/DroolsExecutor.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/DroolsExecutor.java @@ -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. @@ -21,24 +21,17 @@ package org.onap.policy.drools.core; import java.util.concurrent.Executor; +import lombok.AllArgsConstructor; import org.drools.core.WorkingMemory; /** * An executor that executes its tasks by inserting {@link DroolsRunnable} objects into * the working memory of a running session. */ +@AllArgsConstructor public class DroolsExecutor implements Executor { private final WorkingMemory workingMemory; - /** - * Constructs the object. - * - * @param workingMemory where tasks should be injected - */ - public DroolsExecutor(WorkingMemory workingMemory) { - this.workingMemory = workingMemory; - } - @Override public void execute(Runnable command) { DroolsRunnable runnable = command::run; diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java b/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java index 5bce3505..1eab676f 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-core * ================================================================================ - * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +26,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.concurrent.ConcurrentHashMap; -import org.kie.api.KieBase; +import lombok.Getter; import org.kie.api.KieServices; import org.kie.api.builder.KieScanner; import org.kie.api.builder.Message; @@ -57,6 +57,7 @@ public class PolicyContainer implements Startable { private ConcurrentHashMap<Object, Object> adjuncts = new ConcurrentHashMap<>(); // 'KieContainer' associated with this 'PolicyContainer' + @Getter private KieContainer kieContainer; // indicates whether the PolicyContainer is 'started' @@ -106,7 +107,7 @@ public class PolicyContainer implements Startable { * @param releaseId indicates the artifact that is to be installed in this container */ public PolicyContainer(ReleaseId releaseId) { - ReleaseId newReleaseId = releaseId; + var newReleaseId = releaseId; if (newReleaseId.getVersion().contains(",")) { // this is actually a comma-separated list of release ids newReleaseId = @@ -193,15 +194,6 @@ public class PolicyContainer implements Startable { } /** - * Get kie container. - * - * @return the associated 'KieContainer' instance - */ - public KieContainer getKieContainer() { - return kieContainer; - } - - /** * Get class loader. * * @return the 'ClassLoader' associated with the 'KieContainer' instance @@ -332,8 +324,8 @@ public class PolicyContainer implements Startable { logger.info("adoptKieSession:name: {} kieSession: {}", name, kieSession); } // fetch KieBase, and verify it belongs to this KieContainer - boolean match = false; - KieBase kieBase = kieSession.getKieBase(); + var match = false; + var kieBase = kieSession.getKieBase(); logger.info("adoptKieSession:kieBase: {}", kieBase); for (String kieBaseName : kieContainer.getKieBaseNames()) { logger.info("adoptKieSession:kieBaseName: {}", kieBaseName); @@ -358,7 +350,7 @@ public class PolicyContainer implements Startable { // create the new 'PolicySession', add it to the table, // and return the object to the caller logger.info("adoptKieSession:create a new policySession with name {}", name); - PolicySession policySession = new PolicySession(name, this, kieSession); + var policySession = new PolicySession(name, this, kieSession); sessions.put(name, policySession); // notify features @@ -383,8 +375,8 @@ public class PolicyContainer implements Startable { * how to determine success/failure) */ public String updateToVersion(String newVersion) { - ReleaseId releaseId = kieContainer.getReleaseId(); - Results results = this.updateToVersion( + var releaseId = kieContainer.getReleaseId(); + var results = this.updateToVersion( kieServices.newReleaseId(releaseId.getGroupId(), releaseId.getArtifactId(), newVersion)); List<Message> messages = results == null ? null : results.getMessages(); @@ -411,7 +403,7 @@ public class PolicyContainer implements Startable { } // update the version - Results results = kieContainer.updateToVersion(releaseId); + var results = kieContainer.updateToVersion(releaseId); // add common KiePackage instances @@ -519,7 +511,7 @@ public class PolicyContainer implements Startable { * @return 'true' if the fact was inserted into at least one session, 'false' if not */ public boolean insertAll(Object object) { - boolean rval = false; + var rval = false; synchronized (sessions) { for (PolicySession session : sessions.values()) { session.insertDrools(object); @@ -553,7 +545,7 @@ public class PolicyContainer implements Startable { for (String kieSessionName : kieContainer.getKieSessionNamesInKieBase(kieBaseName)) { // if the 'PolicySession' does not currently exist, this method // call will attempt to create it - PolicySession session = activatePolicySession(kieSessionName, kieBaseName); + var session = activatePolicySession(kieSessionName, kieBaseName); if (session != null) { session.startThread(); } @@ -708,7 +700,7 @@ public class PolicyContainer implements Startable { * @param args standard 'main' arguments, which are currently ignored */ public static void globalInit(String[] args) { - String configDir = "config"; + var configDir = "config"; logger.info("PolicyContainer.main: configDir={}", configDir); // invoke 'globalInit' on all of the features diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java b/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java index fb17b10a..1f8a61c6 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java @@ -22,6 +22,7 @@ package org.onap.policy.drools.core; import java.util.concurrent.ConcurrentHashMap; +import lombok.Getter; import org.kie.api.event.rule.AfterMatchFiredEvent; import org.kie.api.event.rule.AgendaEventListener; import org.kie.api.event.rule.AgendaGroupPoppedEvent; @@ -52,11 +53,18 @@ public class PolicySession implements AgendaEventListener, RuleRuntimeEventListener { // get an instance of logger private static Logger logger = LoggerFactory.getLogger(PolicySession.class); + + // supports 'getCurrentSession()' method + private static ThreadLocal<PolicySession> policySess = + new ThreadLocal<>(); + // name of the 'PolicySession' and associated 'KieSession' + @Getter private String name; // the associated 'PolicyContainer', which may have additional // 'PolicySession' instances in addition to this one + @Getter private PolicyContainer container; // maps feature objects to per-PolicyContainer data @@ -64,15 +72,12 @@ public class PolicySession new ConcurrentHashMap<>(); // associated 'KieSession' instance + @Getter private KieSession kieSession; // if not 'null', this is the thread model processing the 'KieSession' private ThreadModel threadModel = null; - // supports 'getCurrentSession()' method - private static ThreadLocal<PolicySession> policySess = - new ThreadLocal<>(); - /** * Internal constructor - create a 'PolicySession' instance. * @@ -90,35 +95,6 @@ public class PolicySession } /** - * Get policy container. - * - * @return the 'PolicyContainer' object containing this session - */ - public PolicyContainer getPolicyContainer() { - return container; - } - - /** - * Get Kie Session. - * - * @return the associated 'KieSession' instance - */ - public KieSession getKieSession() { - return kieSession; - } - - /** - * Get name. - * - * @return the local name of this session, which should either match the - * name specified in 'kmodule.xml' file associated with this session, or the - * name passed on the 'PolicyContainer.adoptKieSession' method. - */ - public String getName() { - return name; - } - - /** * Get full name. * * @return the 'PolicyContainer' name, followed by ':', followed by the diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/PolicySessionFeatureApiConstants.java b/policy-core/src/main/java/org/onap/policy/drools/core/PolicySessionFeatureApiConstants.java index 174ac794..98808848 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/PolicySessionFeatureApiConstants.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/PolicySessionFeatureApiConstants.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-core * ================================================================================ - * 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. @@ -20,9 +20,12 @@ package org.onap.policy.drools.core; +import lombok.AccessLevel; import lombok.Getter; +import lombok.NoArgsConstructor; import org.onap.policy.common.utils.services.OrderedServiceImpl; +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class PolicySessionFeatureApiConstants { /** * 'FeatureAPI.impl.getList()' returns an ordered list of objects @@ -31,8 +34,4 @@ public class PolicySessionFeatureApiConstants { @Getter private static final OrderedServiceImpl<PolicySessionFeatureApi> impl = new OrderedServiceImpl<>(PolicySessionFeatureApi.class); - - private PolicySessionFeatureApiConstants() { - // do nothing - } } diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmx.java b/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmx.java index e1a89752..0f4add77 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmx.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmx.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * policy-core * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018, 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. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,17 +21,16 @@ package org.onap.policy.drools.core.jmx; import java.util.concurrent.atomic.AtomicLong; +import lombok.Getter; public class PdpJmx implements PdpJmxMBean { + @Getter private static PdpJmx instance = new PdpJmx(); + private final AtomicLong updates = new AtomicLong(); private final AtomicLong actions = new AtomicLong(); - public static PdpJmx getInstance() { - return instance; - } - @Override public long getUpdates() { return updates.longValue(); diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmxListener.java b/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmxListener.java index 924f2b00..4a39173c 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmxListener.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmxListener.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-core * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018, 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. @@ -24,25 +24,24 @@ import java.lang.management.ManagementFactory; import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceNotFoundException; import javax.management.MBeanRegistrationException; -import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.management.NotCompliantMBeanException; import javax.management.ObjectName; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class PdpJmxListener { public static final Logger logger = LoggerFactory.getLogger(PdpJmxListener.class); - private PdpJmxListener() { - } - /** * Stop the listener. */ public static void stop() { - final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); + final var server = ManagementFactory.getPlatformMBeanServer(); try { server.unregisterMBean(new ObjectName("PolicyEngine:type=PdpJmx")); } catch (MBeanRegistrationException | InstanceNotFoundException @@ -58,7 +57,7 @@ public class PdpJmxListener { * Start. */ public static void start() { - final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); + final var server = ManagementFactory.getPlatformMBeanServer(); try { server.registerMBean(PdpJmx.getInstance(), new ObjectName("PolicyEngine:type=PdpJmx")); } catch (InstanceAlreadyExistsException | MBeanRegistrationException diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java b/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java index 03024f52..dbb20883 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java @@ -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. @@ -20,22 +20,17 @@ package org.onap.policy.drools.core.lock; +import lombok.NoArgsConstructor; /** * Lock implementation whose operations always fail. */ +@NoArgsConstructor public class AlwaysFailLock extends LockImpl { private static final long serialVersionUID = 1L; /** * Constructs the object. - */ - public AlwaysFailLock() { - super(); - } - - /** - * Constructs the object. * * @param resourceId identifier of the resource to be locked * @param ownerKey information identifying the owner requesting the lock diff --git a/policy-core/src/main/java/org/onap/policy/drools/properties/DroolsPropertyConstants.java b/policy-core/src/main/java/org/onap/policy/drools/properties/DroolsPropertyConstants.java index 197c972d..110412a2 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/properties/DroolsPropertyConstants.java +++ b/policy-core/src/main/java/org/onap/policy/drools/properties/DroolsPropertyConstants.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-core * ================================================================================ - * 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. @@ -20,7 +20,11 @@ package org.onap.policy.drools.properties; -public class DroolsPropertyConstants { +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class DroolsPropertyConstants { /* Controller Properties */ @@ -36,8 +40,4 @@ public class DroolsPropertyConstants { public static final String RULES_GROUPID = "rules.groupId"; public static final String RULES_ARTIFACTID = "rules.artifactId"; public static final String RULES_VERSION = "rules.version"; - - private DroolsPropertyConstants() { - // do nothing - } } diff --git a/policy-core/src/main/java/org/onap/policy/drools/util/FeatureEnabledChecker.java b/policy-core/src/main/java/org/onap/policy/drools/util/FeatureEnabledChecker.java index aaafd0ec..755e7a18 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/util/FeatureEnabledChecker.java +++ b/policy-core/src/main/java/org/onap/policy/drools/util/FeatureEnabledChecker.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018, 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. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,22 +21,18 @@ package org.onap.policy.drools.util; import java.util.Properties; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; /** * Checks whether or not a feature is enabled. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class FeatureEnabledChecker { /** - * Constructor. - */ - private FeatureEnabledChecker() { - super(); - } - - /** * Determines if a feature is enabled. - * + * * @param props properties from which to extract the "enabled" flag * @param propName the name of the "enabled" property * @return {@code true} if the feature is enabled, or {@code false} if it is not diff --git a/policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java b/policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java index d56af118..043e2b10 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java +++ b/policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-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. @@ -33,6 +33,8 @@ import java.util.HashSet; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import lombok.NonNull; import org.apache.commons.io.IOUtils; import org.drools.compiler.kie.builder.impl.InternalKieModule; @@ -44,7 +46,6 @@ import org.kie.api.builder.KieBuilder; import org.kie.api.builder.KieFileSystem; import org.kie.api.builder.Message; import org.kie.api.builder.ReleaseId; -import org.kie.api.builder.model.KieModuleModel; import org.kie.api.definition.KiePackage; import org.kie.api.definition.rule.Rule; import org.kie.api.runtime.KieContainer; @@ -56,7 +57,8 @@ import org.slf4j.LoggerFactory; /** * Kie related utilities. */ -public class KieUtils { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class KieUtils { private static final Logger logger = LoggerFactory.getLogger(KieUtils.class); @@ -64,25 +66,21 @@ public class KieUtils { private static final String RESOURCE_PREFIX = "src/main/resources/drools"; private static final String RESOURCE_SUFFIX = ".drl"; - private KieUtils() { - // Utility class - } - /** * Installs a rules artifact in the local maven repository. */ public static ReleaseId installArtifact(File kmodule, File pom, String drlKJarPath, @NonNull List<File> drls) throws IOException { - KieModuleModel kieModule = KieModuleModelImpl.fromXML(kmodule); + var kieModule = KieModuleModelImpl.fromXML(kmodule); - final KieFileSystem kieFileSystem = KieServices.Factory.get().newKieFileSystem(); + final var kieFileSystem = KieServices.Factory.get().newKieFileSystem(); kieFileSystem.writeKModuleXML(kieModule.toXML()); kieFileSystem.writePomXML(new String(Files.readAllBytes(pom.toPath()))); for (File drl : drls) { kieFileSystem.write(drlKJarPath + drl.getName(), new String(Files.readAllBytes(drl.toPath()))); } - KieBuilder kieBuilder = build(kieFileSystem); + var kieBuilder = build(kieFileSystem); return getReleaseId(kieBuilder, pom); } @@ -95,7 +93,7 @@ public class KieUtils { } private static ReleaseId getReleaseId(KieBuilder kieBuilder, File pomFile) { - ReleaseId releaseId = kieBuilder.getKieModule().getReleaseId(); + var releaseId = kieBuilder.getKieModule().getReleaseId(); KieMavenRepository .getKieMavenRepository() .installArtifact(releaseId, @@ -164,7 +162,7 @@ public class KieUtils { } private static KieBuilder build(KieFileSystem kieFileSystem) { - KieBuilder kieBuilder = KieServices.Factory.get().newKieBuilder(kieFileSystem); + var kieBuilder = KieServices.Factory.get().newKieBuilder(kieFileSystem); List<Message> messages = kieBuilder.buildAll().getResults().getMessages(); if (messages != null && !messages.isEmpty()) { throw new IllegalArgumentException(messages.toString()); @@ -198,11 +196,11 @@ public class KieUtils { } // generate a 'KieFileSystem' from these resources - KieServices kieServices = KieServices.Factory.get(); - KieFileSystem kfs = kieServices.newKieFileSystem(); - int index = 1; + var kieServices = KieServices.Factory.get(); + var kfs = kieServices.newKieFileSystem(); + var index = 1; while (resources.hasMoreElements()) { - URL url = resources.nextElement(); + var url = resources.nextElement(); try (InputStream is = url.openStream()) { // convert a resource to a byte array byte[] drl = IOUtils.toByteArray(is); @@ -216,7 +214,7 @@ public class KieUtils { } // do a build of the 'KieFileSystem' - KieBuilder builder = kieServices.newKieBuilder(kfs, classLoader); + var builder = kieServices.newKieBuilder(kfs, classLoader); builder.buildAll(); List<Message> results = builder.getResults().getMessages(); if (!results.isEmpty()) { diff --git a/policy-core/src/test/java/org/onap/policy/drools/core/DroolsContainerTest.java b/policy-core/src/test/java/org/onap/policy/drools/core/DroolsContainerTest.java index 9fe5c708..81ca3407 100644 --- a/policy-core/src/test/java/org/onap/policy/drools/core/DroolsContainerTest.java +++ b/policy-core/src/test/java/org/onap/policy/drools/core/DroolsContainerTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-core * ================================================================================ - * 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. @@ -128,7 +128,7 @@ public class DroolsContainerTest { } // verify session attributes - assertEquals(container, session.getPolicyContainer()); + assertEquals(container, session.getContainer()); assertEquals("session1", session.getName()); assertEquals("org.onap.policy.drools-pdp:drools-artifact1:17.1.0-SNAPSHOT:session1", session.getFullName()); @@ -158,7 +158,7 @@ public class DroolsContainerTest { assertEquals("17.2.0-SNAPSHOT", container.getVersion()); // verify new session attributes - assertEquals(container, session.getPolicyContainer()); + assertEquals(container, session.getContainer()); assertEquals("session1", session.getName()); assertEquals("org.onap.policy.drools-pdp:drools-artifact1:17.2.0-SNAPSHOT:session1", session.getFullName()); @@ -290,7 +290,7 @@ public class DroolsContainerTest { } // verify session attributes - assertEquals(container, session.getPolicyContainer()); + assertEquals(container, session.getContainer()); assertEquals("session1", session.getName()); assertEquals("org.onap.policy.drools-pdp:drools-artifact1:17.1.0-SNAPSHOT:session1", session.getFullName()); diff --git a/policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionTest.java b/policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionTest.java index 3b882195..e937bb30 100644 --- a/policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionTest.java +++ b/policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018, 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018, 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. @@ -69,7 +69,7 @@ public class PolicySessionTest { verify(kie).addEventListener(rule); // test other simple methods - assertEquals(container, session.getPolicyContainer()); + assertEquals(container, session.getContainer()); assertEquals(kie, session.getKieSession()); assertEquals(MY_NAME, session.getName()); assertEquals(CONTAINER + ":" + MY_NAME, session.getFullName()); |