aboutsummaryrefslogtreecommitdiffstats
path: root/utils-test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-06-17 13:16:43 -0400
committerJim Hahn <jrh3@att.com>2021-06-18 12:42:29 +0000
commitfc1412f6a14cf83e2a74f57bd990fbc3d8a7f277 (patch)
tree49a36defe913822ffe3e747f9f719e77ed5171b8 /utils-test
parent768d6c300ceba0b9b0325a8f1f2700aa374f57fe (diff)
Use lombok in policy-common utils-test
Issue-ID: POLICY-3394 Change-Id: I85504848afc268be7419654dc95ed555d870272c Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'utils-test')
-rw-r--r--utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java18
-rw-r--r--utils-test/src/main/java/org/onap/policy/common/utils/io/Serializer.java10
-rw-r--r--utils-test/src/main/java/org/onap/policy/common/utils/test/ToStringTester.java8
-rw-r--r--utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledExecutorService.java9
-rw-r--r--utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledFuture.java8
-rw-r--r--utils-test/src/main/java/org/onap/policy/common/utils/time/TestTime.java12
6 files changed, 19 insertions, 46 deletions
diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java b/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java
index 1357a51f..161e7c5c 100644
--- a/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java
+++ b/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java
@@ -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;
/**
@@ -77,19 +82,6 @@ public class GsonTestUtils {
}
/**
- * 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.
*
* @param object the object to be serialized
diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/io/Serializer.java b/utils-test/src/main/java/org/onap/policy/common/utils/io/Serializer.java
index 39266a66..f3e1418a 100644
--- a/utils-test/src/main/java/org/onap/policy/common/utils/io/Serializer.java
+++ b/utils-test/src/main/java/org/onap/policy/common/utils/io/Serializer.java
@@ -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 {
/**
@@ -37,13 +40,6 @@ public class Serializer {
private static Factory factory = new Factory();
/**
- * The constructor.
- */
- private Serializer() {
-
- }
-
- /**
* Serializes an object into a byte array.
*
* @param object the object to be serialized
diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/test/ToStringTester.java b/utils-test/src/main/java/org/onap/policy/common/utils/test/ToStringTester.java
index 3890ae95..ab09291c 100644
--- a/utils-test/src/main/java/org/onap/policy/common/utils/test/ToStringTester.java
+++ b/utils-test/src/main/java/org/onap/policy/common/utils/test/ToStringTester.java
@@ -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) {
diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledExecutorService.java b/utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledExecutorService.java
index 847b058e..71a24528 100644
--- a/utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledExecutorService.java
+++ b/utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledExecutorService.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.
@@ -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;
/**
@@ -80,11 +82,6 @@ public class PseudoScheduledExecutorService implements ScheduledExecutorService
}
@Override
- public boolean isShutdown() {
- return shutdown;
- }
-
- @Override
public boolean isTerminated() {
return isShutdown();
}
diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledFuture.java b/utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledFuture.java
index 6ce7bc04..34c756bb 100644
--- a/utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledFuture.java
+++ b/utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledFuture.java
@@ -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;
/**
@@ -82,11 +83,6 @@ class PseudoScheduledFuture<T> extends FutureTask<T> implements RunnableSchedule
}
@Override
- public boolean isPeriodic() {
- return periodic;
- }
-
- @Override
public void run() {
if (isPeriodic()) {
super.runAndReset();
diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/time/TestTime.java b/utils-test/src/main/java/org/onap/policy/common/utils/time/TestTime.java
index 420021f3..ace19160 100644
--- a/utils-test/src/main/java/org/onap/policy/common/utils/time/TestTime.java
+++ b/utils-test/src/main/java/org/onap/policy/common/utils/time/TestTime.java
@@ -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();