diff options
author | Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com> | 2019-08-20 15:53:19 +0200 |
---|---|---|
committer | Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com> | 2019-08-21 14:35:38 +0200 |
commit | 7962fe55692954548da260f31528dfc434f17755 (patch) | |
tree | 675513195ae04fbdd0eafd058e816c184acbe50e /openecomp-be/api | |
parent | 4d8b50e2a87095d737db72f454f7520ff97f4ec5 (diff) |
increasing test coverage in openecomp-be api
Issue-ID: SDC-2326
Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Change-Id: I93cc5183190fcbada2349b18f14fbec9c28f1ae5
Diffstat (limited to 'openecomp-be/api')
29 files changed, 1217 insertions, 4 deletions
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 @@ <artifactId>junit</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <scope>test</scope> + </dependency> </dependencies> 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<ApplicationConfigEntity> 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<NetworkEntity> 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<LicenseAgreementEntity> 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 @@ <artifactId>cxf-rt-frontend-jaxrs</artifactId> <version>${cxf.version}</version> </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> </dependencies> -</project>
\ No newline at end of file +</project> 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<HealthInfo> 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"> <modelVersion>4.0.0</modelVersion> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> <parent> <groupId>org.openecomp.sdc</groupId> @@ -12,4 +19,4 @@ <artifactId>healthcheck-rest-types</artifactId> -</project>
\ No newline at end of file +</project> 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 @@ <artifactId>swagger-annotations</artifactId> <version>${swagger.version}</version> </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <version>5.3.1</version> + <scope>test</scope> + </dependency> </dependencies> 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 @@ <artifactId>openecomp-sdc-conflict-manager</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <version>5.3.1</version> + <scope>test</scope> + </dependency> </dependencies> -</project>
\ No newline at end of file +</project> 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 @@ <artifactId>openecomp-sdc-datatypes-lib</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <version>5.3.1</version> + <scope>test</scope> + </dependency> </dependencies> <parent> @@ -20,4 +26,4 @@ <artifactId>notifications-rest-types</artifactId> -</project>
\ No newline at end of file +</project> 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<String, Object> 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<ErrorMessage > 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); + } +} |