From 130aa901dd94519cd6bc99140a9d935365220cc5 Mon Sep 17 00:00:00 2001 From: ayalaben Date: Wed, 10 Oct 2018 09:40:57 +0300 Subject: Unit test coverage Change-Id: I3634ccaa60c72ee91b89ae42b8da8926b5823436 Issue-ID: SDC-1822 Signed-off-by: ayalaben --- .../MapLimitEntityToLimitCreationDtoTest.java | 36 ++++++++ .../vendor-software-products-rest-services/pom.xml | 5 + .../MapComponentDataToComponentDtoTest.java | 58 ++++++++++++ ...ComponentDependencyEntityToCreationDtoTest.java | 38 ++++++++ .../MapComponentDependencyEntityToDtoTest.java | 66 +++++++++++++ ...MapComponentDependencyModelEntityToDtoTest.java | 56 +++++++++++ ...omponentDependencyModelRequestToEntityTest.java | 59 ++++++++++++ ...pComponentEntityToComponentCreationDtoTest.java | 35 +++++++ .../MapComponentEntityToComponentDtoTest.java | 35 +++++++ .../MapCompositionEntityResponseToDtoTest.java | 51 +++++++++++ ...apCompositionEntityValidationDataToDtoTest.java | 69 ++++++++++++++ .../MapComputeDataToComputeDetailsDtoTest.java | 47 ++++++++++ .../MapComputeEntityToComputeCreationDtoTest.java | 36 ++++++++ ...orEntityDeploymentFlavorToListResponseTest.java | 38 ++++++++ ...vorEntityToDeploymentFlavorCreationDtoTest.java | 38 ++++++++ ...ymentFlavorEntityToDeploymentFlavorDtoTest.java | 37 ++++++++ .../MapDeploymentFlavorToDeploymentDtoTest.java | 59 ++++++++++++ .../openecomp-item-permissions-core/pom.xml | 4 +- .../dao/impl/PermissionsServicesImplTest.java | 102 ++++++++++++--------- .../servlet/PermissionsFilterTest.java | 7 +- ...ationTemplateFileExtensionErrorBuilderTest.java | 33 ++++--- ...orSoftwareProductCreationFailedBuilderTest.java | 22 ++++- ...dorSoftwareProductNotFoundErrorBuilderTest.java | 34 ++++--- 23 files changed, 887 insertions(+), 78 deletions(-) create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/test/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDataToComponentDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToCreationDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelEntityToDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelRequestToEntityTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentCreationDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityResponseToDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityValidationDataToDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeDataToComputeDetailsDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeEntityToComputeCreationDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityDeploymentFlavorToListResponseTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityToDeploymentFlavorCreationDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityToDeploymentFlavorDtoTest.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorToDeploymentDtoTest.java diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/test/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/test/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDtoTest.java new file mode 100644 index 0000000000..68a5811ba5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/test/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDtoTest.java @@ -0,0 +1,36 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; + +public class MapLimitEntityToLimitCreationDtoTest { + + @Test + public void testId() { + LimitEntity source = new LimitEntity(); + LimitCreationDto target = new LimitCreationDto(); + MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto(); + String param = "52d4d919-015a-4a46-af04-4d0dec17e88d"; + source.setId(param); + mapper.doMapping(source, target); + assertEquals(target.getLimitId(), param); + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml index 923cc48557..bb11b11fde 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml @@ -13,6 +13,11 @@ + + junit + junit + test + org.springframework spring-core diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDataToComponentDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDataToComponentDtoTest.java new file mode 100644 index 0000000000..2973426b13 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDataToComponentDtoTest.java @@ -0,0 +1,58 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; + +public class MapComponentDataToComponentDtoTest { + + @Test + public void testDisplayName() { + ComponentData source = new ComponentData(); + ComponentDto target = new ComponentDto(); + MapComponentDataToComponentDto mapper = new MapComponentDataToComponentDto(); + String displayName = "some_test_name"; + source.setDisplayName(displayName); + mapper.doMapping(source, target); + assertEquals(target.getDisplayName(), displayName); + } + + @Test + public void testName() { + ComponentData source = new ComponentData(); + ComponentDto target = new ComponentDto(); + MapComponentDataToComponentDto mapper = new MapComponentDataToComponentDto(); + String name = "component_name_1"; + source.setName(name); + mapper.doMapping(source, target); + assertEquals(target.getName(), name); + } + + @Test + public void testDescription() { + ComponentData source = new ComponentData(); + ComponentDto target = new ComponentDto(); + MapComponentDataToComponentDto mapper = new MapComponentDataToComponentDto(); + String description = "my_test_component"; + source.setDescription(description); + mapper.doMapping(source, target); + assertEquals(target.getDescription(), description); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToCreationDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToCreationDtoTest.java new file mode 100644 index 0000000000..5abaf8dd23 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToCreationDtoTest.java @@ -0,0 +1,38 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyCreationDto; + +public class MapComponentDependencyEntityToCreationDtoTest { + + @Test + public void testId() { + ComponentDependencyModelEntity source = new ComponentDependencyModelEntity(); + ComponentDependencyCreationDto target = new ComponentDependencyCreationDto(); + MapComponentDependencyEntityToCreationDto mapper = new MapComponentDependencyEntityToCreationDto(); + String id = "some_test_id"; + source.setId(id); + mapper.doMapping(source, target); + assertEquals(target.getId(), id); + } + + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToDtoTest.java new file mode 100644 index 0000000000..c97a274615 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToDtoTest.java @@ -0,0 +1,66 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyResponseDto; + +public class MapComponentDependencyEntityToDtoTest { + + private static final String TEST_VALUE = "some_test_id"; + + @Test + public void testSourceId() { + ComponentDependencyModelEntity source = new ComponentDependencyModelEntity(); + ComponentDependencyResponseDto target = new ComponentDependencyResponseDto(); + MapComponentDependencyEntityToDto mapper = new MapComponentDependencyEntityToDto(); + source.setSourceComponentId(TEST_VALUE); + mapper.doMapping(source, target); + assertEquals(target.getSourceId(), TEST_VALUE); + } + @Test + public void testTargetId() { + ComponentDependencyModelEntity source = new ComponentDependencyModelEntity(); + ComponentDependencyResponseDto target = new ComponentDependencyResponseDto(); + MapComponentDependencyEntityToDto mapper = new MapComponentDependencyEntityToDto(); + source.setTargetComponentId(TEST_VALUE); + mapper.doMapping(source, target); + assertEquals(target.getTargetId(), TEST_VALUE); + } + + @Test + public void testRelationType() { + ComponentDependencyModelEntity source = new ComponentDependencyModelEntity(); + ComponentDependencyResponseDto target = new ComponentDependencyResponseDto(); + MapComponentDependencyEntityToDto mapper = new MapComponentDependencyEntityToDto(); + source.setRelation(TEST_VALUE); + mapper.doMapping(source, target); + assertEquals(target.getRelationType(), TEST_VALUE); + } + + @Test + public void testId() { + ComponentDependencyModelEntity source = new ComponentDependencyModelEntity(); + ComponentDependencyResponseDto target = new ComponentDependencyResponseDto(); + MapComponentDependencyEntityToDto mapper = new MapComponentDependencyEntityToDto(); + source.setId(TEST_VALUE); + mapper.doMapping(source, target); + assertEquals(target.getId(), TEST_VALUE); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelEntityToDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelEntityToDtoTest.java new file mode 100644 index 0000000000..f92eed584f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelEntityToDtoTest.java @@ -0,0 +1,56 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; + +public class MapComponentDependencyModelEntityToDtoTest { + + private static final String TEST_VALUE = "some_test_id"; + + @Test + public void testSourceId() { + ComponentDependencyModelEntity source = new ComponentDependencyModelEntity(); + ComponentDependencyModel target = new ComponentDependencyModel(); + MapComponentDependencyModelEntityToDto mapper = new MapComponentDependencyModelEntityToDto(); + source.setSourceComponentId(TEST_VALUE); + mapper.doMapping(source, target); + assertEquals(target.getSourceId(), TEST_VALUE); + } + @Test + public void testTargetId() { + ComponentDependencyModelEntity source = new ComponentDependencyModelEntity(); + ComponentDependencyModel target = new ComponentDependencyModel(); + MapComponentDependencyModelEntityToDto mapper = new MapComponentDependencyModelEntityToDto(); + source.setTargetComponentId(TEST_VALUE); + mapper.doMapping(source, target); + assertEquals(target.getTargetId(), TEST_VALUE); + } + + @Test + public void testRelationType() { + ComponentDependencyModelEntity source = new ComponentDependencyModelEntity(); + ComponentDependencyModel target = new ComponentDependencyModel(); + MapComponentDependencyModelEntityToDto mapper = new MapComponentDependencyModelEntityToDto(); + source.setRelation(TEST_VALUE); + mapper.doMapping(source, target); + assertEquals(target.getRelationType(), TEST_VALUE); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelRequestToEntityTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelRequestToEntityTest.java new file mode 100644 index 0000000000..467b7e0864 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelRequestToEntityTest.java @@ -0,0 +1,59 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; + +public class MapComponentDependencyModelRequestToEntityTest { + + private static final String TEST_VALUE = "some_test_id"; + private static final String RELATION_TYPE = "dependsOn"; + + @Test + public void testSourceId() { + ComponentDependencyModel source = new ComponentDependencyModel(); + ComponentDependencyModelEntity target = new ComponentDependencyModelEntity(); + MapComponentDependencyModelRequestToEntity mapper = new MapComponentDependencyModelRequestToEntity(); + source.setSourceId(TEST_VALUE); + source.setRelationType(RELATION_TYPE); + mapper.doMapping(source, target); + assertEquals(target.getSourceComponentId(), TEST_VALUE); + } + @Test + public void testTargetId() { + ComponentDependencyModel source = new ComponentDependencyModel(); + ComponentDependencyModelEntity target = new ComponentDependencyModelEntity(); + MapComponentDependencyModelRequestToEntity mapper = new MapComponentDependencyModelRequestToEntity(); + source.setTargetId(TEST_VALUE); + source.setRelationType(RELATION_TYPE); + mapper.doMapping(source, target); + assertEquals(target.getTargetComponentId(), TEST_VALUE); + } + + @Test + public void testRelationType() { + ComponentDependencyModel source = new ComponentDependencyModel(); + ComponentDependencyModelEntity target = new ComponentDependencyModelEntity(); + MapComponentDependencyModelRequestToEntity mapper = new MapComponentDependencyModelRequestToEntity(); + source.setRelationType(RELATION_TYPE); + mapper.doMapping(source, target); + assertEquals(target.getRelation(), RELATION_TYPE); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentCreationDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentCreationDtoTest.java new file mode 100644 index 0000000000..0fb5c6e167 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentCreationDtoTest.java @@ -0,0 +1,35 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentCreationDto; + +public class MapComponentEntityToComponentCreationDtoTest { + + @Test + public void testVfcId() { + ComponentEntity source = new ComponentEntity(); + ComponentCreationDto target = new ComponentCreationDto(); + MapComponentEntityToComponentCreationDto mapper = new MapComponentEntityToComponentCreationDto(); + source.setId("some_test_id"); + mapper.doMapping(source, target); + assertEquals(target.getVfcId(), "some_test_id"); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentDtoTest.java new file mode 100644 index 0000000000..e6c4315938 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentDtoTest.java @@ -0,0 +1,35 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; + +public class MapComponentEntityToComponentDtoTest { + + @Test + public void testId() { + ComponentEntity source = new ComponentEntity(); + ComponentDto target = new ComponentDto(); + MapComponentEntityToComponentDto mapper = new MapComponentEntityToComponentDto(); + source.setId("some_test_id"); + mapper.doMapping(source, target); + assertEquals(target.getId(),"some_test_id"); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityResponseToDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityResponseToDtoTest.java new file mode 100644 index 0000000000..716b7b786d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityResponseToDtoTest.java @@ -0,0 +1,51 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; + +public class MapCompositionEntityResponseToDtoTest { + + @Test + public void testId() { + CompositionEntityResponse source = new CompositionEntityResponse(); + CompositionEntityResponseDto target = new CompositionEntityResponseDto(); + String testId = "some_test_id"; + source.setId(testId); + MapCompositionEntityResponseToDto mapper = + new MapCompositionEntityResponseToDto(new MapComponentDataToComponentDto(), ComponentDto.class); + mapper.doMapping(source, target); + assertEquals(target.getId(), testId); + } + + @Test + public void testSchema() { + CompositionEntityResponse source = new CompositionEntityResponse(); + CompositionEntityResponseDto target = new CompositionEntityResponseDto(); + MapCompositionEntityResponseToDto mapper = + new MapCompositionEntityResponseToDto(new MapComponentDataToComponentDto(), ComponentDto.class); + String schema = "component_name_1"; + source.setSchema(schema); + mapper.doMapping(source, target); + assertEquals(target.getSchema(), schema); + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityValidationDataToDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityValidationDataToDtoTest.java new file mode 100644 index 0000000000..78e634ab3b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityValidationDataToDtoTest.java @@ -0,0 +1,69 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.Collection; +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; + +public class MapCompositionEntityValidationDataToDtoTest { + private static final String TEST_ID = "some_test_id"; + + @Test + public void testEntityType() { + CompositionEntityValidationData source = new CompositionEntityValidationData(CompositionEntityType.compute,TEST_ID); + CompositionEntityValidationDataDto target = new CompositionEntityValidationDataDto(); + MapCompositionEntityValidationDataToDto mapper = new MapCompositionEntityValidationDataToDto(); + mapper.doMapping(source, target); + assertEquals(target.getEntityType(), CompositionEntityType.compute); + } + + @Test + public void testEntityId() { + CompositionEntityValidationData source = new CompositionEntityValidationData(CompositionEntityType.compute,TEST_ID); + CompositionEntityValidationDataDto target = new CompositionEntityValidationDataDto(); + MapCompositionEntityValidationDataToDto mapper = new MapCompositionEntityValidationDataToDto(); + mapper.doMapping(source, target); + assertEquals(target.getEntityId(), TEST_ID); + } + + @Test + public void testEntityName() { + CompositionEntityValidationData source = new CompositionEntityValidationData(CompositionEntityType.compute,TEST_ID); + CompositionEntityValidationDataDto target = new CompositionEntityValidationDataDto(); + String name = "some_test_name"; + source.setEntityName(name); + MapCompositionEntityValidationDataToDto mapper = new MapCompositionEntityValidationDataToDto(); + mapper.doMapping(source, target); + assertEquals(target.getEntityName(), name); + } + + @Test + public void testErrors() { + CompositionEntityValidationData source = new CompositionEntityValidationData(CompositionEntityType.compute,TEST_ID); + CompositionEntityValidationDataDto target = new CompositionEntityValidationDataDto(); + Collection errors = Arrays.asList("some_test_id_1","some_test_id_2","some_test_id_3"); + source.setErrors(errors); + MapCompositionEntityValidationDataToDto mapper = new MapCompositionEntityValidationDataToDto(); + mapper.doMapping(source, target); + assertEquals(target.getErrors(), errors); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeDataToComputeDetailsDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeDataToComputeDetailsDtoTest.java new file mode 100644 index 0000000000..4ce5a4d70b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeDataToComputeDetailsDtoTest.java @@ -0,0 +1,47 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDetailsDto; + +public class MapComputeDataToComputeDetailsDtoTest { + + @Test + public void testName() { + ComputeData source = new ComputeData(); + ComputeDetailsDto target = new ComputeDetailsDto(); + String name = "some_test_name"; + source.setName(name); + MapComputeDataToComputeDetailsDto mapper = new MapComputeDataToComputeDetailsDto(); + mapper.doMapping(source, target); + assertEquals(target.getName(), name); + } + + @Test + public void testDescription() { + ComputeData source = new ComputeData(); + ComputeDetailsDto target = new ComputeDetailsDto(); + String description = "some_test_description"; + source.setDescription(description); + MapComputeDataToComputeDetailsDto mapper = new MapComputeDataToComputeDetailsDto(); + mapper.doMapping(source, target); + assertEquals(target.getDescription(), description); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeEntityToComputeCreationDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeEntityToComputeCreationDtoTest.java new file mode 100644 index 0000000000..1b33f08a8d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeEntityToComputeCreationDtoTest.java @@ -0,0 +1,36 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeCreationDto; + +public class MapComputeEntityToComputeCreationDtoTest { + + @Test + public void testId() { + ComputeEntity source = new ComputeEntity(); + ComputeCreationDto target = new ComputeCreationDto(); + String testId = "some_test_id"; + source.setId(testId); + MapComputeEntityToComputeCreationDto mapper = new MapComputeEntityToComputeCreationDto(); + mapper.doMapping(source, target); + assertEquals(target.getId(), testId); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityDeploymentFlavorToListResponseTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityDeploymentFlavorToListResponseTest.java new file mode 100644 index 0000000000..5aefb4194d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityDeploymentFlavorToListResponseTest.java @@ -0,0 +1,38 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorListResponseDto; + +public class MapDeploymentFlavorEntityDeploymentFlavorToListResponseTest { + + @Test + public void testId() { + DeploymentFlavorEntity source = new DeploymentFlavorEntity(); + DeploymentFlavorListResponseDto target = new DeploymentFlavorListResponseDto(); + String testId = "some_test_id"; + source.setId(testId); + MapDeploymentFlavorEntityDeploymentFlavorToListResponse mapper = + new MapDeploymentFlavorEntityDeploymentFlavorToListResponse(); + mapper.doMapping(source, target); + assertEquals(target.getId(), testId); + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityToDeploymentFlavorCreationDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityToDeploymentFlavorCreationDtoTest.java new file mode 100644 index 0000000000..8044e30950 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityToDeploymentFlavorCreationDtoTest.java @@ -0,0 +1,38 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorCreationDto; + +public class MapDeploymentFlavorEntityToDeploymentFlavorCreationDtoTest { + + @Test + public void testId() { + DeploymentFlavorEntity source = new DeploymentFlavorEntity(); + DeploymentFlavorCreationDto target = new DeploymentFlavorCreationDto(); + String testId = "some_test_id"; + source.setId(testId); + MapDeploymentFlavorEntityToDeploymentFlavorCreationDto mapper = + new MapDeploymentFlavorEntityToDeploymentFlavorCreationDto(); + mapper.doMapping(source, target); + assertEquals(target.getDeploymentFlavorId(), testId); + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityToDeploymentFlavorDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityToDeploymentFlavorDtoTest.java new file mode 100644 index 0000000000..bfa7a94648 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityToDeploymentFlavorDtoTest.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; + +public class MapDeploymentFlavorEntityToDeploymentFlavorDtoTest { + + @Test + public void testModel() { + DeploymentFlavorEntity source = new DeploymentFlavorEntity(); + DeploymentFlavorDto target = new DeploymentFlavorDto(); + String testId = "some_test_id"; + source.setId(testId); + MapDeploymentFlavorEntityToDeploymentFlavorDto mapper = new MapDeploymentFlavorEntityToDeploymentFlavorDto(); + mapper.doMapping(source, target); + assertEquals(target.getId(), testId); + } + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorToDeploymentDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorToDeploymentDtoTest.java new file mode 100644 index 0000000000..79dd509e76 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorToDeploymentDtoTest.java @@ -0,0 +1,59 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; + +public class MapDeploymentFlavorToDeploymentDtoTest { + + @Test + public void testModel() { + DeploymentFlavor source = new DeploymentFlavor(); + DeploymentFlavorDto target = new DeploymentFlavorDto(); + String model = "some_test_model"; + source.setModel(model); + MapDeploymentFlavorToDeploymentDto mapper = new MapDeploymentFlavorToDeploymentDto(); + mapper.doMapping(source, target); + assertEquals(target.getModel(), model); + } + + @Test + public void testDescription() { + DeploymentFlavor source = new DeploymentFlavor(); + DeploymentFlavorDto target = new DeploymentFlavorDto(); + String description = "some_test_description"; + source.setDescription(description); + MapDeploymentFlavorToDeploymentDto mapper = new MapDeploymentFlavorToDeploymentDto(); + mapper.doMapping(source, target); + assertEquals(target.getDescription(), description); + } + + @Test + public void testFeatureGroupId() { + DeploymentFlavor source = new DeploymentFlavor(); + DeploymentFlavorDto target = new DeploymentFlavorDto(); + String testId = "some_test_id"; + source.setFeatureGroupId(testId); + MapDeploymentFlavorToDeploymentDto mapper = new MapDeploymentFlavorToDeploymentDto(); + mapper.doMapping(source, target); + assertEquals(target.getFeatureGroupId(), testId); + } + +} diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/pom.xml b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/pom.xml index 092338fb2d..9721eee3f9 100644 --- a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/pom.xml +++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/pom.xml @@ -56,8 +56,8 @@ test - org.testng - testng + junit + junit test diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImplTest.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImplTest.java index 9346b0a5a5..a6baf9da19 100644 --- a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImplTest.java +++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImplTest.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + package org.openecomp.sdc.itempermissions.dao.impl; import static org.mockito.Matchers.anyObject; @@ -23,9 +39,10 @@ import org.openecomp.sdc.itempermissions.PermissionsRules; import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDao; import org.openecomp.sdc.itempermissions.dao.UserPermissionsDao; import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.Test; +import org.junit.Before; +import org.junit.Assert; + /** * Created by ayalaben on 7/9/2017 @@ -54,7 +71,7 @@ public class PermissionsServicesImplTest { private PermissionsServicesImpl permissionsServices; - @BeforeMethod + @Before public void setUp() { MockitoAnnotations.initMocks(this); } @@ -91,32 +108,29 @@ public class PermissionsServicesImplTest { @Test public void testGetUserItemPermission() { Mockito.when(permissionsDaoMock.getUserItemPermission(anyString(), anyString())) - .thenReturn(Optional.of(PERMISSION)); + .thenReturn(Optional.of(PERMISSION)); Optional permission = permissionsServices.getUserItemPermission(ITEM1_ID, USER1_ID); Assert.assertTrue(permission.isPresent()); - Assert.assertEquals(permission.get(), PERMISSION); + Assert.assertEquals(PERMISSION, permission.get()); } @Test public void testListItemPermissionsWhenNone() { - Collection permissions = - permissionsServices.listItemPermissions(ITEM1_ID); - Assert.assertEquals(permissions.size(), 0); + Collection permissions = permissionsServices.listItemPermissions(ITEM1_ID); + Assert.assertEquals( 0, permissions.size()); } @Test public void testListItemPermissions() { - doReturn(Arrays.asList( - createPermissionEntity(ITEM1_ID, USER1_ID, PERMISSION), - createPermissionEntity(ITEM1_ID, USER2_ID, PERMISSION))) - .when(permissionsDaoMock).listItemPermissions(anyObject()); - - Collection actual = - permissionsServices.listItemPermissions(ITEM1_ID); - Assert.assertEquals(actual.size(), 2); + doReturn(Arrays.asList(createPermissionEntity(ITEM1_ID, USER1_ID, PERMISSION), + createPermissionEntity(ITEM1_ID, USER2_ID, PERMISSION))).when(permissionsDaoMock) + .listItemPermissions(anyObject()); + + Collection actual = permissionsServices.listItemPermissions(ITEM1_ID); + Assert.assertEquals(2, actual.size()); } @@ -129,10 +143,10 @@ public class PermissionsServicesImplTest { Assert.assertTrue(result); - } + } - @Test - public void shouldUpdatePermissions(){ + @Test + public void shouldUpdatePermissions() { Set addedUsers = new HashSet<>(); addedUsers.add(USER2_ID); @@ -141,33 +155,31 @@ public class PermissionsServicesImplTest { verify(permissionsRulesMock).executeAction(ITEM1_ID, USER1_ID, CHANGE_PERMISSIONS); verify(permissionsRulesMock).updatePermission(ITEM1_ID, USER1_ID, PERMISSION, addedUsers, new HashSet<>()); - verify(permissionsDaoMock).updateItemPermissions(ITEM1_ID, PERMISSION, addedUsers, new - HashSet<>()); + verify(permissionsDaoMock).updateItemPermissions(ITEM1_ID, PERMISSION, addedUsers, new HashSet<>()); + } + + @Test + public void shouldExecutePermissionRules() { + permissionsServices.execute(ITEM1_ID, USER1_ID, ACTION_SUBMIT); + verify(permissionsRulesMock).executeAction(ITEM1_ID, USER1_ID, ACTION_SUBMIT); } - @Test - public void shouldExecutePermissionRules(){ - permissionsServices.execute(ITEM1_ID,USER1_ID,ACTION_SUBMIT); - verify(permissionsRulesMock).executeAction(ITEM1_ID,USER1_ID,ACTION_SUBMIT); - } - - @Test - public void shouldReturnUserItemPermission(){ - doReturn(Optional.of(PERMISSION)).when(permissionsDaoMock).getUserItemPermission(ITEM1_ID, USER1_ID); - Optional actual = permissionsServices.getUserItemPermission(ITEM1_ID, USER1_ID); - Assert.assertTrue(actual.isPresent()); - Assert.assertEquals(actual.get(), PERMISSION); - } - - @Test - public void shouldDeleteItemPermissions(){ - permissionsServices.deleteItemPermissions(ITEM1_ID); - verify(permissionsDaoMock).deleteItemPermissions(ITEM1_ID); - } - - - private static ItemPermissionsEntity createPermissionEntity(String itemId, String - userId, String permission) { + @Test + public void shouldReturnUserItemPermission() { + doReturn(Optional.of(PERMISSION)).when(permissionsDaoMock).getUserItemPermission(ITEM1_ID, USER1_ID); + Optional actual = permissionsServices.getUserItemPermission(ITEM1_ID, USER1_ID); + Assert.assertTrue(actual.isPresent()); + Assert.assertEquals(PERMISSION, actual.get()); + } + + @Test + public void shouldDeleteItemPermissions() { + permissionsServices.deleteItemPermissions(ITEM1_ID); + verify(permissionsDaoMock).deleteItemPermissions(ITEM1_ID); + } + + + private static ItemPermissionsEntity createPermissionEntity(String itemId, String userId, String permission) { ItemPermissionsEntity permissionsEntity = new ItemPermissionsEntity(); permissionsEntity.setItemId(itemId); permissionsEntity.setUserId(userId); diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/test/java/org/openecomp/sdc/itempermissions/servlet/PermissionsFilterTest.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/test/java/org/openecomp/sdc/itempermissions/servlet/PermissionsFilterTest.java index 6bb51c30dd..fcf899245c 100644 --- a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/test/java/org/openecomp/sdc/itempermissions/servlet/PermissionsFilterTest.java +++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/test/java/org/openecomp/sdc/itempermissions/servlet/PermissionsFilterTest.java @@ -33,8 +33,9 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mockito.Spy; import org.openecomp.sdc.itempermissions.PermissionsServices; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.Test; +import org.junit.Before; + public class PermissionsFilterTest { @@ -45,7 +46,7 @@ public class PermissionsFilterTest { @Spy private PermissionsFilter permissionsFilter; - @BeforeMethod + @Before public void setUp() { MockitoAnnotations.initMocks(this); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilderTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilderTest.java index 1e643fa787..3cf91f1f32 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilderTest.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/OrchestrationTemplateFileExtensionErrorBuilderTest.java @@ -1,26 +1,35 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdc.vendorsoftwareproduct.dao.errors; import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_EXTENSION; -import org.junit.Before; +import org.junit.Assert; import org.junit.Test; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; -import org.testng.Assert; public class OrchestrationTemplateFileExtensionErrorBuilderTest { - private OrchestrationTemplateFileExtensionErrorBuilder orchestrationTemplateFileExtensionErrorBuilder; - - @Before - public void setUp() { - orchestrationTemplateFileExtensionErrorBuilder = new OrchestrationTemplateFileExtensionErrorBuilder(); - } - @Test - public void shouldReturnInvalidExtentionErrorCode(){ + public void shouldReturnInvalidExtentionErrorCode() { + OrchestrationTemplateFileExtensionErrorBuilder orchestrationTemplateFileExtensionErrorBuilder = + new OrchestrationTemplateFileExtensionErrorBuilder(); ErrorCode actual = orchestrationTemplateFileExtensionErrorBuilder.build(); - Assert.assertEquals(actual.category(), ErrorCategory.APPLICATION); - Assert.assertEquals(actual.id(), INVALID_EXTENSION); + Assert.assertEquals(ErrorCategory.APPLICATION, actual.category()); + Assert.assertEquals(INVALID_EXTENSION,actual.id()); } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductCreationFailedBuilderTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductCreationFailedBuilderTest.java index 921881d322..150fcc50f3 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductCreationFailedBuilderTest.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductCreationFailedBuilderTest.java @@ -1,12 +1,28 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdc.vendorsoftwareproduct.dao.errors; import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.FAILED_TO_CREATE_VSP; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; -import org.testng.Assert; + public class VendorSoftwareProductCreationFailedBuilderTest { @@ -21,7 +37,7 @@ public class VendorSoftwareProductCreationFailedBuilderTest { @Test public void shouldReturnVspNotFoundErrorCode(){ ErrorCode actual = vendorSoftwareProductCreationFailedBuilder.build(); - Assert.assertEquals(actual.category(), ErrorCategory.APPLICATION); - Assert.assertEquals(actual.id(), FAILED_TO_CREATE_VSP); + Assert.assertEquals(ErrorCategory.APPLICATION, actual.category()); + Assert.assertEquals(FAILED_TO_CREATE_VSP, actual.id()); } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductNotFoundErrorBuilderTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductNotFoundErrorBuilderTest.java index 75e6b1f6df..9268178fbd 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductNotFoundErrorBuilderTest.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/errors/VendorSoftwareProductNotFoundErrorBuilderTest.java @@ -1,27 +1,35 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdc.vendorsoftwareproduct.dao.errors; import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_NOT_FOUND; -import org.junit.Before; +import org.junit.Assert; import org.junit.Test; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; -import org.testng.Assert; public class VendorSoftwareProductNotFoundErrorBuilderTest { - private static final String VSP_ID = "testVsp1"; - private VendorSoftwareProductNotFoundErrorBuilder vendorSoftwareProductNotFoundErrorBuilder; - - @Before - public void setUp() { - vendorSoftwareProductNotFoundErrorBuilder = new VendorSoftwareProductNotFoundErrorBuilder(VSP_ID); - } - @Test - public void shouldReturnVspNotFoundErrorCode(){ + public void shouldReturnVspNotFoundErrorCode() { + VendorSoftwareProductNotFoundErrorBuilder vendorSoftwareProductNotFoundErrorBuilder = + new VendorSoftwareProductNotFoundErrorBuilder("testVsp1"); ErrorCode actual = vendorSoftwareProductNotFoundErrorBuilder.build(); - Assert.assertEquals(actual.category(), ErrorCategory.APPLICATION); - Assert.assertEquals(actual.id(), VSP_NOT_FOUND); + Assert.assertEquals(ErrorCategory.APPLICATION, actual.category()); + Assert.assertEquals(VSP_NOT_FOUND, actual.id()); } } -- cgit 1.2.3-korg