7c820bb54d2e3568d25dcf3ef49009a53eab36ef
[aai/validation.git] /
1 /*
2  * ============LICENSE_START===================================================
3  * Copyright (c) 2018 Amdocs
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  * ============LICENSE_END=====================================================
17  */
18 package org.onap.aai.validation.modeldriven.configuration.mapping;
19
20 import static org.hamcrest.Matchers.is;
21 import static org.junit.Assert.assertThat;
22 import static org.junit.Assert.assertTrue;
23
24 import java.util.ArrayList;
25 import java.util.List;
26 import org.junit.Test;
27 import org.onap.aai.validation.modeldriven.configuration.mapping.Filter;
28 import org.onap.aai.validation.modeldriven.configuration.mapping.ModelInstanceMapper;
29 import org.onap.aai.validation.modeldriven.configuration.mapping.ValueConfiguration;
30 import org.onap.aai.validation.modeldriven.configuration.mapping.ModelInstanceMapper.MappingType;
31
32 public class TestModelInstanceMapper {
33
34     static {
35         System.setProperty("APP_HOME", ".");
36     }
37
38     @Test
39     public void testAllMethodsToImproveCodeCoverage() {
40         List<String> valid = new ArrayList<>();
41         valid.add("string1");
42         Filter filter = new Filter();
43         filter.setPath("testPath");
44         filter.setValid(valid);
45
46         ValueConfiguration valueConf1 = new ValueConfiguration();
47         valueConf1.setFilter(filter);
48         valueConf1.setId("id");
49         valueConf1.setOrigin("testOrigin");
50         valueConf1.setRoot("testRoot");
51         valueConf1.setValue("testValue");
52
53         ModelInstanceMapper mapper1 = new ModelInstanceMapper();
54         mapper1.setInstance(valueConf1);
55         mapper1.setMappingType(MappingType.ATTRIBUTE.toString());
56         mapper1.setModel(valueConf1);
57
58         ModelInstanceMapper mapper2 = new ModelInstanceMapper();
59         mapper2.setInstance(valueConf1);
60         mapper2.setMappingType(MappingType.ATTRIBUTE.toString());
61         mapper2.setModel(valueConf1);
62
63         assertThat(mapper1.hashCode(), is(mapper2.hashCode()));
64         assertThat(mapper1.getInstance(), is(mapper2.getInstance()));
65         assertThat(mapper1.getMappingType(), is(mapper2.getMappingType()));
66         assertThat(mapper1.getModel(), is(mapper2.getModel()));
67         assertThat(mapper1.toString(), is(mapper2.toString()));
68         assertTrue(mapper1.equals(mapper2));
69     }
70
71 }