b1e2d5cbde8cdc7c6754afb17dd49e9cfe4d81b5
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  *  Modifications Copyright (C) 2020 Nordix Foundation.
5  *  Modifications Copyright (C) 2021 Bell Canada. 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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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  *
19  * SPDX-License-Identifier: Apache-2.0
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.policy.apex.model.policymodel.handling;
24
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotNull;
27
28 import org.junit.Test;
29 import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
30
31 public class PolicyAnalyserTest {
32     @Test
33     public void test() {
34         final AxPolicyModel apexModel = new SupportApexPolicyModelCreator().getModel();
35
36         final PolicyAnalyser policyAnalyser = new PolicyAnalyser();
37         final PolicyAnalysisResult analysisResult = policyAnalyser.analyse(apexModel);
38
39         assertEquals(EXPECTED_ANALYSIS_RESULT, analysisResult.toString());
40
41         assertNotNull(analysisResult.getUsedContextAlbums());
42         assertNotNull(analysisResult.getUsedContextSchemas());
43         assertNotNull(analysisResult.getUsedEvents());
44         assertNotNull(analysisResult.getUsedTasks());
45         assertNotNull(analysisResult.getUnusedContextAlbums());
46         assertNotNull(analysisResult.getUnusedContextSchemas());
47         assertNotNull(analysisResult.getUnusedEvents());
48         assertNotNull(analysisResult.getUnusedTasks());
49     }
50
51     private static final String EXPECTED_ANALYSIS_RESULT = "" + "Context Schema usage\n" + " MapType:0.0.1\n"
52             + "  contextAlbum0:0.0.1\n" + " StringType:0.0.1\n" + "  contextAlbum1:0.0.1\n"
53             + " eventContextItem0:0.0.1\n" + "  inEvent:0.0.1\n" + "  outEvent0:0.0.1\n" + "  outEvent1:0.0.1\n"
54             + " eventContextItem1:0.0.1\n" + "  inEvent:0.0.1\n" + "  outEvent0:0.0.1\n"
55             + "  outEvent1:0.0.1\n" + "Context Album usage\n" + " contextAlbum0:0.0.1\n"
56             + "  task:0.0.1\n" + "  policy:0.0.1:NULL:state\n" + " contextAlbum1:0.0.1\n" + "  task:0.0.1\n"
57             + "  policy:0.0.1:NULL:state\n" + "Event usage\n" + " inEvent:0.0.1\n" + "  policy:0.0.1:NULL:state\n"
58             + " outEvent0:0.0.1\n" + "  policy:0.0.1:NULL:state\n" + " outEvent1:0.0.1 (unused)\n" + "Task usage\n"
59             + " task:0.0.1\n" + "  policy:0.0.1:NULL:state\n";
60 }