2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 European Software Marketing Ltd.
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.aai.modelloader.entity.model;
23 import static org.hamcrest.CoreMatchers.not;
24 import static org.hamcrest.MatcherAssert.assertThat;
25 import static org.hamcrest.Matchers.isEmptyString;
26 import static org.junit.jupiter.api.Assertions.assertEquals;
27 import static org.junit.jupiter.api.Assertions.assertTrue;
28 import static org.junit.jupiter.api.Assertions.fail;
30 import java.nio.file.Files;
31 import java.nio.file.Paths;
32 import java.util.List;
34 import org.junit.jupiter.api.Test;
35 import org.onap.aai.modelloader.entity.Artifact;
37 public class TestNamedQueryArtifactParser {
39 private static final String MODEL_FILE = "src/test/resources/models/named-query-wan-connector.xml";
42 public void testParseNamedQuery() throws Exception {
44 String fileString = new String(Files.readAllBytes(Paths.get(MODEL_FILE)));
46 NamedQueryArtifactParser parser = new NamedQueryArtifactParser();
47 List<Artifact> modelList = parser.parse(fileString, "test-artifact");
49 assertEquals(1, modelList.size());
51 NamedQueryArtifact model = (NamedQueryArtifact) modelList.get(0);
53 assertThat(model.toString(), not(isEmptyString()));
54 assertTrue(model.getNamedQueryUuid().equalsIgnoreCase("94cac189-8d88-4d63-a194-f44214e080ff"));
55 assertTrue(model.getType().toString().equalsIgnoreCase("NAMED_QUERY"));
56 assertEquals(4, model.getDependentModelIds().size());
57 assertTrue(model.getDependentModelIds().contains("d09dd9da-0148-46cd-a947-591afc844d24"));
58 assertTrue(model.getDependentModelIds().contains("997fc7-fca1-451f-b953-9a1e6197b4d6"));
59 assertTrue(model.getDependentModelIds().contains("897df7ea-8938-42b0-bc57-46e913a4d93b"));
60 assertTrue(model.getDependentModelIds().contains("f2b24d95-c582-48d5-b2d6-c5b3a94ce812"));
61 } catch (Exception e) {