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
10 // http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.onap.dcae.common;
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;
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;
34 @RunWith(MockitoJUnitRunner.class)
35 public class ConfigProcessorAdapterTest {
38 private ConfigProcessors configProcessors;
41 private ConfigProcessorAdapter configProcessorAdapter;
45 public void shouldCallIsFilterMetOnAdapter() {
47 JSONObject parameter = new JSONObject();
48 when(configProcessors.isFilterMet(parameter)).thenReturn(true);
50 boolean actualReturn = configProcessorAdapter.isFilterMet(parameter);
52 assertTrue(actualReturn);
53 verify(configProcessors, times(1)).isFilterMet(parameter);
57 public void shouldCallGivenMethodFromConfigProcessor() throws Exception {
58 JSONObject parameter = new JSONObject();
59 String exampleFunction = "concatenateValue";
61 configProcessorAdapter.runConfigProcessorFunctionByName(exampleFunction, parameter);
63 verify(configProcessors, times(1)).concatenateValue(parameter);