2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.tools.model.generator;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNull;
26 import org.junit.Test;
27 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
28 import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
29 import org.onap.policy.apex.model.policymodel.concepts.AxState;
30 import org.onap.policy.apex.testsuites.integration.common.model.SampleDomainModelFactory;
33 * Test the Key Info Getter.
35 public class KeyInfoGetterTest {
38 public void testKeyInfoGetter() {
39 AxPolicyModel sampleModel = new SampleDomainModelFactory().getSamplePolicyModel("JAVASCRIPT");
41 KeyInfoGetter kiGetter = new KeyInfoGetter(sampleModel);
43 assertNull(kiGetter.getName(null));
44 assertEquals("SamplePolicyModelJAVASCRIPT", kiGetter.getName(sampleModel.getKey()));
46 assertNull(kiGetter.getUuid(null));
47 assertNull(kiGetter.getUuid(new AxArtifactKey()));
48 assertEquals(36, kiGetter.getUuid(sampleModel.getKey()).length());
50 assertNull(kiGetter.getDesc(null));
51 assertNull(kiGetter.getDesc(new AxArtifactKey()));
52 assertEquals("Generated description for concept referred to by key " + "\"SamplePolicyModelJAVASCRIPT:0.0.1\"",
53 kiGetter.getDesc(sampleModel.getKey()));
55 assertNull(kiGetter.getVersion(null));
56 assertEquals("0.0.1", kiGetter.getVersion(sampleModel.getKey()));
58 AxState matchState = sampleModel.getPolicies().get("Policy0").getStateMap().get("Match");
60 assertNull(kiGetter.getLName(null));
61 assertEquals("Match", kiGetter.getLName(matchState.getKey()));
63 assertNull(kiGetter.getPName(null));
64 assertEquals("Policy0", kiGetter.getPName(matchState.getKey()));
66 assertNull(kiGetter.getPVersion(null));
67 assertEquals("0.0.1", kiGetter.getPVersion(matchState.getKey()));
69 assertNull(kiGetter.getPlName(null));
70 assertEquals("NULL", kiGetter.getPlName(matchState.getKey()));