Merge "Fix bug with processing event list"
[dcaegen2/collectors/ves.git] / src / test / java / org / onap / dcae / common / ConfigProcessorAdapterTest.java
1 //
2 //        ================================================================================
3 //        Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
4 //        Copyright (c) 2018 Nokia. All rights reserved.
5 //        ================================================================================
6 //        Licensed under the Apache License, Version 2.0 (the "License");
7 //        you may not use this file except in compliance with the License.
8 //        You may obtain a copy of the License at
9 //
10 //        http://www.apache.org/licenses/LICENSE-2.0
11 //
12 //        Unless required by applicable law or agreed to in writing, software
13 //        distributed under the License is distributed on an "AS IS" BASIS,
14 //        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 //        See the License for the specific language governing permissions and
16 //        limitations under the License.
17 //        ============LICENSE_END=========================================================
18 //
19 //
20 package org.onap.dcae.common;
21
22 import static org.junit.Assert.assertTrue;
23 import static org.mockito.Mockito.times;
24 import static org.mockito.Mockito.verify;
25 import static org.mockito.Mockito.when;
26
27 import org.json.JSONObject;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.mockito.InjectMocks;
31 import org.mockito.Mock;
32 import org.mockito.junit.MockitoJUnitRunner;
33
34 @RunWith(MockitoJUnitRunner.class)
35 public class ConfigProcessorAdapterTest {
36
37     @Mock
38     private ConfigProcessors configProcessors;
39
40     @InjectMocks
41     private ConfigProcessorAdapter configProcessorAdapter;
42
43
44     @Test
45     public void shouldCallIsFilterMetOnAdapter() {
46         //given
47         JSONObject parameter = new JSONObject();
48         when(configProcessors.isFilterMet(parameter)).thenReturn(true);
49         //when
50         boolean actualReturn = configProcessorAdapter.isFilterMet(parameter);
51         //then
52         assertTrue(actualReturn);
53         verify(configProcessors, times(1)).isFilterMet(parameter);
54     }
55
56     @Test
57     public void shouldCallGivenMethodFromConfigProcessor() throws Exception {
58         JSONObject parameter = new JSONObject();
59         String exampleFunction = "concatenateValue";
60         //when
61         configProcessorAdapter.runConfigProcessorFunctionByName(exampleFunction, parameter);
62         //then
63         verify(configProcessors, times(1)).concatenateValue(parameter);
64     }
65
66 }