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.junit.Assert.assertNull;
24 import static org.mockito.ArgumentMatchers.eq;
25 import static org.mockito.Mockito.verify;
26 import static org.mockito.Mockito.when;
27 import java.util.Collections;
28 import java.util.List;
29 import org.junit.Test;
30 import org.junit.runner.RunWith;
31 import org.mockito.InjectMocks;
32 import org.mockito.Mock;
33 import org.mockito.junit.MockitoJUnitRunner;
34 import org.onap.aai.domain.yang.EsrSystemInfo;
36 @RunWith(MockitoJUnitRunner.class)
37 public class SubscriptionSchedulerTest {
39 private static final String URL = "url";
40 private static final String ID = "id044";
43 private SubscriberService subscriberService;
46 private SubscriptionScheduler subscriptionScheduler;
49 public void testFullScenario() throws Exception {
51 final EsrSystemInfo info = new EsrSystemInfo();
52 info.setServiceUrl(URL);
53 final List<EsrSystemInfo> infos = Collections.singletonList(info);
55 when(subscriberService.subscribe(eq(info))).thenReturn(ID);
56 when(subscriberService.checkSubscription(eq(info), eq(ID))).thenReturn(false);
59 subscriptionScheduler.setInfos(infos);
60 subscriptionScheduler.subscribeTask();
61 subscriptionScheduler.checkSubscribeTask();
64 verify(subscriberService).subscribe(info);
65 verify(subscriberService).checkSubscription(info, ID);
67 assertNull(subscriptionScheduler.getEsrIds().get(0).getId());