2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
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.junit.Assert.assertTrue;
25 import java.nio.file.Files;
26 import java.nio.file.Paths;
28 import org.junit.Test;
29 import org.onap.aai.modelloader.entity.model.IModelParser;
30 import org.onap.aai.modelloader.entity.model.ModelArtifactParser;
31 import org.onap.aai.modelloader.entity.model.ModelParserFactory;
32 import org.onap.aai.modelloader.entity.model.ModelV8ArtifactParser;
33 import org.onap.aai.modelloader.entity.model.NamedQueryArtifactParser;
35 public class ModelParserFactoryTest {
38 public void testParserFactory() throws Exception {
39 final String MODEL_FILE_V8 = "src/test/resources/models/v8-wan-connector-model.xml";
40 final String MODEL_FILE_V9 = "src/test/resources/models/AAI-VL-resource-1.xml";
41 final String MODEL_FILE_NAMED_QUERY = "src/test/resources/models/named-query-wan-connector.xml";
45 byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE_V8));
46 IModelParser parser = ModelParserFactory.createModelParser(xmlBytes, "v8-wan-connector-model.xml");
47 assertTrue(parser instanceof ModelV8ArtifactParser);
49 xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE_V9));
50 parser = ModelParserFactory.createModelParser(xmlBytes, "AAI-VL-resource-1.xml");
51 assertTrue(parser instanceof ModelArtifactParser);
53 xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE_NAMED_QUERY));
54 parser = ModelParserFactory.createModelParser(xmlBytes, "named-query-wan-connector.xml");
55 assertTrue(parser instanceof NamedQueryArtifactParser);
56 } catch (Exception e) {