* 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.
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;
@Override
public void putMessage(M message) throws APPCException {
- this.putMessage(message,-1,null);
+ this.putMessage(message, -1, null);
}
/**
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){
* 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.
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;
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
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);
+ }
}