2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (c) 2019, CMCC Technologies Co., Ltd.
6 * Copyright (c) 2022, Samsung Electronics. All rights reserved.
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=========================================================
21 package org.onap.so.adapters.catalogdb.catalogrest;
23 import org.assertj.core.api.Assertions;
24 import org.junit.Test;
25 import org.onap.so.db.catalog.beans.ServiceInfo;
26 import org.onap.so.db.catalog.beans.Service;
27 import org.onap.so.jsonpath.JsonPathUtil;
28 import java.util.ArrayList;
29 import java.util.List;
30 import static org.mockito.Mockito.mock;
32 public class QueryServiceInfoTest {
35 public void serviceInfoTest() {
36 QueryServiceInfo queryServiceInfo = new QueryServiceInfo(createList());
37 String jsonResult = queryServiceInfo.JSON2(true, false);
38 String serviceInfo = jsonResult.substring(jsonResult.indexOf("{"), jsonResult.length());
39 Assertions.assertThat(JsonPathUtil.getInstance().locateResult(serviceInfo, "$.id").get()).contains("1");
42 private List<ServiceInfo> createList() {
43 Service service = mock(Service.class);
44 ServiceInfo serviceInfo = new ServiceInfo();
46 serviceInfo.setService(service);
47 serviceInfo.setServiceInput(null);
48 serviceInfo.setServiceProperties(null);
50 List<ServiceInfo> serviceInfos = new ArrayList<>();
51 serviceInfos.add(serviceInfo);