2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (c) 2019 IBM.
6 * ===================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * ============LICENSE_END=============================================
20 * ====================================================================
22 package org.onap.appc.adapter.message;
24 import static org.junit.Assert.assertEquals;
26 import java.util.ArrayList;
27 import java.util.List;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 import org.mockito.Mock;
33 import org.mockito.Mockito;
34 import org.mockito.runners.MockitoJUnitRunner;
36 @RunWith(MockitoJUnitRunner.class)
37 public class TestCallableConsumer {
39 CallableConsumer callableConsumer;
42 private Consumer consumer;
44 private List<String> list;
45 private int waitMs = 15000;
46 private int limit = 1000;
47 private int maxLife = 25000;
51 list = new ArrayList<String>();
52 callableConsumer = new CallableConsumer(consumer, waitMs, limit);
56 public void testCallableConsumer() {
57 CallableConsumer callableConsumer = new CallableConsumer(consumer);
58 Mockito.when(consumer.fetch()).thenReturn(list);
59 assertEquals(list, callableConsumer.call());
63 public void testCall() {
64 Mockito.when(consumer.fetch()).thenReturn(list);
65 assertEquals(list, callableConsumer.call());
69 public void testGetMaxLife() {
70 assertEquals(maxLife, callableConsumer.getMaxLife());