2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 Samsung. All rights reserved.
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.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.adapters.vevnfm.service;
23 import static org.mockito.Mockito.*;
24 import org.junit.Test;
25 import org.junit.runner.RunWith;
26 import org.mockito.InjectMocks;
27 import org.mockito.Mock;
28 import org.mockito.junit.MockitoJUnitRunner;
29 import org.onap.so.adapters.vevnfm.aai.AaiConnection;
30 import org.onap.so.adapters.vevnfm.exception.VeVnfmException;
32 @RunWith(MockitoJUnitRunner.class)
33 public class StartupServiceTest {
36 private AaiConnection aaiConnection;
39 private SubscriberService subscriberService;
42 private StartupService startupService;
45 public void testSuccess() throws Exception {
47 final String endpoint = "lh";
49 when(aaiConnection.receiveVnfm()).thenReturn(endpoint);
50 when(subscriberService.subscribe(endpoint)).thenReturn(true);
56 verify(aaiConnection, times(1)).receiveVnfm();
57 verify(subscriberService, times(1)).subscribe(endpoint);
60 @Test(expected = VeVnfmException.class)
61 public void testFailureAai() throws Exception {
63 when(aaiConnection.receiveVnfm()).thenReturn(null);
69 @Test(expected = VeVnfmException.class)
70 public void testFailureSubscriber() throws Exception {
72 final String endpoint = "lh";
74 when(aaiConnection.receiveVnfm()).thenReturn(endpoint);
75 when(subscriberService.subscribe(endpoint)).thenReturn(false);