aboutsummaryrefslogtreecommitdiffstats
path: root/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2019-02-06 18:31:58 +0000
committerPatrick Brady <patrick.brady@att.com>2019-02-06 22:44:48 +0000
commitcc48824b82792d240fb62862f167a0d991fa5eab (patch)
tree693a566f8159e5f1b218ad4e3480a5de76f80f6f /appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib
parent830828d1ebb01bba58a3e997b4c2418a214cdfe9 (diff)
Improve testing in ExecutionQueueServiceImpl
Increased coverage to 100% Issue-ID: APPC-1396 Change-Id: Ie9c2bd14d83f43e4fc41dacfd45a596ec46b1d95 Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib')
-rw-r--r--appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/onap/appc/executionqueue/impl/ExecutionQueueServiceImpl.java7
-rw-r--r--appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/test/java/org/onap/appc/executionqueue/TestExecutionQueueService.java24
2 files changed, 23 insertions, 8 deletions
diff --git a/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/onap/appc/executionqueue/impl/ExecutionQueueServiceImpl.java b/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/onap/appc/executionqueue/impl/ExecutionQueueServiceImpl.java
index d8bc82d2b..1c98980e8 100644
--- a/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/onap/appc/executionqueue/impl/ExecutionQueueServiceImpl.java
+++ b/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/onap/appc/executionqueue/impl/ExecutionQueueServiceImpl.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +29,6 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import org.onap.appc.exceptions.APPCException;
import org.onap.appc.executionqueue.ExecutionQueueService;
-import org.onap.appc.executionqueue.MessageExpirationListener;
import org.onap.appc.executionqueue.impl.object.QueueMessage;
import java.util.Calendar;
@@ -46,7 +47,7 @@ public class ExecutionQueueServiceImpl<M extends Runnable> implements ExecutionQ
@Override
public void putMessage(M message) throws APPCException {
- this.putMessage(message,-1,null);
+ this.putMessage(message, -1, null);
}
/**
@@ -62,7 +63,7 @@ public class ExecutionQueueServiceImpl<M extends Runnable> implements ExecutionQ
QueueMessage queueMessage;
try {
- Date expirationTime = calculateExpirationTime(timeout,unit);
+ Date expirationTime = calculateExpirationTime(timeout, unit);
queueMessage = new QueueMessage(message,expirationTime);
boolean enqueueTask = queueManager.enqueueTask(queueMessage);
if(!enqueueTask){
diff --git a/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/test/java/org/onap/appc/executionqueue/TestExecutionQueueService.java b/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/test/java/org/onap/appc/executionqueue/TestExecutionQueueService.java
index f09809258..8d2549dce 100644
--- a/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/test/java/org/onap/appc/executionqueue/TestExecutionQueueService.java
+++ b/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/test/java/org/onap/appc/executionqueue/TestExecutionQueueService.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,9 +25,14 @@
package org.onap.appc.executionqueue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.times;
+import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mockito;
@@ -36,14 +43,12 @@ import org.onap.appc.executionqueue.impl.ExecutionQueueServiceImpl;
import org.onap.appc.executionqueue.impl.QueueManager;
import org.powermock.modules.junit4.PowerMockRunner;
-import java.util.concurrent.TimeUnit;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.times;
-
@RunWith(PowerMockRunner.class)
public class TestExecutionQueueService {
+ @Rule
+ public ExpectedException expectedEx = ExpectedException.none();
+
@InjectMocks
ExecutionQueueServiceImpl service;
@Spy
@@ -66,4 +71,13 @@ public class TestExecutionQueueService {
Assert.fail(e.toString());
}
}
+
+ @Test
+ public void testPutMessageExceptionFlow() throws APPCException {
+ QueueManager queueManager = Mockito.mock(QueueManager.class);
+ Mockito.when(queueManager.enqueueTask(Mockito.any())).thenReturn(false);
+ service.setQueueManager(queueManager);
+ expectedEx.expect(APPCException.class);
+ service.putMessage(new Thread(), 1, TimeUnit.MILLISECONDS);
+ }
}