2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.onap.policy.rest.util;
22 import static org.junit.Assert.*;
25 import java.util.ArrayList;
26 import java.util.Arrays;
27 import java.util.HashMap;
28 import java.util.List;
31 import org.apache.commons.lang.StringUtils;
32 import org.junit.Test;
33 import org.onap.policy.rest.util.MSModelUtils.MODEL_TYPE;
35 public class MSModelUtilsTest {
38 public void testMSModelUtils(){
39 HashMap<String, MSAttributeObject> classMap = new HashMap<>();
40 ClassLoader classLoader = getClass().getClassLoader();
41 File file = new File(classLoader.getResource("DKaTVESPolicy-v1802.xmi").getFile());
42 MSModelUtils utils = new MSModelUtils("http://org.onap", "http://org.onap.policy");
43 Map<String, MSAttributeObject> tempMap = utils.processEpackage(file.getAbsolutePath().toString(), MODEL_TYPE.XMI);
44 classMap.putAll(tempMap);
45 MSAttributeObject mainClass = classMap.get("StandardDeviationThreshold");
46 String dependTemp = StringUtils.replaceEach(mainClass.getDependency(), new String[]{"[", "]", " "}, new String[]{"", "", ""});
47 List<String> dependency = new ArrayList<String>(Arrays.asList(dependTemp.split(",")));
48 dependency = utils.getFullDependencyList(dependency, classMap);
49 String subAttribute = utils.createSubAttributes(dependency, classMap, "StandardDeviationThreshold");
50 assertTrue(subAttribute != null);