aboutsummaryrefslogtreecommitdiffstats
path: root/utils-test
diff options
context:
space:
mode:
Diffstat (limited to 'utils-test')
-rw-r--r--utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java9
-rw-r--r--utils-test/src/test/java/org/onap/policy/common/utils/time/PseudoScheduledExecutorServiceTest.java12
-rw-r--r--utils-test/src/test/java/org/onap/policy/common/utils/time/PseudoTimerTest.java16
3 files changed, 22 insertions, 15 deletions
diff --git a/utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java b/utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java
index 11ee63c0..f16764c9 100644
--- a/utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java
+++ b/utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java
@@ -76,10 +76,11 @@ public class GsonTestUtilsTest {
utils.compareGson(data, GsonTestUtilsTest.class);
// file not found
- assertThatThrownBy(() -> utils.compareGson(data,
- new File(GsonTestUtilsTest.class.getSimpleName() + "-NotFound.json")))
- .isInstanceOf(JsonParseException.class)
- .hasCauseInstanceOf(FileNotFoundException.class);
+ File file = new File(GsonTestUtilsTest.class.getSimpleName() + "-NotFound.json");
+
+ assertThatThrownBy(() -> utils.compareGson(data, file))
+ .isInstanceOf(JsonParseException.class)
+ .hasCauseInstanceOf(FileNotFoundException.class);
// force I/O error while reading file
GsonTestUtils utils2 = new GsonTestUtils() {
diff --git a/utils-test/src/test/java/org/onap/policy/common/utils/time/PseudoScheduledExecutorServiceTest.java b/utils-test/src/test/java/org/onap/policy/common/utils/time/PseudoScheduledExecutorServiceTest.java
index 70820c44..745e989f 100644
--- a/utils-test/src/test/java/org/onap/policy/common/utils/time/PseudoScheduledExecutorServiceTest.java
+++ b/utils-test/src/test/java/org/onap/policy/common/utils/time/PseudoScheduledExecutorServiceTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Collections;
+import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture;
@@ -37,6 +38,7 @@ import org.junit.Test;
public class PseudoScheduledExecutorServiceTest {
private static final long DELAY_MS = 100L;
private static final long PERIOD_MS = 200L;
+ private static final List<Callable<Object>> EMPTY_CALLABLES = Collections.emptyList();
private int ran;
private int called;
@@ -135,25 +137,25 @@ public class PseudoScheduledExecutorServiceTest {
@Test
public void testInvokeAllCollectionOfQextendsCallableOfT() {
- assertThatThrownBy(() -> svc.invokeAll(Collections.emptyList()))
+ assertThatThrownBy(() -> svc.invokeAll(EMPTY_CALLABLES))
.isInstanceOf(UnsupportedOperationException.class);
}
@Test
public void testInvokeAllCollectionOfQextendsCallableOfTLongTimeUnit() {
- assertThatThrownBy(() -> svc.invokeAll(Collections.emptyList(), 1, TimeUnit.MILLISECONDS))
+ assertThatThrownBy(() -> svc.invokeAll(EMPTY_CALLABLES, 1, TimeUnit.MILLISECONDS))
.isInstanceOf(UnsupportedOperationException.class);
}
@Test
public void testInvokeAnyCollectionOfQextendsCallableOfT() {
- assertThatThrownBy(() -> svc.invokeAny(Collections.emptyList()))
+ assertThatThrownBy(() -> svc.invokeAny(EMPTY_CALLABLES))
.isInstanceOf(UnsupportedOperationException.class);
}
@Test
public void testInvokeAnyCollectionOfQextendsCallableOfTLongTimeUnit() {
- assertThatThrownBy(() -> svc.invokeAny(Collections.emptyList(), 1, TimeUnit.MILLISECONDS))
+ assertThatThrownBy(() -> svc.invokeAny(EMPTY_CALLABLES, 1, TimeUnit.MILLISECONDS))
.isInstanceOf(UnsupportedOperationException.class);
}
diff --git a/utils-test/src/test/java/org/onap/policy/common/utils/time/PseudoTimerTest.java b/utils-test/src/test/java/org/onap/policy/common/utils/time/PseudoTimerTest.java
index 49710538..d7316c1f 100644
--- a/utils-test/src/test/java/org/onap/policy/common/utils/time/PseudoTimerTest.java
+++ b/utils-test/src/test/java/org/onap/policy/common/utils/time/PseudoTimerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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.
@@ -83,8 +83,9 @@ public class PseudoTimerTest {
@Test
public void testScheduleTimerTaskDate() {
- assertThatThrownBy(() -> timer.schedule(new MyTask(), new Date()))
- .isInstanceOf(UnsupportedOperationException.class);
+ MyTask task = new MyTask();
+ Date curdate = new Date();
+ assertThatThrownBy(() -> timer.schedule(task, curdate)).isInstanceOf(UnsupportedOperationException.class);
}
@Test
@@ -105,8 +106,9 @@ public class PseudoTimerTest {
@Test
public void testScheduleTimerTaskDateLong() {
- assertThatThrownBy(() -> timer.schedule(new MyTask(), new Date(), 1L))
- .isInstanceOf(UnsupportedOperationException.class);
+ MyTask task = new MyTask();
+ Date curdate = new Date();
+ assertThatThrownBy(() -> timer.schedule(task, curdate, 1L)).isInstanceOf(UnsupportedOperationException.class);
}
@Test
@@ -127,7 +129,9 @@ public class PseudoTimerTest {
@Test
public void testScheduleAtFixedRateTimerTaskDateLong() {
- assertThatThrownBy(() -> timer.scheduleAtFixedRate(new MyTask(), new Date(), 1L))
+ MyTask task = new MyTask();
+ Date curdate = new Date();
+ assertThatThrownBy(() -> timer.scheduleAtFixedRate(task, curdate, 1L))
.isInstanceOf(UnsupportedOperationException.class);
}