832d59f89ada5d4393aaaf739129c029e2ea6605
[policy/drools-applications.git] / controlloop / common / model-impl / aai / src / test / java / org / onap / policy / aai / RelatedToPropertyTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * aai
4  * ================================================================================
5  * Copyright (C) 2017-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
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  * ============LICENSE_END=========================================================
19 */
20
21 package org.onap.policy.aai;
22
23 import static org.junit.Assert.assertEquals;
24
25 import java.io.File;
26 import java.nio.file.Files;
27 import org.junit.Test;
28 import org.onap.policy.aai.util.Serialization;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32 public class RelatedToPropertyTest {
33     private static final Logger logger = LoggerFactory.getLogger(RelatedToPropertyTest.class);
34
35     @Test
36     public void test() throws Exception {
37         // deserialize json and verify fields are populated properly
38         String json = new String(Files.readAllBytes(
39                         new File("src/test/resources/org/onap/policy/aai/RelatedToProperty.json").toPath()));
40
41         RelatedToProperty relatedToProperty = Serialization.gsonPretty.fromJson(json, RelatedToProperty.class);
42
43         assertEquals("generic-vnf.vnf-name", relatedToProperty.getPropertyKey());
44         assertEquals("vLoadBalancerMS-Vnf-0809-1", relatedToProperty.getPropertyValue());
45
46         logger.info(Serialization.gsonPretty.toJson(relatedToProperty));
47
48         // verify that setXxx methods work
49         relatedToProperty.setPropertyKey("a key");
50         relatedToProperty.setPropertyValue("a value");
51
52         assertEquals("a key", relatedToProperty.getPropertyKey());
53         assertEquals("a value", relatedToProperty.getPropertyValue());
54     }
55
56 }