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.Service;
26 import org.onap.so.db.catalog.beans.ServiceArtifact;
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 QueryServiceArtifactTest {
35 public void ServiceArtifactTest() {
36 QueryServiceArtifact queryServiceArtifact = new QueryServiceArtifact(createList());
37 String jsonResult = queryServiceArtifact.JSON2(true, false);
38 Assertions.assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.serviceArtifact[0].name").get())
39 .contains("eMBB.zip");
42 private List<ServiceArtifact> createList() {
43 List<ServiceArtifact> artifacts = new ArrayList<>();
44 Service service = mock(Service.class);
45 ServiceArtifact artifact = new ServiceArtifact();
46 artifact.setService(service);
47 artifact.setArtifactUUID("b170dbeb-2954-4a4f-ad12-6bc84b3e089e");
48 artifact.setChecksum("ZWRkMGM3NzNjMmE3NzliYTFiZGNmZjVlMDE4OWEzMTA=");
49 artifact.setDescription("embbCn");
50 artifact.setType("OTHER");
51 artifact.setName("eMBB.zip");
52 artifact.setVersion("1");
53 artifacts.add(artifact);