75065a396bc84b596b52d4391d0f9ec9eb6b7c89
[aai/model-loader.git] / src / test / java / org / onap / aai / modelloader / entity / model / NamedQueryArtifactParserTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *     http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  *
22  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23  */
24 package org.onap.aai.modelloader.entity.model;
25
26 import static org.junit.Assert.assertTrue;
27
28 import java.nio.file.Files;
29 import java.nio.file.Paths;
30 import java.util.List;
31
32 import org.junit.Test;
33 import org.onap.aai.modelloader.entity.Artifact;
34 import org.onap.aai.modelloader.entity.model.NamedQueryArtifact;
35 import org.onap.aai.modelloader.entity.model.NamedQueryArtifactParser;
36
37 public class NamedQueryArtifactParserTest {
38
39         @Test
40         public void testParseNamedQuery() throws Exception {
41                 final String MODEL_FILE = "src/test/resources/models/named-query-wan-connector.xml";
42
43                 try {
44                         byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE));
45
46                         NamedQueryArtifactParser parser = new NamedQueryArtifactParser();
47                         List<Artifact> modelList = parser.parse(xmlBytes, "test-artifact");
48
49                         assertTrue(modelList.size() == 1);
50
51                         NamedQueryArtifact model = (NamedQueryArtifact) modelList.get(0);
52                         System.out.println(model.toString());
53
54                         assertTrue(model.getNamedQueryUuid().equalsIgnoreCase("94cac189-8d88-4d63-a194-f44214e080ff"));
55                         assertTrue(model.getType().toString().equalsIgnoreCase("NAMED_QUERY"));
56                         assertTrue(model.getDependentModelIds().size() == 4);
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) {
62                         e.printStackTrace();
63                         assertTrue(false);
64                 }
65         }
66
67 }