From 7962fe55692954548da260f31528dfc434f17755 Mon Sep 17 00:00:00 2001 From: Bartosz Gardziejewski Date: Tue, 20 Aug 2019 15:53:19 +0200 Subject: increasing test coverage in openecomp-be api Issue-ID: SDC-2326 Signed-off-by: Bartosz Gardziejewski Change-Id: I93cc5183190fcbada2349b18f14fbec9c28f1ae5 --- .../application-config-rest-services/pom.xml | 5 + .../services/ApplicationConfigurationImplTest.java | 123 +++++++++++++++++++++ .../rest/mapping/MapConflictToDtoTest.java | 85 ++++++++++++++ .../mapping/MapItemVersionConflictToDtoTest.java | 73 ++++++++++++ .../healthcheck-rest-services/pom.xml | 7 +- .../rest/mapping/MapHealthCheckInfoToDtoTest.java | 63 +++++++++++ .../healthcheck-rest-types/pom.xml | 9 +- .../sdcrests/health/types/HealthInfoDtoTest.java | 40 +++++++ .../sdcrests/health/types/HealthInfoDtosTest.java | 40 +++++++ .../item-permissions-rest-types/pom.xml | 6 + .../types/ItemPermissionsDtoTest.java | 41 +++++++ .../types/ItemPermissionsRequestDtoTest.java | 40 +++++++ .../item-rest/item-rest-types/pom.xml | 8 +- .../sdcrests/item/types/ActivityLogDtoTest.java | 38 +++++++ .../sdcrests/item/types/ActivityStatusTest.java | 54 +++++++++ .../sdcrests/item/types/CommitRequestDtoTest.java | 38 +++++++ .../item/types/ItemActionRequestDtoTest.java | 38 +++++++ .../sdcrests/item/types/ItemCreationDtoTest.java | 38 +++++++ .../openecomp/sdcrests/item/types/ItemDtoTest.java | 38 +++++++ .../sdcrests/item/types/RevisionDtoTest.java | 38 +++++++ .../item/types/RevisionRequestDtoTest.java | 38 +++++++ .../sdcrests/item/types/SubmitRequestDtoTest.java | 38 +++++++ .../item/types/VersionActionRequestDtoTest.java | 38 +++++++ .../sdcrests/item/types/VersionDtoTest.java | 38 +++++++ .../sdcrests/item/types/VersionRequestDtoTest.java | 38 +++++++ .../notifications-rest-types/pom.xml | 8 +- .../types/NotificationEntityDtoTest.java | 64 +++++++++++ .../types/NotificationsStatusDtoTest.java | 38 +++++++ .../UpdateNotificationResponseStatusTest.java | 99 +++++++++++++++++ openecomp-be/pom.xml | 7 ++ 30 files changed, 1224 insertions(+), 4 deletions(-) create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/test/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImplTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/test/java/org/openecomp/sdcrests/health/rest/mapping/MapHealthCheckInfoToDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/test/java/org/openecomp/sdcrests/health/types/HealthInfoDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/test/java/org/openecomp/sdcrests/health/types/HealthInfoDtosTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/test/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/test/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ActivityLogDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ActivityStatusTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/CommitRequestDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ItemActionRequestDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ItemCreationDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ItemDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/RevisionDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/RevisionRequestDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/SubmitRequestDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/VersionActionRequestDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/VersionDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/VersionRequestDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/test/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/test/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/test/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatusTest.java diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml index 034f87e513..b1adca25f6 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml @@ -60,6 +60,11 @@ junit test + + org.springframework + spring-web + test + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/test/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImplTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/test/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImplTest.java new file mode 100644 index 0000000000..43ebeab9e5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/test/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImplTest.java @@ -0,0 +1,123 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.applicationconfig.rest.services; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity; +import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData; +import org.openecomp.sdc.applicationconfig.ApplicationConfigManager; +import org.openecomp.sdcrests.applicationconfiguration.types.ApplicationConfigDto; +import org.openecomp.sdcrests.applicationconfiguration.types.ConfigurationDataDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.springframework.http.HttpStatus; + +import javax.ws.rs.core.Response; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.ArrayList; + +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +public class ApplicationConfigurationImplTest { + + + private ApplicationConfigurationImpl applicationConfiguration; + + @Mock + ApplicationConfigManager applicationConfigManager; + + @Before + public void setUp() { + initMocks(this); + applicationConfiguration = new ApplicationConfigurationImpl(applicationConfigManager); + } + + @Test + public void validateInsertInToTableCallsManagerFunctionWithValidParameters() { + + final String testNamespace = "namespace"; + final String testKey = "key"; + final String testValue = "testingValue"; + final InputStream testInput = new ByteArrayInputStream(testValue.getBytes()); + + Response response = applicationConfiguration.insertToTable(testNamespace, testKey, testInput); + + assertEquals(response.getStatus(), HttpStatus.OK.value()); + verify(applicationConfigManager).insertIntoTable(eq(testNamespace),eq(testKey),eq(testValue)); + } + + @Test + public void validateGetFromTableReturnsValidObject() { + + final String testNamespace = "namespace"; + final String testKey = "key"; + final ConfigurationData testValue = new ConfigurationData("testValue", 111); + + when(applicationConfigManager.getFromTable(eq(testNamespace),eq(testKey))).thenReturn(testValue); + + Response response = applicationConfiguration.getFromTable(testNamespace, testKey); + + assertEquals(response.getEntity().getClass(), ConfigurationDataDto.class); + assertEquals(((ConfigurationDataDto)response.getEntity()).getValue(),testValue.getValue()); + } + + + @Test + public void validateGetListOfConfigurationByNamespaceFromTableReturnsValidList() { + + final String testNamespace = "namespace"; + final ArrayList testApplicationConfigEntities = new ArrayList<>(); + final ApplicationConfigEntity testConfigEntity01 = new ApplicationConfigEntity(); + final String testValue01 = "testValue01"; + final ApplicationConfigEntity testConfigEntity02 = new ApplicationConfigEntity(); + final String testValue02 = "testValue02"; + testConfigEntity01.setValue(testValue01); + testConfigEntity02.setValue(testValue02); + testApplicationConfigEntities.add(testConfigEntity01); + testApplicationConfigEntities.add(testConfigEntity02); + + when(applicationConfigManager.getListOfConfigurationByNamespace(eq(testNamespace))) + .thenReturn(testApplicationConfigEntities); + + Response response = applicationConfiguration.getListOfConfigurationByNamespaceFromTable(testNamespace); + + assertEquals(response.getEntity().getClass(), GenericCollectionWrapper.class); + assertEquals( + ((GenericCollectionWrapper)response.getEntity()).getResults().size(), + testApplicationConfigEntities.size() + ); + assertEquals( + ((ApplicationConfigDto)response.readEntity(GenericCollectionWrapper.class).getResults().get(0)).getValue(), + testApplicationConfigEntities.get(0).getValue() + ); + assertEquals( + ((ApplicationConfigDto)response.readEntity(GenericCollectionWrapper.class).getResults().get(1)).getValue(), + testApplicationConfigEntities.get(1).getValue() + ); + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDtoTest.java new file mode 100644 index 0000000000..a37be72944 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDtoTest.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.conflict.rest.mapping; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.openecomp.conflicts.types.Conflict; +import org.openecomp.sdc.datatypes.model.ElementType; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; +import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; +import org.openecomp.sdcrests.conflict.types.ConflictDto; +import static org.junit.Assert.assertEquals; + +public class MapConflictToDtoTest { + + private MapConflictToDto mapConflictToDto; + + private final String testId = "testId"; + private final String testName = "testName"; + + @Before + public void setUp() { + mapConflictToDto = new MapConflictToDto(); + } + + @Test + public void validDoMappingIsCorrectForNetworkEntity() { + final NetworkEntity testYoursNetworkEntity = new NetworkEntity(); + testYoursNetworkEntity.setId("YoursId"); + final NetworkEntity testTheirsNetworkEntity = new NetworkEntity(); + testTheirsNetworkEntity.setId("TheirsId"); + final Conflict testConflict = new Conflict<>(testId, ElementType.Network, testName); + testConflict.setYours(testYoursNetworkEntity); + testConflict.setTheirs(testTheirsNetworkEntity); + final ConflictDto testConflictDto = new ConflictDto(); + + mapConflictToDto.doMapping(testConflict, testConflictDto); + + assertEquals(testConflict.getId(), testConflictDto.getId()); + assertEquals(testConflict.getName(), testConflictDto.getName()); + assertEquals(testConflict.getType(), testConflictDto.getType()); + assertEquals(testConflict.getYours().getId(), testConflictDto.getYours().get("id")); + assertEquals(testConflict.getTheirs().getId(), testConflictDto.getTheirs().get("id")); + } + + @Test + public void validDoMappingIsCorrectForLicenseAgreement() { + final LicenseAgreementEntity testYoursLicenseAgreementEntity = new LicenseAgreementEntity(); + testYoursLicenseAgreementEntity.setName("YoursName"); + final LicenseAgreementEntity testTheirsLicenseAgreementEntity = new LicenseAgreementEntity(); + testTheirsLicenseAgreementEntity.setName("TheirsName"); + final Conflict testConflict = new Conflict<>(testId, ElementType.LicenseAgreement, testName); + testConflict.setYours(testYoursLicenseAgreementEntity); + testConflict.setTheirs(testTheirsLicenseAgreementEntity); + final ConflictDto testConflictDto = new ConflictDto(); + + mapConflictToDto.doMapping(testConflict, testConflictDto); + + assertEquals(testConflict.getId(), testConflictDto.getId()); + assertEquals(testConflict.getName(), testConflictDto.getName()); + assertEquals(testConflict.getType(), testConflictDto.getType()); + assertEquals(testConflict.getYours().getName(), testConflictDto.getYours().get("name")); + assertEquals(testConflict.getTheirs().getName(), testConflictDto.getTheirs().get("name")); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDtoTest.java new file mode 100644 index 0000000000..0f1a007fce --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDtoTest.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.conflict.rest.mapping; + +import org.junit.Before; +import org.junit.Test; +import org.openecomp.conflicts.types.ConflictInfo; +import org.openecomp.conflicts.types.ItemVersionConflict; +import org.openecomp.sdc.datatypes.model.ElementType; +import org.openecomp.sdcrests.conflict.types.ConflictInfoDto; +import org.openecomp.sdcrests.conflict.types.ItemVersionConflictDto; + +import java.util.Collection; +import java.util.Collections; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; + +public class MapItemVersionConflictToDtoTest { + + private MapItemVersionConflictToDto mapItemVersionConflictToDto; + + + @Before + public void setUp() { + mapItemVersionConflictToDto = new MapItemVersionConflictToDto(); + } + + @Test + public void validDoMappingCorrectMapsVersionConflicts() { + + final String testId01 = "testId01"; + final String testName01 = "testName01"; + final String testId02 = "testId02"; + final String testName02 = "testName02"; + + final ItemVersionConflict testSource = new ItemVersionConflict(); + Collections.addAll(testSource.getElementConflicts(), + new ConflictInfo(testId01, ElementType.itemVersion, testName01), + new ConflictInfo(testId02, ElementType.itemVersion, testName02) + ); + final ItemVersionConflictDto testTarget = new ItemVersionConflictDto(); + + mapItemVersionConflictToDto.doMapping(testSource, testTarget); + + assertArrayEquals( + testSource.getElementConflicts().stream().map(ConflictInfo::getName).toArray(), + testTarget.getConflictInfoList().stream().map(ConflictInfoDto::getName).toArray() + ); + assertArrayEquals( + testSource.getElementConflicts().stream().map(ConflictInfo::getId).toArray(), + testTarget.getConflictInfoList().stream().map(ConflictInfoDto::getId).toArray() + ); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/pom.xml index a3054b1472..2d88272e56 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/pom.xml @@ -50,8 +50,13 @@ cxf-rt-frontend-jaxrs ${cxf.version} + + junit + junit + test + - \ No newline at end of file + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/test/java/org/openecomp/sdcrests/health/rest/mapping/MapHealthCheckInfoToDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/test/java/org/openecomp/sdcrests/health/rest/mapping/MapHealthCheckInfoToDtoTest.java new file mode 100644 index 0000000000..7c1ab838e6 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/test/java/org/openecomp/sdcrests/health/rest/mapping/MapHealthCheckInfoToDtoTest.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.health.rest.mapping; + +import org.junit.Before; +import org.junit.Test; +import org.openecomp.sdc.health.data.HealthCheckStatus; +import org.openecomp.sdc.health.data.HealthInfo; +import org.openecomp.sdc.health.data.MonitoredModules; +import org.openecomp.sdcrests.health.types.HealthInfoDto; +import org.openecomp.sdcrests.health.types.HealthInfoDtos; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import static org.junit.Assert.assertEquals; + +public class MapHealthCheckInfoToDtoTest { + + private MapHealthCheckInfoToDto mapHealthCheckInfoToDto; + + @Before + public void setUp() { + mapHealthCheckInfoToDto = new MapHealthCheckInfoToDto(); + } + + @Test + public void validateDoMappingCorrectMapsHealthInfoToHealthInfoDto() { + + final HealthInfo healthInfo = new HealthInfo(MonitoredModules.BE, HealthCheckStatus.UP, "1.0", "test"); + List testSource = Collections.singletonList(healthInfo); + + HealthInfoDtos testTarget = new HealthInfoDtos(); + + mapHealthCheckInfoToDto.doMapping(testSource ,testTarget); + + final HealthInfo sourceElement = testSource.get(0); + final HealthInfoDto responceElement = testTarget.getHealthInfos().get(0); + assertEquals(sourceElement.getDescription(),responceElement.getDescription()); + assertEquals(sourceElement.getHealthCheckStatus().toString(),responceElement.getHealthStatus().toString()); + assertEquals(sourceElement.getVersion(),responceElement.getVersion()); + assertEquals(sourceElement.getHealthCheckComponent().toString(),responceElement.getHealthCheckComponent().toString()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/pom.xml index 6b7059eabc..0d23c84022 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/pom.xml @@ -3,6 +3,13 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + + junit + junit + test + + org.openecomp.sdc @@ -12,4 +19,4 @@ healthcheck-rest-types - \ No newline at end of file + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/test/java/org/openecomp/sdcrests/health/types/HealthInfoDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/test/java/org/openecomp/sdcrests/health/types/HealthInfoDtoTest.java new file mode 100644 index 0000000000..1b270aa7fe --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/test/java/org/openecomp/sdcrests/health/types/HealthInfoDtoTest.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.health.types; + +import org.junit.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +public class HealthInfoDtoTest { + + @Test + public void testBean() { + assertThat(HealthInfoDto.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/test/java/org/openecomp/sdcrests/health/types/HealthInfoDtosTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/test/java/org/openecomp/sdcrests/health/types/HealthInfoDtosTest.java new file mode 100644 index 0000000000..259548a22a --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/test/java/org/openecomp/sdcrests/health/types/HealthInfoDtosTest.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.health.types; + +import org.junit.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +public class HealthInfoDtosTest { + + @Test + public void testBean() { + assertThat(HealthInfoDtos.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/pom.xml index 5249403240..f7b228a1f9 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/pom.xml @@ -9,6 +9,12 @@ swagger-annotations ${swagger.version} + + org.junit.jupiter + junit-jupiter-api + 5.3.1 + test + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/test/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/test/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDtoTest.java new file mode 100644 index 0000000000..82570b29fd --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/test/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDtoTest.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.itempermissions.types; + +import org.junit.jupiter.api.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +public class ItemPermissionsDtoTest { + + + @Test + public void testBean() { + assertThat(ItemPermissionsDto.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/test/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/test/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDtoTest.java new file mode 100644 index 0000000000..94ce4c1e52 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/test/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDtoTest.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.itempermissions.types; + +import org.junit.jupiter.api.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +public class ItemPermissionsRequestDtoTest { + + @Test + public void testBean() { + assertThat(ItemPermissionsRequestDto.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/pom.xml index f3b5dbfa5d..0a368dfd4a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/pom.xml @@ -28,7 +28,13 @@ openecomp-sdc-conflict-manager ${project.version} + + org.junit.jupiter + junit-jupiter-api + 5.3.1 + test + - \ No newline at end of file + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ActivityLogDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ActivityLogDtoTest.java new file mode 100644 index 0000000000..8a740e2469 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ActivityLogDtoTest.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.types; + +import org.junit.jupiter.api.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +class ActivityLogDtoTest { + @Test + void testBean() { + assertThat(ActivityLogDto.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ActivityStatusTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ActivityStatusTest.java new file mode 100644 index 0000000000..b643e718e5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ActivityStatusTest.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.types; + +import org.junit.jupiter.api.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; + +class ActivityStatusTest { + + @Test + void testBean() { + assertThat(ActivityStatus.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } + + @Test + void validateArgConstructors() { + + final String testMessage = "testMessage"; + + ActivityStatus activityStatus = new ActivityStatus(false); + assertEquals(activityStatus.isSuccess(),false); + + activityStatus = new ActivityStatus(true,testMessage); + assertEquals(activityStatus.isSuccess(),true); + assertEquals(activityStatus.getMessage(), testMessage); + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/CommitRequestDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/CommitRequestDtoTest.java new file mode 100644 index 0000000000..8eb1b5e089 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/CommitRequestDtoTest.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.types; + +import org.junit.jupiter.api.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +public class CommitRequestDtoTest { + @Test + void testBean() { + assertThat(CommitRequestDto.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ItemActionRequestDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ItemActionRequestDtoTest.java new file mode 100644 index 0000000000..9933e81909 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ItemActionRequestDtoTest.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.types; + +import org.junit.jupiter.api.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +public class ItemActionRequestDtoTest { + @Test + void testBean() { + assertThat(ItemActionRequestDto.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ItemCreationDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ItemCreationDtoTest.java new file mode 100644 index 0000000000..e3050b121b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ItemCreationDtoTest.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.types; + +import org.junit.jupiter.api.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +class ItemCreationDtoTest { + @Test + void testBean() { + assertThat(ItemCreationDto.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ItemDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ItemDtoTest.java new file mode 100644 index 0000000000..742b60aa4d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/ItemDtoTest.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.types; + +import org.junit.jupiter.api.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +class ItemDtoTest { + @Test + void testBean() { + assertThat(ItemDto.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/RevisionDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/RevisionDtoTest.java new file mode 100644 index 0000000000..79287243b8 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/RevisionDtoTest.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.types; + +import org.junit.jupiter.api.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +class RevisionDtoTest { + @Test + void testBean() { + assertThat(RevisionDto.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/RevisionRequestDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/RevisionRequestDtoTest.java new file mode 100644 index 0000000000..bef452b9bd --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/RevisionRequestDtoTest.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.types; + +import org.junit.jupiter.api.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +class RevisionRequestDtoTest { + @Test + void testBean() { + assertThat(RevisionRequestDto.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/SubmitRequestDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/SubmitRequestDtoTest.java new file mode 100644 index 0000000000..94987de426 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/SubmitRequestDtoTest.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.types; + +import org.junit.jupiter.api.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +class SubmitRequestDtoTest { + @Test + void testBean() { + assertThat(SubmitRequestDto.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/VersionActionRequestDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/VersionActionRequestDtoTest.java new file mode 100644 index 0000000000..94d9e37b25 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/VersionActionRequestDtoTest.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.types; + +import org.junit.jupiter.api.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +class VersionActionRequestDtoTest { + @Test + void testBean() { + assertThat(VersionActionRequestDto.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/VersionDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/VersionDtoTest.java new file mode 100644 index 0000000000..50db26bab8 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/VersionDtoTest.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.types; + +import org.junit.jupiter.api.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +class VersionDtoTest { + @Test + void testBean() { + assertThat(VersionDto.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/VersionRequestDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/VersionRequestDtoTest.java new file mode 100644 index 0000000000..20d651d6b9 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/test/java/org/openecomp/sdcrests/item/types/VersionRequestDtoTest.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.item.types; + +import org.junit.jupiter.api.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +class VersionRequestDtoTest { + @Test + void testBean() { + assertThat(VersionRequestDto.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/pom.xml index 76b6fcfbbc..03ff748e4c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/pom.xml @@ -9,6 +9,12 @@ openecomp-sdc-datatypes-lib ${project.version} + + org.junit.jupiter + junit-jupiter-api + 5.3.1 + test + @@ -20,4 +26,4 @@ notifications-rest-types - \ No newline at end of file + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/test/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/test/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDtoTest.java new file mode 100644 index 0000000000..e9e2bee613 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/test/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDtoTest.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.notifications.types; + +import org.junit.jupiter.api.Test; + +import java.util.Collections; +import java.util.Map; +import java.util.UUID; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; + +class NotificationEntityDtoTest { + @Test + void testBean() { + assertThat(NotificationEntityDto.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } + @Test + void validateArgConstructors() { + + final boolean read = false; + final UUID eventId = new UUID(10,20); + final String eventType = "testType"; + final Map eventAttributes = Collections.singletonMap("testKey","testValue"); + NotificationEntityDto notificationEntityDto = new NotificationEntityDto(read,eventId,eventType,eventAttributes); + assertEquals(notificationEntityDto.isRead(), read); + assertEquals(notificationEntityDto.getEventId(), eventId); + assertEquals(notificationEntityDto.getEventType(), eventType); + assertEquals(notificationEntityDto.getEventAttributes(), eventAttributes); + + final String dataTime = "10-10-2019"; + notificationEntityDto = new NotificationEntityDto(read, eventId, eventType, eventAttributes, dataTime); + assertEquals(notificationEntityDto.isRead(), read); + assertEquals(notificationEntityDto.getEventId(), eventId); + assertEquals(notificationEntityDto.getEventType(), eventType); + assertEquals(notificationEntityDto.getEventAttributes(), eventAttributes); + assertEquals(notificationEntityDto.getDateTime(), dataTime); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/test/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/test/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDtoTest.java new file mode 100644 index 0000000000..fe236f33ce --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/test/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDtoTest.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.notifications.types; + +import org.junit.jupiter.api.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; + +class NotificationsStatusDtoTest { + @Test + void testBean() { + assertThat(NotificationsStatusDto.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/test/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatusTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/test/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatusTest.java new file mode 100644 index 0000000000..20d23fbf7e --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/test/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatusTest.java @@ -0,0 +1,99 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.notifications.types; + +import org.junit.jupiter.api.Test; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.datatypes.error.ErrorMessage; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class UpdateNotificationResponseStatusTest { + @Test + void testBean() { + assertThat(UpdateNotificationResponseStatus.class, allOf( + hasValidBeanConstructor(), + hasValidGettersAndSetters() + )); + } + @Test + void validateAddStructureErrorCorrectlyAddsOneError() { + UpdateNotificationResponseStatus updateNotificationResponseStatus = new UpdateNotificationResponseStatus(); + + assertTrue(updateNotificationResponseStatus.getErrors().isEmpty()); + final String notificationId = "testId"; + final ErrorMessage testError = new ErrorMessage(ErrorLevel.ERROR,"test Error"); + updateNotificationResponseStatus.addStructureError(notificationId, testError); + + assertFalse(updateNotificationResponseStatus.getErrors().isEmpty()); + assertEquals(updateNotificationResponseStatus.getErrors().size(),1); + assertEquals(updateNotificationResponseStatus.getErrors().get(notificationId).size(),1); + assertEquals(updateNotificationResponseStatus.getErrors().get(notificationId).get(0),testError); + } + @Test + void validateAddStructureErrorCorrectlyAddsTwoErrorsToOneKey() { + UpdateNotificationResponseStatus updateNotificationResponseStatus = new UpdateNotificationResponseStatus(); + + assertTrue(updateNotificationResponseStatus.getErrors().isEmpty()); + final String notificationId = "testId"; + final ErrorMessage testError01 = new ErrorMessage(ErrorLevel.ERROR,"test Error01"); + final ErrorMessage testError02 = new ErrorMessage(ErrorLevel.ERROR,"test Error02"); + final List testErrorsList = new ArrayList<>(); + Collections.addAll(testErrorsList,testError01,testError02); + updateNotificationResponseStatus.addStructureError(notificationId, testError01); + updateNotificationResponseStatus.addStructureError(notificationId, testError02); + + assertFalse(updateNotificationResponseStatus.getErrors().isEmpty()); + assertEquals(updateNotificationResponseStatus.getErrors().size(),1); + assertEquals(updateNotificationResponseStatus.getErrors().get(notificationId).size(),2); + assertArrayEquals(updateNotificationResponseStatus.getErrors().get(notificationId).toArray(), testErrorsList.toArray()); + } + @Test + void validateAddStructureErrorCorrectlyAddsTwoErrorsToTwoKeys() { + UpdateNotificationResponseStatus updateNotificationResponseStatus = new UpdateNotificationResponseStatus(); + + assertTrue(updateNotificationResponseStatus.getErrors().isEmpty()); + final String notificationId01 = "testId01"; + final ErrorMessage testError01 = new ErrorMessage(ErrorLevel.ERROR,"test Error01"); + final String notificationId02 = "testId02"; + final ErrorMessage testError02 = new ErrorMessage(ErrorLevel.ERROR,"test Error02"); + updateNotificationResponseStatus.addStructureError(notificationId01, testError01); + updateNotificationResponseStatus.addStructureError(notificationId02, testError02); + + assertFalse(updateNotificationResponseStatus.getErrors().isEmpty()); + assertEquals(updateNotificationResponseStatus.getErrors().size(),2); + assertEquals(updateNotificationResponseStatus.getErrors().get(notificationId01).size(),1); + assertEquals(updateNotificationResponseStatus.getErrors().get(notificationId01).get(0), testError01); + assertEquals(updateNotificationResponseStatus.getErrors().get(notificationId02).size(),1); + assertEquals(updateNotificationResponseStatus.getErrors().get(notificationId02).get(0), testError02); + } +} diff --git a/openecomp-be/pom.xml b/openecomp-be/pom.xml index 9e6a01ca8b..8a5f990811 100644 --- a/openecomp-be/pom.xml +++ b/openecomp-be/pom.xml @@ -32,6 +32,13 @@ + + + com.google.code.bean-matchers + bean-matchers + ${bean-matchers.version} + test + org.togglz togglz-core -- cgit 1.2.3-korg