Unit/SONAR/Checkstyle in ONAP-REST
[policy/engine.git] / ONAP-REST / src / test / java / org / onap / policy / rest / jpa / ConfigurationDataEntityTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-REST
4  * ================================================================================
5  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019 Nordix Foundation.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.rest.jpa;
23
24 import static org.hamcrest.CoreMatchers.is;
25 import static org.hamcrest.CoreMatchers.not;
26 import static org.junit.Assert.assertEquals;
27 import static org.junit.Assert.assertNull;
28 import static org.junit.Assert.assertThat;
29
30 import java.util.Date;
31
32 import org.junit.Test;
33
34 public class ConfigurationDataEntityTest {
35     @Test
36     public void testEquals() {
37         // Set up test data
38         String value = "testVal";
39         ConfigurationDataEntity entity = new ConfigurationDataEntity();
40         entity.prePersist();
41         ConfigurationDataEntity entity3 = new ConfigurationDataEntity();
42
43         // Test set and get
44         entity3.preUpdate();
45         entity3.setConfigBody(value);
46         assertEquals(value, entity3.getConfigBody());
47         entity3.setCreatedBy(value);
48         assertEquals(value, entity3.getCreatedBy());
49         entity3.setModifiedBy(value);
50         assertEquals(value, entity3.getModifiedBy());
51
52         Date date = new Date();
53         entity3.setModifiedDate(date);
54         assertEquals(date, entity3.getModifiedDate());
55         assertEquals(0, entity3.getVersion());
56         assertNull(entity3.getCreatedDate());
57         entity3.setDeleted(true);
58         assertEquals(true, entity3.isDeleted());
59         entity3.setDescription(value);
60         assertEquals(value, entity3.getDescription());
61         entity3.setConfigType(value);
62         assertEquals(value, entity3.getConfigType());
63         entity3.setConfigurationName(value);
64         assertEquals(value, entity3.getConfigurationName());
65         assertEquals(0, entity3.getConfigurationDataId());
66
67         // Test method combinations
68         assertEquals(false, entity.equals(null));
69         assertEquals(true, entity.equals(entity));
70         assertEquals(false, entity.equals(value));
71
72         ConfigurationDataEntity entity2 = new ConfigurationDataEntity();
73         assertEquals(false, entity.equals(entity2));
74         assertThat(entity.hashCode(), is(not(0)));
75     }
76 }