da77eefb495efe2b93ed2f1a3ceb1d44405f0149
[policy/distribution.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2018 Intel. 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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.distribution.reception.decoding.pdpx;
22
23 import static org.junit.Assert.assertEquals;
24
25 import org.junit.Test;
26
27 /**
28  * Class to perform unit test for Content 0f {@link Content}.
29  *
30  */
31 public class TestContent {
32
33     @Test
34     public void testContent() {
35         final String identity = "dummyidentity";
36         final String policyType = "optimization";
37
38         final Content content = new Content();
39         content.setIdentity(identity);
40         content.setPolicyType(policyType);
41
42         validateReport(identity, policyType, content);
43     }
44
45     private void validateReport(final String identity, final String policyType,
46             final Content content) {
47         assertEquals(0, content.getScope().size());
48         assertEquals(0, content.getGeography().size());
49         assertEquals(identity, content.getIdentity());
50         assertEquals(policyType, content.getPolicyType());
51         assertEquals(0, content.getPolicyScope().size());
52         content.getPolicyScope().add("vFW");
53         assertEquals(1, content.getPolicyScope().size());
54         content.getPolicyScope().remove("vFW");
55         assertEquals(0, content.getPolicyScope().size());
56         assertEquals(0, content.getServices().size());
57         content.getServices().add("vCPE");
58         assertEquals(1, content.getServices().size());
59         content.getServices().remove("vCPE");
60         assertEquals(0, content.getServices().size());
61         assertEquals(0, content.getFlavorFeatures().size());
62         FlavorFeature flavorFeature = new FlavorFeature();
63         content.getFlavorFeatures().add(flavorFeature);
64         assertEquals(1, content.getFlavorFeatures().size());
65         content.getFlavorFeatures().remove(flavorFeature);
66         assertEquals(0, content.getFlavorFeatures().size());
67         assertEquals(0, content.getResources().size());
68         content.getResources().add("vGW");
69         assertEquals(1, content.getResources().size());
70         content.getResources().remove("vGW");
71         assertEquals(0, content.getResources().size());
72     }
73 }