Replaced all tabs with spaces in java and pom.xml
[so.git] / adapters / mso-catalog-db-adapter / src / test / java / org / onap / so / adapters / catalogdb / catalogrest / QueryServiceCsarTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. 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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.so.adapters.catalogdb.catalogrest;
22
23 import static org.assertj.core.api.Assertions.assertThat;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.onap.so.db.catalog.beans.ToscaCsar;
27 import org.onap.so.jsonpath.JsonPathUtil;
28
29 public class QueryServiceCsarTest {
30
31     private static final String TOSCA_ARTIFACT_UUID = "artUuidTest";
32     private static final String TOSCA_NAME = "toscaNameTest";
33     private static final String TOSCA_VERSION = "v12";
34     private static final String TOSCA_ARTIFACT_CHECKSUM = "tosArtCheck";
35     private static final String TOSCA_URL = "tosUrl";
36     private static final String TOSCA_DESCRIPTION = "toscaDescr";
37
38     private QueryServiceCsar testedObject;
39
40     @Before
41     public void init() {
42         testedObject = new QueryServiceCsar(createToscaCsar());
43     }
44
45     @Test
46     public void convertToJson_successful() {
47         String jsonResult = testedObject.JSON2(true, true);
48         assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.artifactUUID")).contains(TOSCA_ARTIFACT_UUID);
49         assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.name")).contains(TOSCA_NAME);
50         assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.version")).contains(TOSCA_VERSION);
51         assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.artifactChecksum"))
52                 .contains(String.valueOf(TOSCA_ARTIFACT_CHECKSUM));
53         assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.url")).contains(TOSCA_URL);
54         assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.description")).contains(TOSCA_DESCRIPTION);
55     }
56
57     private ToscaCsar createToscaCsar() {
58         ToscaCsar toscaCsar = new ToscaCsar();
59         toscaCsar.setArtifactUUID(TOSCA_ARTIFACT_UUID);
60         toscaCsar.setName(TOSCA_NAME);
61         toscaCsar.setVersion(TOSCA_VERSION);
62         toscaCsar.setArtifactChecksum(TOSCA_ARTIFACT_CHECKSUM);
63         toscaCsar.setUrl(TOSCA_URL);
64         toscaCsar.setDescription(TOSCA_DESCRIPTION);
65         return toscaCsar;
66     }
67
68 }