diff options
author | waqas.ikram <waqas.ikram@est.tech> | 2020-10-02 13:21:17 +0100 |
---|---|---|
committer | waqas.ikram <waqas.ikram@est.tech> | 2020-10-02 14:59:52 +0100 |
commit | 1ae0b7fb1fd12587f24b19cabfcfc93e2204204e (patch) | |
tree | 9061f59e03d07d9f0c4e4e6730c4394479273bc4 /so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test | |
parent | 23312bd92a1bc9a64b26602a2798c05005187d0f (diff) |
Increasing code coverage ns-lcm-database-service
Change-Id: Iee314c28e9f65e5bcac542b390df0d8b05ed2e31
Issue-ID: SO-2867
Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test')
2 files changed, 94 insertions, 1 deletions
diff --git a/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/DatabaseServiceProviderTest.java b/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/DatabaseServiceProviderTest.java index 8108749d48..8070036791 100644 --- a/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/DatabaseServiceProviderTest.java +++ b/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/DatabaseServiceProviderTest.java @@ -133,7 +133,7 @@ public class DatabaseServiceProviderTest { .status(State.NOT_INSTANTIATED).createTime(CURRENT_DATE_TIME).lastUpdateTime(CURRENT_DATE_TIME); databaseServiceProvider.saveNfvoNfInst(nfInst); - final Optional<NfvoNfInst> actual = databaseServiceProvider.getNfvoNfInstByNfInstId(nfInst.getNfInstId()); + final Optional<NfvoNfInst> actual = databaseServiceProvider.getNfvoNfInst(nfInst.getNfInstId()); final NfvoNfInst actualNfvoNfInst = actual.get(); assertEquals(nsInst.getNsInstId(), actualNfvoNfInst.getNsInst().getNsInstId()); assertEquals(nfInst.getNfInstId(), actualNfvoNfInst.getNfInstId()); diff --git a/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 b/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 new file mode 100644 index 0000000000..5f033a2438 --- /dev/null +++ b/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 @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.etsi.nfvo.ns.lcm.database; + +import javax.persistence.Entity; +import javax.persistence.Id; +import org.junit.Test; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJob; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoJobStatus; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNfInst; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NfvoNsInst; +import org.onap.so.etsi.nfvo.ns.lcm.database.beans.NsLcmOpOcc; +import org.onap.so.openpojo.rules.ToStringTester; +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; +import nl.jqno.equalsverifier.EqualsVerifier; +import nl.jqno.equalsverifier.Warning; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + */ +public class PojoClassesTests { + + @Test + public void test_database_beans() throws ClassNotFoundException { + + final Validator validator = ValidatorBuilder.create().with(new SetterTester()).with(new GetterTester()) + .with(new ToStringTester()).build(); + validator.validate(NfvoNsInst.class.getPackageName(), new FilterPackageInfo()); + } + + @Test + public void test_database_nfvoJob_equalAndHashMethod() throws ClassNotFoundException { + EqualsVerifier.forClass(NfvoJob.class) + .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT) + .withPrefabValues(NfvoJobStatus.class, new NfvoJobStatus().nfvoJob(new NfvoJob()), + new NfvoJobStatus().nfvoJob(new NfvoJob())) + .withIgnoredAnnotations(Entity.class, Id.class).verify(); + } + + @Test + public void test_database_nfvoJobStatus_equalAndHashMethod() throws ClassNotFoundException { + EqualsVerifier.forClass(NfvoJobStatus.class) + .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT) + .withPrefabValues(NfvoJob.class, new NfvoJob(), new NfvoJob()) + .withIgnoredAnnotations(Entity.class, Id.class).verify(); + } + + @Test + public void test_database_nfvoNsInst_equalAndHashMethod() throws ClassNotFoundException { + EqualsVerifier.forClass(NfvoNsInst.class) + .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT) + .withPrefabValues(NfvoNfInst.class, new NfvoNfInst(), new NfvoNfInst()) + .withPrefabValues(NsLcmOpOcc.class, new NsLcmOpOcc(), new NsLcmOpOcc()) + .withIgnoredAnnotations(Entity.class, Id.class).verify(); + } + + @Test + public void test_database_nfvoNfInst_equalAndHashMethod() throws ClassNotFoundException { + EqualsVerifier.forClass(NfvoNfInst.class) + .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT) + .withPrefabValues(NfvoNsInst.class, new NfvoNsInst(), new NfvoNsInst()) + .withIgnoredAnnotations(Entity.class, Id.class).verify(); + } + + @Test + public void test_database_nsLcmOpOcc_equalAndHashMethod() throws ClassNotFoundException { + EqualsVerifier.forClass(NsLcmOpOcc.class) + .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT) + .withPrefabValues(NfvoNsInst.class, new NfvoNsInst(), new NfvoNsInst()) + .withIgnoredAnnotations(Entity.class, Id.class).verify(); + } +} |