diff options
Diffstat (limited to 'so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test')
5 files changed, 0 insertions, 420 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 deleted file mode 100644 index b9858a8dd5..0000000000 --- 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 +++ /dev/null @@ -1,181 +0,0 @@ -/*- - * ============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 static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; -import java.util.List; -import java.util.Optional; -import java.util.UUID; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobAction; -import org.onap.so.etsi.nfvo.ns.lcm.database.beans.JobStatusEnum; -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.etsi.nfvo.ns.lcm.database.beans.NsLcmOpType; -import org.onap.so.etsi.nfvo.ns.lcm.database.beans.OperationStateEnum; -import org.onap.so.etsi.nfvo.ns.lcm.database.beans.State; -import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Waqas Ikram (waqas.ikram@est.tech) - * - */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") -public class DatabaseServiceProviderTest { - - private static final String RANDOM_ID = UUID.randomUUID().toString(); - private static final String DUMMY_NAME = "NAME"; - private static final LocalDateTime CURRENT_DATE_TIME = LocalDateTime.now().truncatedTo(ChronoUnit.MILLIS); - @Autowired - private DatabaseServiceProvider databaseServiceProvider; - - @Test - public void testAddJob_StoredInDatabase() { - final NfvoJob expected = new NfvoJob().jobType("TYPE").jobAction(JobAction.CREATE).resourceId(RANDOM_ID) - .resourceName(DUMMY_NAME).startTime(CURRENT_DATE_TIME).status(JobStatusEnum.STARTED); - databaseServiceProvider.addJob(expected); - - Optional<NfvoJob> actual = databaseServiceProvider.getJob(expected.getJobId()); - assertEquals(expected, actual.get()); - - actual = databaseServiceProvider.getRefreshedJob(expected.getJobId()); - assertEquals(expected, actual.get()); - - } - - @Test - public void testAddJobWithJobStatus_StoredInDatabase() { - final NfvoJob job = new NfvoJob().jobType("TYPE").jobAction(JobAction.CREATE).resourceId(RANDOM_ID) - .resourceName(DUMMY_NAME).startTime(CURRENT_DATE_TIME).status(JobStatusEnum.STARTED); - databaseServiceProvider.addJob(job); - - final NfvoJobStatus jobStatus = new NfvoJobStatus().status(JobStatusEnum.STARTED) - .description("Create NS workflow process started").updatedTime(CURRENT_DATE_TIME); - databaseServiceProvider.addJob(job.nfvoJobStatus(jobStatus)); - - final Optional<NfvoJob> actual = databaseServiceProvider.getJob(job.getJobId()); - final NfvoJob actualNfvoJob = actual.get(); - - assertEquals(job.getJobId(), actualNfvoJob.getJobId()); - assertFalse(actualNfvoJob.getNfvoJobStatuses().isEmpty()); - assertEquals(job.getJobId(), actualNfvoJob.getNfvoJobStatuses().get(0).getNfvoJob().getJobId()); - - } - - @Test - public void testAddNsInst_StoredInDatabase_ableTofindByQuery() { - - final NfvoNsInst nsInst = new NfvoNsInst().name(DUMMY_NAME).nsdId(RANDOM_ID).status(State.NOT_INSTANTIATED) - .nsdInvariantId(RANDOM_ID).statusUpdatedTime(CURRENT_DATE_TIME); - - databaseServiceProvider.saveNfvoNsInst(nsInst); - - Optional<NfvoNsInst> actual = databaseServiceProvider.getNfvoNsInst(nsInst.getNsInstId()); - NfvoNsInst actualNfvoNsInst = actual.get(); - assertEquals(nsInst.getNsInstId(), actualNfvoNsInst.getNsInstId()); - assertEquals(RANDOM_ID, actualNfvoNsInst.getNsdId()); - assertEquals(State.NOT_INSTANTIATED, actualNfvoNsInst.getStatus()); - assertEquals(RANDOM_ID, actualNfvoNsInst.getNsdInvariantId()); - assertEquals(CURRENT_DATE_TIME, actualNfvoNsInst.getStatusUpdatedTime()); - - actual = databaseServiceProvider.getNfvoNsInstByName(DUMMY_NAME); - actualNfvoNsInst = actual.get(); - - assertEquals(nsInst.getNsInstId(), actualNfvoNsInst.getNsInstId()); - assertEquals(RANDOM_ID, actualNfvoNsInst.getNsdId()); - assertEquals(State.NOT_INSTANTIATED, actualNfvoNsInst.getStatus()); - assertEquals(RANDOM_ID, actualNfvoNsInst.getNsdInvariantId()); - assertEquals(CURRENT_DATE_TIME, actualNfvoNsInst.getStatusUpdatedTime()); - - - assertTrue(databaseServiceProvider.isNsInstExists(DUMMY_NAME)); - } - - @Test - public void testAddNfInst_StoredInDatabase_ableTofindByQuery() { - - final NfvoNsInst nsInst = new NfvoNsInst().name(DUMMY_NAME).nsdId(RANDOM_ID).status(State.NOT_INSTANTIATED) - .nsdInvariantId(RANDOM_ID).statusUpdatedTime(CURRENT_DATE_TIME); - - databaseServiceProvider.saveNfvoNsInst(nsInst); - - final NfvoNfInst nfInst = new NfvoNfInst().nfvoNsInst(nsInst).name(DUMMY_NAME).vnfdId(RANDOM_ID) - .status(State.NOT_INSTANTIATED).createTime(CURRENT_DATE_TIME).lastUpdateTime(CURRENT_DATE_TIME); - databaseServiceProvider.saveNfvoNfInst(nfInst); - - final Optional<NfvoNfInst> actual = databaseServiceProvider.getNfvoNfInst(nfInst.getNfInstId()); - final NfvoNfInst actualNfvoNfInst = actual.get(); - assertEquals(nsInst.getNsInstId(), actualNfvoNfInst.getNsInst().getNsInstId()); - assertEquals(nfInst.getNfInstId(), actualNfvoNfInst.getNfInstId()); - assertEquals(nfInst.getName(), actualNfvoNfInst.getName()); - assertEquals(nfInst.getVnfdId(), actualNfvoNfInst.getVnfdId()); - assertEquals(nfInst.getStatus(), actualNfvoNfInst.getStatus()); - assertEquals(nfInst.getCreateTime(), actualNfvoNfInst.getCreateTime()); - assertEquals(nfInst.getLastUpdateTime(), actualNfvoNfInst.getLastUpdateTime()); - - - List<NfvoNfInst> nfvoNfInstList = databaseServiceProvider.getNfvoNfInstByNsInstId(nsInst.getNsInstId()); - assertFalse(nfvoNfInstList.isEmpty()); - assertEquals(nsInst.getNsInstId(), nfvoNfInstList.get(0).getNsInst().getNsInstId()); - - nfvoNfInstList = databaseServiceProvider.getNfvoNfInstByNsInstIdAndNfName(nsInst.getNsInstId(), DUMMY_NAME); - - assertFalse(nfvoNfInstList.isEmpty()); - assertEquals(nsInst.getNsInstId(), nfvoNfInstList.get(0).getNsInst().getNsInstId()); - assertEquals(DUMMY_NAME, nfvoNfInstList.get(0).getName()); - } - - @Test - public void testAddNsLcmOpOcc_StoredInDatabase_ableTofindByQuery() { - - final NfvoNsInst nsInst = new NfvoNsInst().name(DUMMY_NAME).nsdId(RANDOM_ID).status(State.NOT_INSTANTIATED) - .nsdInvariantId(RANDOM_ID).statusUpdatedTime(CURRENT_DATE_TIME); - - databaseServiceProvider.saveNfvoNsInst(nsInst); - - final NsLcmOpOcc nsLcmOpOcc = new NsLcmOpOcc().nfvoNsInst(nsInst).operationState(OperationStateEnum.PROCESSING) - .isCancelPending(false).isAutoInvocation(false).operation(NsLcmOpType.INSTANTIATE) - .startTime(CURRENT_DATE_TIME).stateEnteredTime(CURRENT_DATE_TIME).operationParams(""); - - - databaseServiceProvider.addNSLcmOpOcc(nsLcmOpOcc); - - final Optional<NsLcmOpOcc> actual = databaseServiceProvider.getNsLcmOpOcc(nsLcmOpOcc.getId()); - final NsLcmOpOcc actualLcmOpOcc = actual.get(); - assertEquals(nsLcmOpOcc.getId(), actualLcmOpOcc.getId()); - - assertEquals(nsInst.getNsInstId(), actualLcmOpOcc.getNfvoNsInst().getNsInstId()); - - } -} 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 deleted file mode 100644 index 5f033a2438..0000000000 --- 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 +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * ============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(); - } -} 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/TestApplication.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/TestApplication.java deleted file mode 100644 index 921cae2343..0000000000 --- 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/TestApplication.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============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 org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.FilterType; -import org.springframework.context.annotation.ComponentScan.Filter; - -/** - * @author Waqas Ikram (waqas.ikram@est.tech) - * - */ -@SpringBootApplication(scanBasePackages = {"org.onap.so"}) -@EnableAutoConfiguration(exclude = {JacksonAutoConfiguration.class}) -@ComponentScan(basePackages = {"org.onap"}, - excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)}) -public class TestApplication { - - public static void main(final String[] args) { - new SpringApplication(TestApplication.class).run(args); - } - -} 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/beans/utils/UtilsTest.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/beans/utils/UtilsTest.java deleted file mode 100644 index 632bda937c..0000000000 --- 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/beans/utils/UtilsTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============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.beans.utils; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import java.util.Arrays; -import java.util.Collections; -import org.junit.Test; - -/** - * @author Waqas Ikram (waqas.ikram@est.tech) - * - */ -public class UtilsTest { - - @Test - public void testTwoEmptyLists_equal() { - assertTrue(Utils.isEquals(Collections.emptyList(), Collections.emptyList())); - } - - @Test - public void testEmptyListAndNonEmpty_notEqual() { - assertFalse(Utils.isEquals(Collections.emptyList(), Arrays.asList("A"))); - } - - @Test - public void testTwoNullLists_equal() { - assertTrue(Utils.isEquals(null, null)); - } - - @Test - public void testNullListAndEmptyList_notEqual() { - assertFalse(Utils.isEquals(null, Collections.emptyList())); - } - - @Test - public void testTwoNotEmptyListsContainSameObjects_equal() { - assertTrue(Utils.isEquals(Arrays.asList("A"), Arrays.asList("A"))); - } - - @Test - public void testTwoNotEmptyListsContainsDifferentObjects_equal() { - assertFalse(Utils.isEquals(Arrays.asList("A"), Arrays.asList(1))); - } - - -} diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/resources/application.yaml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/resources/application.yaml deleted file mode 100644 index 478a5b5ac7..0000000000 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-database-service/src/test/resources/application.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright © 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. -spring: - main: - web-application-type: none - datasource: - hikari: - nfvo: - jdbcUrl: jdbc:h2:mem:nfvo;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS nfvo;MODE=MYSQL;DATABASE_TO_LOWER=TRUE;CASE_INSENSITIVE_IDENTIFIERS=TRUE - driver-class-name: org.h2.Driver - pool-name: ns-lcm-bpmn-pool - registerMbeans: true - test: - database: - replace: NONE - jpa: - generate-ddl: true - dialect: org.hibernate.dialect.MySQL5Dialect - hibernate: - ddl-auto: create - database-platform: org.hibernate.dialect.MariaDBDialect -hibernate: - dialect: org.hibernate.dialect.H2Dialect - hbm2ddl: - auto: create
\ No newline at end of file |