Use parent snapshot in drools-apps 77/109577/4
authorJim Hahn <jrh3@att.com>
Thu, 25 Jun 2020 15:12:36 +0000 (11:12 -0400)
committerJim Hahn <jrh3@att.com>
Thu, 25 Jun 2020 15:57:00 +0000 (11:57 -0400)
Fixed checkstyle issues that were subsequently reported.
Also fixed a few eclipse warnings.
Also fixed some of the sonar issues in the files that were touched:
- use "{}" in logger calls
- camelcase method names
- use "<?>" instead of generics
- add serialization ID

Issue-ID: POLICY-2188
Change-Id: I5c94a2e26dd74a61a0a919e1c3da17ab02a5bc9d
Signed-off-by: Jim Hahn <jrh3@att.com>
30 files changed:
controlloop/common/eventmanager/pom.xml
controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/server/restful/RestTransactionTrackerTest.java
controlloop/common/guard/pom.xml
controlloop/m2/adapters/src/main/java/org/onap/policy/m2/adapters/VirtualOnsetAdapter.java
controlloop/m2/adapters/src/test/java/org/onap/policy/m2/adapters/VirtualOnsetAdapterTest.java
controlloop/m2/appclcm/src/main/java/org/onap/policy/m2/appclcm/AppcLcmActor.java
controlloop/m2/appclcm/src/main/java/org/onap/policy/m2/appclcm/AppcLcmHealthCheckOperation.java
controlloop/m2/appclcm/src/main/java/org/onap/policy/m2/appclcm/AppcLcmOperation.java
controlloop/m2/appclcm/src/test/java/appclcm/AppcLcmActorTest.java
controlloop/m2/appclcm/src/test/java/appclcm/AppcLcmHealthCheckOperationTest.java
controlloop/m2/appclcm/src/test/java/appclcm/AppcLcmOperationTest.java
controlloop/m2/appclcm/src/test/java/model/AppcLcmResponseCodeTest.java
controlloop/m2/base/src/main/java/org/onap/policy/m2/base/GuardAdjunct.java
controlloop/m2/base/src/main/java/org/onap/policy/m2/base/OnsetAdapter.java
controlloop/m2/base/src/main/java/org/onap/policy/m2/base/Operation.java
controlloop/m2/base/src/main/java/org/onap/policy/m2/base/Transaction.java
controlloop/m2/base/src/test/java/org/onap/policy/m2/base/ActorOperationTest.java
controlloop/m2/base/src/test/java/org/onap/policy/m2/base/GuardAdjunctTest.java
controlloop/m2/base/src/test/java/org/onap/policy/m2/base/TransactionTest.java
controlloop/m2/guard/src/main/java/org/onap/policy/guard/GuardContext.java
controlloop/m2/guard/src/test/java/org/onap/policy/guard/GuardContextTest.java
controlloop/m2/lock/src/main/java/org/onap/policy/drools/m2/lock/LockAdjunct.java
controlloop/m2/lock/src/test/java/org/onap/policy/drools/m2/lock/LockAdjunctTest.java
controlloop/m2/test/src/test/java/org/onap/policy/m2/test/AppcLcmTest.java
controlloop/m2/test/src/test/java/org/onap/policy/m2/test/SimDmaap.java
controlloop/m2/test/src/test/java/org/onap/policy/m2/test/SimGuard.java
controlloop/m2/test/src/test/java/org/onap/policy/m2/test/Util.java
controlloop/m2/util/src/main/java/org/onap/policy/util/DroolsSessionCommonSerializable.java
controlloop/m2/util/src/test/java/org/onap/policy/util/DroolsSessionCommonSerializableTest.java
pom.xml

index aa4f8e8..a2ac8ae 100644 (file)
@@ -41,7 +41,6 @@
         <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
-            <version>2.5</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
index d05b975..02842da 100644 (file)
@@ -23,7 +23,6 @@ package org.onap.policy.drools.server.restful;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Collections;
@@ -151,10 +150,6 @@ public class RestTransactionTrackerTest {
         assertNotNull(HttpClient.getBody(response, clazz));
     }
 
-    private <T> void empty(Response response, Class<T> clazz) {
-        assertNull(HttpClient.getBody(response, clazz));
-    }
-
     @NotNull
     private Response checkResponse(int statusCode, Response response) {
         assertEquals(statusCode, response.getStatus());
index 8c355db..ec3c0e4 100644 (file)
@@ -2,7 +2,7 @@
   ============LICENSE_START=======================================================
   drools-pdp-apps
   ================================================================================
-  Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+  Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
   Modifications Copyright (C) 2020 Bell Canada.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
@@ -77,7 +77,6 @@
     <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
-      <version>2.5</version>
       <scope>provided</scope>
     </dependency>
     <dependency>
index e9ca116..1a3a5f6 100644 (file)
 package org.onap.policy.m2.adapters;
 
 import java.io.Serializable;
-
 import org.onap.policy.controlloop.ControlLoopEvent;
 import org.onap.policy.controlloop.ControlLoopNotification;
 import org.onap.policy.controlloop.VirtualControlLoopEvent;
 import org.onap.policy.controlloop.VirtualControlLoopNotification;
-
 import org.onap.policy.m2.base.OnsetAdapter;
 
 public class VirtualOnsetAdapter extends OnsetAdapter implements Serializable {
@@ -50,7 +48,7 @@ public class VirtualOnsetAdapter extends OnsetAdapter implements Serializable {
     @Override
     public ControlLoopNotification createNotification(ControlLoopEvent event) {
         if (event instanceof VirtualControlLoopEvent) {
-            return new VirtualControlLoopNotification((VirtualControlLoopEvent)event);
+            return new VirtualControlLoopNotification((VirtualControlLoopEvent) event);
         }
 
         // Right now, the onset event from the transaction is used to locate
index c19a80e..4b38b1e 100644 (file)
@@ -22,10 +22,8 @@ package org.onap.policy.m2.adapters;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
-
 import org.onap.policy.controlloop.ControlLoopEvent;
 import org.onap.policy.controlloop.ControlLoopNotification;
 import org.onap.policy.controlloop.VirtualControlLoopEvent;
@@ -47,7 +45,9 @@ public class VirtualOnsetAdapterTest {
         // we want an exact class match, so 'instanceOf' is not being used
         assertEquals(VirtualControlLoopNotification.class, notification.getClass());
 
-        ControlLoopEvent controlLoopEvent = new ControlLoopEvent() {};
+        ControlLoopEvent controlLoopEvent = new ControlLoopEvent() {
+            private static final long serialVersionUID = 1L;
+        };
         notification = virtualOnsetAdapter.createNotification(controlLoopEvent);
         assertNotNull(notification);
     }
index f89d3b8..ee9ebdc 100644 (file)
 package org.onap.policy.m2.appclcm;
 
 import java.io.Serializable;
-
 import org.onap.policy.controlloop.ControlLoopEvent;
 import org.onap.policy.controlloop.policy.Policy;
-
 import org.onap.policy.m2.adapters.VirtualOnsetAdapter;
 import org.onap.policy.m2.base.Actor;
 import org.onap.policy.m2.base.Operation;
index cc0df45..40e0b0a 100644 (file)
@@ -22,7 +22,6 @@ package org.onap.policy.m2.appclcm;
 
 import java.util.HashMap;
 import java.util.Map;
-
 import org.onap.policy.appclcm.AppcLcmDmaapWrapper;
 import org.onap.policy.appclcm.AppcLcmOutput;
 import org.onap.policy.common.utils.coder.CoderException;
@@ -33,7 +32,6 @@ import org.onap.policy.controlloop.policy.PolicyResult;
 import org.onap.policy.guard.PolicyGuardResponse;
 import org.onap.policy.m2.appclcm.model.AppcLcmResponseCode;
 import org.onap.policy.m2.base.Transaction;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -60,6 +58,7 @@ public class AppcLcmHealthCheckOperation extends AppcLcmOperation {
      *            the appc lcm response json payload
      * @return the string that contains the state of the vnf
      */
+    @SuppressWarnings("unchecked")
     private String getVnfHealthState(String jsonPayload) {
         HashMap<String, Object> healthCheckPayloadMap;
         try {
@@ -96,7 +95,7 @@ public class AppcLcmHealthCheckOperation extends AppcLcmOperation {
         // The rest of this method is mostly copied from
         // 'ControlLoopOperationManager.onResponse'.
 
-        AppcLcmOutput response = ((AppcLcmDmaapWrapper)object).getBody().getOutput();
+        AppcLcmOutput response = ((AppcLcmDmaapWrapper) object).getBody().getOutput();
 
         //
         // Determine which subrequestID (ie. attempt)
index 668860e..24f8ed5 100644 (file)
 package org.onap.policy.m2.appclcm;
 
 import com.google.common.collect.ImmutableList;
-
 import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
 import lombok.Getter;
-
 import org.onap.policy.appclcm.AppcLcmBody;
 import org.onap.policy.appclcm.AppcLcmCommonHeader;
 import org.onap.policy.appclcm.AppcLcmDmaapWrapper;
@@ -47,7 +45,6 @@ import org.onap.policy.m2.appclcm.model.AppcLcmResponseCode;
 import org.onap.policy.m2.base.GuardAdjunct;
 import org.onap.policy.m2.base.Operation;
 import org.onap.policy.m2.base.Transaction;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -164,7 +161,7 @@ public class AppcLcmOperation implements Operation, LockAdjunct.Requestor, Seria
             return;
         }
 
-        this.onset = (VirtualControlLoopEvent)onset;
+        this.onset = (VirtualControlLoopEvent) onset;
 
         // fetch or create the guard adjunct -- note that 'guard' operations are
         // only performed if a 'GuardContext' is present, and the adjunct was
@@ -508,7 +505,7 @@ public class AppcLcmOperation implements Operation, LockAdjunct.Requestor, Seria
     public void incomingMessage(Object object) {
         if (! (object instanceof AppcLcmDmaapWrapper)) {
             if (object instanceof PolicyGuardResponse) {
-                incomingGuardMessage((PolicyGuardResponse)object);
+                incomingGuardMessage((PolicyGuardResponse) object);
             } else if (object instanceof ControlLoopEvent) {
                 incomingAbatedEvent((ControlLoopEvent) object);
             }
@@ -520,7 +517,7 @@ public class AppcLcmOperation implements Operation, LockAdjunct.Requestor, Seria
         // The rest of this method is mostly copied from
         // 'ControlLoopOperationManager.onResponse'.
 
-        AppcLcmOutput response = ((AppcLcmDmaapWrapper)object).getBody().getOutput();
+        AppcLcmOutput response = ((AppcLcmDmaapWrapper) object).getBody().getOutput();
 
         //
         // Determine which subrequestID (ie. attempt)
index e1bc162..1c6e81e 100644 (file)
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.mock;
 
 import java.util.Properties;
 import java.util.UUID;
-
 import org.drools.core.WorkingMemory;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -42,12 +41,8 @@ import org.onap.policy.m2.appclcm.AppcLcmActor;
 import org.onap.policy.m2.appclcm.AppcLcmHealthCheckOperation;
 import org.onap.policy.m2.appclcm.AppcLcmOperation;
 import org.onap.policy.m2.base.Transaction;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class AppcLcmActorTest {
-    private static Logger logger = LoggerFactory.getLogger(AppcLcmActorTest.class);
-
     public static Policy policy;
     public static VirtualControlLoopEvent event;
     public static Transaction transaction;
index f49204e..6e606b2 100644 (file)
@@ -23,18 +23,14 @@ package appclcm;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-
 import static org.mockito.Mockito.mock;
 
 import java.util.Properties;
 import java.util.UUID;
-
 import org.drools.core.WorkingMemory;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
-
 import org.onap.policy.appclcm.AppcLcmDmaapWrapper;
 import org.onap.policy.appclcm.AppcLcmInput;
 import org.onap.policy.appclcm.util.Serialization;
index 7800399..e270c3d 100644 (file)
@@ -30,13 +30,10 @@ import static org.mockito.Mockito.mock;
 import java.util.HashMap;
 import java.util.Properties;
 import java.util.UUID;
-
 import org.drools.core.WorkingMemory;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
-
 import org.onap.policy.appclcm.AppcLcmDmaapWrapper;
 import org.onap.policy.appclcm.AppcLcmInput;
 import org.onap.policy.appclcm.util.Serialization;
@@ -51,7 +48,6 @@ import org.onap.policy.controlloop.policy.TargetType;
 import org.onap.policy.drools.system.PolicyEngineConstants;
 import org.onap.policy.m2.appclcm.AppcLcmOperation;
 import org.onap.policy.m2.base.Transaction;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
index fc33492..327f8c5 100644 (file)
@@ -24,7 +24,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 
 import org.junit.Test;
-
 import org.onap.policy.m2.appclcm.model.AppcLcmResponseCode;
 
 
index 34397e2..d3675ae 100644 (file)
@@ -21,7 +21,6 @@
 package org.onap.policy.m2.base;
 
 import java.io.Serializable;
-
 import org.onap.policy.controlloop.ControlLoopOperation;
 import org.onap.policy.controlloop.policy.Policy;
 import org.onap.policy.guard.GuardContext;
index 37a999f..3c164cf 100644 (file)
 package org.onap.policy.m2.base;
 
 import java.io.Serializable;
-
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-
 import org.onap.policy.controlloop.ControlLoopEvent;
 import org.onap.policy.controlloop.ControlLoopNotification;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -42,7 +39,7 @@ public class OnsetAdapter implements Serializable {
     private static Logger logger = LoggerFactory.getLogger(OnsetAdapter.class);
 
     // table mapping onset message class to 'OnsetAdapter' instance
-    private static Map<Class,OnsetAdapter> map = new ConcurrentHashMap<>();
+    private static Map<Class<?>, OnsetAdapter> map = new ConcurrentHashMap<>();
 
     /**
      * This method is called to add an entry to the table.
@@ -51,7 +48,7 @@ public class OnsetAdapter implements Serializable {
      * @param value an instance of 'OnsetAdapter' that should be
      *     associated with 'clazz'
      */
-    public static void register(Class clazz, OnsetAdapter value) {
+    public static void register(Class<?> clazz, OnsetAdapter value) {
         // only create an entry if one doesn't already exist
         map.putIfAbsent(clazz, value);
     }
@@ -79,14 +76,14 @@ public class OnsetAdapter implements Serializable {
         // one will be chosen "at random".
 
         // we need to look for the best match of 'clazz'
-        HashSet<Class> matches = new HashSet<>();
-        Class chosenMatch = null;
+        HashSet<Class<?>> matches = new HashSet<>();
+        Class<?> chosenMatch = null;
         synchronized (map) {
             for (Class<?> possibleMatch : map.keySet()) {
                 if (possibleMatch.isAssignableFrom(clazz)) {
                     // we have a match -- see if it is the best match
                     boolean add = true;
-                    for (Class<?> match : new ArrayList<Class>(matches)) {
+                    for (Class<?> match : new ArrayList<Class<?>>(matches)) {
                         if (match.isAssignableFrom(possibleMatch)) {
                             // 'possibleMatch' is a better match than 'match'
                             matches.remove(match);
@@ -134,6 +131,8 @@ public class OnsetAdapter implements Serializable {
 
     // the new 'ControlLoopNotification' is abstract
     public static class BaseControlLoopNotification extends ControlLoopNotification {
+        private static final long serialVersionUID = 1L;
+
         BaseControlLoopNotification(ControlLoopEvent event) {
             super(event);
         }
index ec5ab8e..c8ee901 100644 (file)
@@ -21,7 +21,6 @@
 package org.onap.policy.m2.base;
 
 import java.io.Serializable;
-
 import org.onap.policy.controlloop.ControlLoopException;
 import org.onap.policy.controlloop.ControlLoopOperation;
 import org.onap.policy.controlloop.policy.Policy;
index 41c251e..f964e20 100644 (file)
@@ -29,11 +29,9 @@ import java.util.List;
 import java.util.Map;
 import java.util.ServiceLoader;
 import java.util.UUID;
-
 import lombok.Getter;
 import org.drools.core.WorkingMemory;
 import org.kie.api.runtime.rule.FactHandle;
-
 import org.onap.policy.controlloop.ControlLoopEvent;
 import org.onap.policy.controlloop.ControlLoopNotification;
 import org.onap.policy.controlloop.ControlLoopNotificationType;
@@ -42,7 +40,6 @@ import org.onap.policy.controlloop.policy.ControlLoopPolicy;
 import org.onap.policy.controlloop.policy.FinalResult;
 import org.onap.policy.controlloop.policy.Policy;
 import org.onap.policy.controlloop.policy.PolicyResult;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -58,7 +55,7 @@ public class Transaction implements Serializable {
     // This table maps 'actor' names to objects implementing the
     // 'Actor' interface. 'ServiceLoader' is used to locate and create
     // these objects, and populate the table.
-    private static Map<String,Actor> nameToActor = new HashMap<>();
+    private static Map<String, Actor> nameToActor = new HashMap<>();
 
     static {
         // use 'ServiceLoader' to locate all of the 'Actor' implementations
@@ -428,7 +425,7 @@ public class Transaction implements Serializable {
                 break;
 
             case FAILURE:
-                nextPolicy = processResult_Failure();
+                nextPolicy = processResultFailure();
                 break;
 
             case FAILURE_TIMEOUT:
@@ -499,7 +496,7 @@ public class Transaction implements Serializable {
     }
 
     // returns the next policy if the current operation fails
-    private String processResult_Failure() {
+    private String processResultFailure() {
         String nextPolicy = null;
         int attempt = currentOperation.getAttempt();
         if (attempt <= currentPolicy.getRetry()) {
@@ -507,20 +504,19 @@ public class Transaction implements Serializable {
             Actor actor = nameToActor.get(currentPolicy.getActor());
             if (actor != null) {
                 attempt += 1;
-                logger.debug("found Actor, attempt " + attempt);
+                logger.debug("found Actor, attempt {}", attempt);
                 currentOperation =
                     actor.createOperation(this, currentPolicy, onset, attempt);
                 createHistEntry();
             } else {
-                logger.error("'Transaction' can't find actor "
-                             + currentPolicy.getActor());
+                logger.error("'Transaction' can't find actor {}", currentPolicy.getActor());
             }
         } else {
             // operation failed, and no retries (or no retries left)
             nextPolicy = (attempt == 1
                 ? currentPolicy.getFailure()
                 : currentPolicy.getFailure_retries());
-            logger.debug("moving to policy " + nextPolicy);
+            logger.debug("moving to policy {}", nextPolicy);
         }
         return nextPolicy;
     }
@@ -592,11 +588,10 @@ public class Transaction implements Serializable {
                     actor.createOperation(this, currentPolicy, onset, 1);
                 createHistEntry();
             } else {
-                logger.error("'Transaction' can't find actor "
-                             + currentPolicy.getActor());
+                logger.error("'Transaction' can't find actor {}", currentPolicy.getActor());
             }
         } else {
-            logger.error("Transaction' can't find policy " + id);
+            logger.error("Transaction' can't find policy {}", id);
         }
 
         if (currentOperation == null) {
@@ -670,7 +665,7 @@ public class Transaction implements Serializable {
             T adjunct = null;
             try {
                 // create the adjunct (may trigger an exception)
-                adjunct = clazz.newInstance();
+                adjunct = clazz.getDeclaredConstructor().newInstance();
 
                 // initialize the adjunct (may also trigger an exception */
                 adjunct.init(Transaction.this);
index ce5f2df..33b4928 100644 (file)
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
 import org.junit.Test;
-
 import org.onap.policy.controlloop.ControlLoopEvent;
 import org.onap.policy.controlloop.ControlLoopException;
 import org.onap.policy.controlloop.policy.Policy;
@@ -37,6 +36,7 @@ public class ActorOperationTest {
     public static final String STATE = "COMPLETE";
 
     public static class TestOperation implements Operation {
+        private static final long serialVersionUID = 1L;
 
         @Override
         public Object getRequest() throws ControlLoopException {
index 78aab89..facde54 100644 (file)
@@ -26,14 +26,11 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
 
 import java.time.Instant;
 import java.util.UUID;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
-
 import org.onap.policy.controlloop.ControlLoopOperation;
 import org.onap.policy.controlloop.policy.Policy;
 import org.onap.policy.guard.GuardContext;
@@ -41,7 +38,6 @@ import org.powermock.reflect.Whitebox;
 
 public class GuardAdjunctTest {
     private static final String ADJUNCT_CONTEXT_FIELD = "context";
-    private static final String ADJUNCT_TRANSACTION_FIELD = "transaction";
 
     private static GuardAdjunct adjunct;
     private static Transaction transaction;
@@ -73,7 +69,7 @@ public class GuardAdjunctTest {
         assertTrue(adjunct.asyncQuery(policy, "testTarget", UUID.randomUUID().toString()));
 
         GuardContext savedContext = Whitebox.getInternalState(adjunct, ADJUNCT_CONTEXT_FIELD);
-        Whitebox.setInternalState(adjunct, ADJUNCT_CONTEXT_FIELD, (GuardContext)null);
+        Whitebox.setInternalState(adjunct, ADJUNCT_CONTEXT_FIELD, (GuardContext) null);
 
         try {
             assertFalse(adjunct.asyncQuery(policy, "testTarget", UUID.randomUUID().toString()));
index 30546d0..c5fa6be 100644 (file)
@@ -25,14 +25,13 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.anyObject;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.time.Instant;
 import java.util.LinkedList;
 import java.util.UUID;
-
 import org.drools.core.WorkingMemory;
 import org.drools.core.impl.StatefulKnowledgeSessionImpl;
 import org.junit.BeforeClass;
@@ -46,7 +45,6 @@ import org.onap.policy.controlloop.policy.ControlLoopPolicy;
 import org.onap.policy.controlloop.policy.FinalResult;
 import org.onap.policy.controlloop.policy.Policy;
 import org.onap.policy.controlloop.policy.Target;
-import org.onap.policy.m2.base.GuardAdjunct;
 
 public class TransactionTest {
 
@@ -61,7 +59,7 @@ public class TransactionTest {
     public static void setUpBeforeClass() {
         mockWorkingMemory = mock(WorkingMemory.class);
         FactHandle factHandle = mock(FactHandle.class);
-        when(mockWorkingMemory.getFactHandle(anyObject())).thenReturn(factHandle);
+        when(mockWorkingMemory.getFactHandle(any())).thenReturn(factHandle);
     }
 
     @Test
@@ -310,7 +308,7 @@ public class TransactionTest {
         Transaction transaction = new Transaction(mockWorkingMemory, CL_NAME, UUID.randomUUID(), createControlLoop());
         ControlLoopNotification notification = transaction.processError();
         assertNull(notification);
-        
+
         VirtualControlLoopEvent onset =
                 createControlLoopEvent(UUID.randomUUID(), CL_NAME, null, "VM", "vserver.vserver-name");
         transaction.setControlLoopEvent(onset);
index 1bfb6ae..d41e30c 100644 (file)
@@ -33,7 +33,6 @@ import javax.persistence.Persistence;
 import org.drools.core.WorkingMemory;
 import org.onap.policy.drools.core.PolicyContainer;
 import org.onap.policy.drools.core.PolicySession;
-import org.onap.policy.drools.system.PolicyController;
 import org.onap.policy.drools.system.PolicyControllerConstants;
 import org.onap.policy.drools.system.PolicyEngineConstants;
 import org.onap.policy.util.DroolsSessionCommonSerializable;
@@ -257,7 +256,7 @@ public class GuardContext implements Serializable {
             // 'EntityManagerFactory' does not exist yet -- create one
 
             // copy database properties to a 'HashMap'
-            HashMap<Object,Object> propertiesMap = new HashMap<>(dbProperties);
+            HashMap<Object, Object> propertiesMap = new HashMap<>(dbProperties);
 
             // use 'ClassLoader' from Drools session
             propertiesMap.put("eclipselink.classloader",
index 7242b9f..54fd323 100644 (file)
@@ -37,7 +37,6 @@ import java.util.Properties;
 import java.util.UUID;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
-
 import org.drools.core.WorkingMemory;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
index 98d8287..937317c 100644 (file)
@@ -21,7 +21,6 @@
 package org.onap.policy.drools.m2.lock;
 
 import java.io.Serializable;
-
 import org.onap.policy.drools.core.lock.Lock;
 import org.onap.policy.drools.core.lock.LockCallback;
 import org.onap.policy.drools.system.PolicyEngineConstants;
index 65ad01a..2b4a29b 100644 (file)
@@ -26,23 +26,16 @@ import static org.junit.Assert.assertTrue;
 
 import java.util.Properties;
 import java.util.UUID;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
-
 import org.onap.policy.drools.core.lock.Lock;
 import org.onap.policy.drools.core.lock.LockCallback;
 import org.onap.policy.drools.system.PolicyEngineConstants;
 import org.onap.policy.m2.base.Transaction;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 public class LockAdjunctTest {
 
-    private static Logger logger = LoggerFactory.getLogger(LockAdjunctTest.class);
-
     public class TestOwner implements LockCallback {
 
         @Override
index a35e8c6..31003cb 100644 (file)
@@ -87,7 +87,7 @@ public class AppcLcmTest {
             "${notificationTopic}", "NOTIFICATION-APPCLCM-TOPIC",
             "${operationTopic}", "APPC-REQUEST-APPCLCM-TOPIC",
             "${policyName}", "appclcm",
-            "${policyScope}", "service=vUSP;resource=vCTS;type=operational" ,
+            "${policyScope}", "service=vUSP;resource=vCTS;type=operational",
             "${policyVersion}",
             "org.onap.policy.m2.test:appclcm:" + projectVersion,
             "${unique}", "2");
index 925e945..1c11fcc 100644 (file)
@@ -25,7 +25,6 @@ import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
-
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
@@ -34,7 +33,6 @@ import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,7 +45,7 @@ public class SimDmaap {
     private static Logger logger = LoggerFactory.getLogger(SimDmaap.class);
 
     // maps topic name to 'Topic' instance
-    static Map<String,Topic> topicTable = new ConcurrentHashMap<>();
+    static Map<String, Topic> topicTable = new ConcurrentHashMap<>();
 
     /**
      * Each instance of this class corresponds to a DMAAP or UEB topic.
@@ -57,7 +55,7 @@ public class SimDmaap {
         String topic;
 
         // maps group name into group instance
-        Map<String,Group> groupTable = new ConcurrentHashMap<>();
+        Map<String, Group> groupTable = new ConcurrentHashMap<>();
 
         /**
          * Create or get a Topic.
@@ -114,7 +112,7 @@ public class SimDmaap {
                     // no more messages
                     break;
                 }
-                String[] prefix = data.substring(cur,leftBrace).split("\\.");
+                String[] prefix = data.substring(cur, leftBrace).split("\\.");
                 if (prefix.length == 3) {
                     try {
                         // determine length of message, and advance current position
@@ -216,7 +214,7 @@ public class SimDmaap {
             builder.append("[\"").append(message);
 
             // add up to '<limit>-1' more messages
-            for (int i = 1 ; i < limit ; i += 1) {
+            for (int i = 1; i < limit; i += 1) {
                 // fetch the next message -- don't wait if it isn't currently there
                 message = messages.poll();
                 if (message == null) {
index 578dd6d..67df850 100644 (file)
 package org.onap.policy.m2.test;
 
 import com.google.gson.JsonObject;
-
 import javax.ws.rs.Consumes;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
-
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
index 48155fd..f6740f8 100644 (file)
@@ -28,13 +28,11 @@ import com.att.nsa.cambria.client.CambriaClientBuilders;
 import com.att.nsa.cambria.client.CambriaClientBuilders.ConsumerBuilder;
 import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder;
 import com.att.nsa.cambria.client.CambriaConsumer;
-
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonPrimitive;
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -47,7 +45,6 @@ import java.util.Properties;
 import java.util.UUID;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
-
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.ServerConnector;
 import org.eclipse.jetty.servlet.ServletContextHandler;
@@ -165,7 +162,7 @@ public class Util {
     public static String openAndReplace(String fileName, String... args)
         throws IOException, FileNotFoundException {
         String text = fileToString(new File(fileName));
-        for (int i = 0 ; i < args.length ; i += 2) {
+        for (int i = 0; i < args.length; i += 2) {
             text = text.replace(args[i], args[i + 1]);
         }
         return text;
@@ -202,7 +199,7 @@ public class Util {
      */
     public static JsonObject json(Object... data) {
         JsonObject obj = new JsonObject();
-        for (int i = 0 ; i < data.length ; i += 2) {
+        for (int i = 0; i < data.length; i += 2) {
             obj.add(data[i].toString(), toJsonElement(data[i + 1]));
         }
         return obj;
index d8501fe..0834026 100644 (file)
 
 package org.onap.policy.util;
 
-import java.io.InvalidObjectException;
 import java.io.ObjectStreamException;
 import java.io.Serializable;
 import java.util.HashMap;
-
 import org.onap.policy.drools.core.PolicySession;
 
 /**
@@ -116,7 +114,7 @@ public class DroolsSessionCommonSerializable implements Serializable {
                 session.setAdjunct(Adjunct.class, adjunct);
             } else {
                 // found the adjunct -- return it
-                adjunct = (Adjunct)adj;
+                adjunct = (Adjunct) adj;
                 //adjunct = Adjunct.class.cast(adj);
             }
         }
@@ -132,5 +130,6 @@ public class DroolsSessionCommonSerializable implements Serializable {
      * warnings.
      */
     private static class Adjunct extends HashMap<String, Object> {
+        private static final long serialVersionUID = 1L;
     }
 }
index 2448d17..24c04f7 100644 (file)
@@ -27,11 +27,8 @@ import static org.mockito.Mockito.when;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
-
 import org.mockito.Mockito;
-
 import org.onap.policy.drools.core.PolicySession;
-
 import org.powermock.api.mockito.PowerMockito;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
diff --git a/pom.xml b/pom.xml
index c39c421..cffa29b 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.onap.policy.parent</groupId>
         <artifactId>integration</artifactId>
-        <version>3.1.3</version>
+        <version>3.2.0-SNAPSHOT</version>
         <relativePath />
     </parent>