2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Nokia.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.vid.controller;
24 import static org.hamcrest.MatcherAssert.assertThat;
25 import static org.hamcrest.core.Is.is;
27 import com.google.common.collect.ImmutableList;
28 import com.google.common.collect.ImmutableMap;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.mockito.Mock;
34 import org.mockito.Mockito;
35 import org.mockito.junit.MockitoJUnitRunner;
36 import org.onap.vid.aai.AaiResponseTranslator;
37 import org.onap.vid.aai.util.AAIRestInterface;
38 import org.onap.vid.roles.RoleProvider;
39 import org.onap.vid.services.AaiService;
40 import org.onap.vid.utils.SystemPropertiesWrapper;
42 @RunWith(MockitoJUnitRunner.class)
43 public class AaiControllerTest {
46 private AaiService aaiService;
48 private AAIRestInterface aaiRestInterface;
50 private RoleProvider roleProvider;
52 private SystemPropertiesWrapper systemPropertiesWrapper;
54 private AaiController aaiController;
58 aaiController = new AaiController(aaiService, aaiRestInterface, roleProvider, systemPropertiesWrapper);
62 public void getPortMirroringConfigData_givenThreeIds_ReturnsThreeResults() {
64 final AaiResponseTranslator.PortMirroringConfigDataOk toBeReturnedForA = new AaiResponseTranslator.PortMirroringConfigDataOk("foobar");
65 final AaiResponseTranslator.PortMirroringConfigDataError toBeReturnedForB = new AaiResponseTranslator.PortMirroringConfigDataError("foo", "{ baz: qux }");
66 final AaiResponseTranslator.PortMirroringConfigDataOk toBeReturnedForC = new AaiResponseTranslator.PortMirroringConfigDataOk("corge");
69 .doReturn(toBeReturnedForA)
70 .doReturn(toBeReturnedForB)
71 .doReturn(toBeReturnedForC)
72 .when(aaiService).getPortMirroringConfigData(Mockito.anyString());
74 final Map<String, AaiResponseTranslator.PortMirroringConfigData> result = aaiController.getPortMirroringConfigsData(ImmutableList.of("a", "b", "c"));
76 assertThat(result, is(ImmutableMap.of(
77 "a", toBeReturnedForA,
78 "b", toBeReturnedForB,