2 * Copyright (C) 2020 Huawei, Inc. and others. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.usecaseui.server.service.lcm.impl;
18 import okhttp3.MediaType;
19 import okhttp3.ResponseBody;
21 import okio.BufferedSource;
22 import org.jetbrains.annotations.NotNull;
23 import org.jetbrains.annotations.Nullable;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
28 import static org.mockito.ArgumentMatchers.eq;
29 import static org.mockito.Mockito.mock;
30 import static org.mockito.Mockito.when;
31 import static org.onap.usecaseui.server.util.CallStub.failedCall;
32 import static org.onap.usecaseui.server.util.CallStub.successfulCall;
34 public class SotnServiceQryServiceImplTest {
36 AAIService aaiService = mock(AAIService.class);
38 SotnServiceQryServiceImpl sotnServiceQryService = new SotnServiceQryServiceImpl(aaiService);
42 public void before() throws Exception {
43 result= new ResponseBody() {
46 public MediaType contentType() {
47 return MediaType.parse("application/json; charset=utf-8");
51 public long contentLength() {
57 public BufferedSource source() {
64 public void getServiceInstancesTest() {
65 when(aaiService.listServiceInstances(eq("SOTN-CUST"),eq("SOTN"))).thenReturn(successfulCall(result));
66 sotnServiceQryService.getServiceInstances("SOTN");
70 public void getServiceInstancesWithThrowException() {
71 when(aaiService.listServiceInstances(eq("SOTN-CUST"),eq("SOTN"))).thenReturn(failedCall("aai is not exist!"));
72 sotnServiceQryService.getServiceInstances("SOTN");