Merge "Removing so-monitoring module"
[so.git] / so-etsi-nfvo / so-etsi-nfvo-ns-lcm / so-etsi-nfvo-ns-lcm-database-service / src / test / java / org / onap / so / etsi / nfvo / ns / lcm / database / PojoClassesTests.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2020 Nordix Foundation.
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 package org.onap.so.etsi.nfvo.ns.lcm.database;
21
22 import javax.persistence.Entity;
23 import javax.persistence.Id;
24 import org.junit.Test;
25 import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob;
26 import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJobStatus;
27 import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst;
28 import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst;
29 import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc;
30 import org.onap.so.openpojo.rules.ToStringTester;
31 import com.openpojo.reflection.filters.FilterPackageInfo;
32 import com.openpojo.validation.Validator;
33 import com.openpojo.validation.ValidatorBuilder;
34 import com.openpojo.validation.test.impl.GetterTester;
35 import com.openpojo.validation.test.impl.SetterTester;
36 import nl.jqno.equalsverifier.EqualsVerifier;
37 import nl.jqno.equalsverifier.Warning;
38
39 /**
40  * @author Waqas Ikram (waqas.ikram@est.tech)
41  */
42 public class PojoClassesTests {
43
44     @Test
45     public void test_database_beans() throws ClassNotFoundException {
46
47         final Validator validator = ValidatorBuilder.create().with(new SetterTester()).with(new GetterTester())
48                 .with(new ToStringTester()).build();
49         validator.validate(NfvoNsInst.class.getPackageName(), new FilterPackageInfo());
50     }
51
52     @Test
53     public void test_database_nfvoJob_equalAndHashMethod() throws ClassNotFoundException {
54         EqualsVerifier.forClass(NfvoJob.class)
55                 .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
56                 .withPrefabValues(NfvoJobStatus.class, new NfvoJobStatus().nfvoJob(new NfvoJob()),
57                         new NfvoJobStatus().nfvoJob(new NfvoJob()))
58                 .withIgnoredAnnotations(Entity.class, Id.class).verify();
59     }
60
61     @Test
62     public void test_database_nfvoJobStatus_equalAndHashMethod() throws ClassNotFoundException {
63         EqualsVerifier.forClass(NfvoJobStatus.class)
64                 .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
65                 .withPrefabValues(NfvoJob.class, new NfvoJob(), new NfvoJob())
66                 .withIgnoredAnnotations(Entity.class, Id.class).verify();
67     }
68
69     @Test
70     public void test_database_nfvoNsInst_equalAndHashMethod() throws ClassNotFoundException {
71         EqualsVerifier.forClass(NfvoNsInst.class)
72                 .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
73                 .withPrefabValues(NfvoNfInst.class, new NfvoNfInst(), new NfvoNfInst())
74                 .withPrefabValues(NsLcmOpOcc.class, new NsLcmOpOcc(), new NsLcmOpOcc())
75                 .withIgnoredAnnotations(Entity.class, Id.class).verify();
76     }
77
78     @Test
79     public void test_database_nfvoNfInst_equalAndHashMethod() throws ClassNotFoundException {
80         EqualsVerifier.forClass(NfvoNfInst.class)
81                 .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
82                 .withPrefabValues(NfvoNsInst.class, new NfvoNsInst(), new NfvoNsInst())
83                 .withIgnoredAnnotations(Entity.class, Id.class).verify();
84     }
85
86     @Test
87     public void test_database_nsLcmOpOcc_equalAndHashMethod() throws ClassNotFoundException {
88         EqualsVerifier.forClass(NsLcmOpOcc.class)
89                 .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
90                 .withPrefabValues(NfvoNsInst.class, new NfvoNsInst(), new NfvoNsInst())
91                 .withIgnoredAnnotations(Entity.class, Id.class).verify();
92     }
93 }