a329a3ee3ff60673c1d6397569870f2532cca289
[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 resources = "dummyresource";
36         final String identity = "dummyidentity";
37         final String policyType = "optimization";
38
39         final Content content = new Content();
40         content.setResources(resources);
41         content.setIdentity(identity);
42         content.setPolicyType(policyType);
43
44         validateReport(resources, identity, policyType,content);
45     }
46
47     private void validateReport(final String resources, final String identity, final String policyType, 
48                                 final Content content) {
49         assertEquals(resources, content.getResources());
50         assertEquals(identity, content.getIdentity());
51         assertEquals(policyType, content.getPolicyType());
52         assertEquals(0, content.getPolicyScope().size());
53         content.getPolicyScope().add("vFW");
54         assertEquals(1, content.getPolicyScope().size());
55         content.getPolicyScope().remove("vFW");
56         assertEquals(0, content.getPolicyScope().size());
57         assertEquals(0, content.getFlavorFeatures().size());
58         FlavorFeature flavorFeature = new FlavorFeature();
59         content.getFlavorFeatures().add(flavorFeature);
60         assertEquals(1, content.getFlavorFeatures().size());
61         content.getFlavorFeatures().remove(flavorFeature);
62         assertEquals(0, content.getFlavorFeatures().size());
63     }
64 }