Use lombok in policy-common utils-test 19/122019/3
authorJim Hahn <jrh3@att.com>
Thu, 17 Jun 2021 17:16:43 +0000 (13:16 -0400)
committerJim Hahn <jrh3@att.com>
Fri, 18 Jun 2021 12:42:29 +0000 (12:42 +0000)
Issue-ID: POLICY-3394
Change-Id: I85504848afc268be7419654dc95ed555d870272c
Signed-off-by: Jim Hahn <jrh3@att.com>
utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java
utils-test/src/main/java/org/onap/policy/common/utils/io/Serializer.java
utils-test/src/main/java/org/onap/policy/common/utils/test/ToStringTester.java
utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledExecutorService.java
utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledFuture.java
utils-test/src/main/java/org/onap/policy/common/utils/time/TestTime.java

index 1357a51..161e7c5 100644 (file)
@@ -37,6 +37,9 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map.Entry;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
 import org.apache.commons.jexl3.JexlBuilder;
 import org.apache.commons.jexl3.JexlContext;
 import org.apache.commons.jexl3.JexlEngine;
@@ -48,6 +51,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Utilities used to test encoding and decoding of Policy objects.
  */
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
 public class GsonTestUtils {
 
     private static final Logger logger = LoggerFactory.getLogger(GsonTestUtils.class);
@@ -65,6 +69,7 @@ public class GsonTestUtils {
     /**
      * Used to encode and decode an object via gson.
      */
+    @Getter
     private Gson gson;
 
     /**
@@ -76,19 +81,6 @@ public class GsonTestUtils {
         gson = other.gson;
     }
 
-    /**
-     * Constructs the object.
-     *
-     * @param gson used to encode via gson
-     */
-    protected GsonTestUtils(Gson gson) {
-        this.gson = gson;
-    }
-
-    public Gson getGson() {
-        return gson;
-    }
-
     /**
      * Serializes and then deserializes an object using gson.
      *
index 39266a6..f3e1418 100644 (file)
@@ -25,10 +25,13 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 
 /**
  * Utilities for testing serialization and de-serialization of objects.
  */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
 public class Serializer {
 
     /**
@@ -36,13 +39,6 @@ public class Serializer {
      */
     private static Factory factory = new Factory();
 
-    /**
-     * The constructor.
-     */
-    private Serializer() {
-
-    }
-
     /**
      * Serializes an object into a byte array.
      *
index 3890ae9..ab09291 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2018 Ericsson. All rights reserved.
- *  Modifications Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved.
  *  Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,6 +29,7 @@ import com.openpojo.reflection.PojoClass;
 import com.openpojo.validation.affirm.Affirm;
 import com.openpojo.validation.test.Tester;
 import com.openpojo.validation.utils.ValidationHelper;
+import lombok.AllArgsConstructor;
 import org.hamcrest.Matcher;
 
 
@@ -37,6 +38,7 @@ import org.hamcrest.Matcher;
  *
  * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
  */
+@AllArgsConstructor
 public class ToStringTester implements Tester {
 
     private final Matcher<?> matcher;
@@ -45,10 +47,6 @@ public class ToStringTester implements Tester {
         matcher = anything();
     }
 
-    public ToStringTester(final Matcher<?> matcher) {
-        this.matcher = matcher;
-    }
-
     @SuppressWarnings("unchecked")
     @Override
     public void run(final PojoClass pojoClass) {
index 847b058..71a2452 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@ import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
+import lombok.Getter;
 
 /**
  * Scheduled executor service that uses {@link TestTimeMulti} to execute its tasks. Note:
@@ -48,6 +49,7 @@ public class PseudoScheduledExecutorService implements ScheduledExecutorService
      * {@code True} if {@link #shutdown()} or {@link #shutdownNow()} has been called,
      * {@code false} otherwise.
      */
+    @Getter
     private boolean shutdown = false;
 
     /**
@@ -79,11 +81,6 @@ public class PseudoScheduledExecutorService implements ScheduledExecutorService
                         .collect(Collectors.toList());
     }
 
-    @Override
-    public boolean isShutdown() {
-        return shutdown;
-    }
-
     @Override
     public boolean isTerminated() {
         return isShutdown();
index 6ce7bc0..34c756b 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,6 +39,7 @@ class PseudoScheduledFuture<T> extends FutureTask<T> implements RunnableSchedule
     /**
      * {@code True} if this task is periodic, {@code false} otherwise.
      */
+    @Getter
     private final boolean periodic;
 
     /**
@@ -81,11 +82,6 @@ class PseudoScheduledFuture<T> extends FutureTask<T> implements RunnableSchedule
         return Long.compare(workItem.getDelay(), other.getDelay(TimeUnit.MILLISECONDS));
     }
 
-    @Override
-    public boolean isPeriodic() {
-        return periodic;
-    }
-
     @Override
     public void run() {
         if (isPeriodic()) {
index 420021f..ace1916 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Common Utils-Test
  * ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-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.
@@ -22,12 +22,14 @@ package org.onap.policy.common.utils.time;
 
 import java.util.Date;
 import java.util.concurrent.atomic.AtomicLong;
+import lombok.NoArgsConstructor;
 
 /**
  * "Current" time, when running junit tests. This is intended to be injected into classes
  * under test, to replace their {@link CurrentTime} objects. When {@link #sleep(long)} is
  * invoked, it simply advances the notion of "current" time and returns immediately.
  */
+@NoArgsConstructor
 public class TestTime extends CurrentTime {
 
     /**
@@ -35,14 +37,6 @@ public class TestTime extends CurrentTime {
      */
     private AtomicLong tcur = new AtomicLong(System.currentTimeMillis());
 
-    /**
-     *  Constructor.
-     *
-     */
-    public TestTime() {
-        super();
-    }
-
     @Override
     public long getMillis() {
         return tcur.get();