diff options
Diffstat (limited to 'catalog-be/src/test')
8 files changed, 210 insertions, 613 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionTests.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionTests.java index 2af413e6ed..5f7929c70a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionTests.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionTests.java @@ -22,12 +22,12 @@ package org.openecomp.sdc.be.components.lifecycle; import fj.data.Either; import org.apache.http.HttpStatus; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic; import org.openecomp.sdc.be.components.impl.exceptions.ComponentException; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -50,13 +50,15 @@ import org.openecomp.sdc.exception.ResponseFormat; import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; -@RunWith(MockitoJUnitRunner.Silent.class) -public class CertificationChangeTransitionTests extends LifecycleTestBase { +@ExtendWith(MockitoExtension.class) +class CertificationChangeTransitionTests extends LifecycleTestBase { @Mock private ServiceBusinessLogic serviceBusinessLogic; @@ -71,10 +73,7 @@ public class CertificationChangeTransitionTests extends LifecycleTestBase { private static String SERVICE_ID = "serviceId"; private static String SERVICE_ID_CERTIFIED = "serviceIdCert"; - - - - @Before + @BeforeEach public void setup() { super.setup(); changeTransition = new CertificationChangeTransition(serviceBusinessLogic, LifeCycleTransitionEnum.CERTIFY, componentsUtils, toscaElementLifecycleOperation, toscaOperationFacade, janusGraphDao); @@ -97,7 +96,7 @@ public class CertificationChangeTransitionTests extends LifecycleTestBase { } @Test - public void testVFCMTStateValidation(){ + void testVFCMTStateValidation() { Either<? extends Component, ResponseFormat> changeStateResult; resource = createResourceVFCMTObject(); resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); @@ -109,7 +108,7 @@ public class CertificationChangeTransitionTests extends LifecycleTestBase { } @Test - public void testCheckoutStateValidation() { + void testCheckoutStateValidation() { Either<? extends Component, ResponseFormat> changeStateResult; resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); @@ -125,7 +124,7 @@ public class CertificationChangeTransitionTests extends LifecycleTestBase { } @Test - public void testPnfValidation() { + void testPnfValidation() { Either<? extends Component, ResponseFormat> changeStateResult; resource.setResourceType(ResourceTypeEnum.PNF); resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); @@ -141,7 +140,7 @@ public class CertificationChangeTransitionTests extends LifecycleTestBase { } @Test - public void testCRValidation() { + void testCRValidation() { Either<? extends Component, ResponseFormat> changeStateResult; resource.setResourceType(ResourceTypeEnum.CR); resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); @@ -157,7 +156,7 @@ public class CertificationChangeTransitionTests extends LifecycleTestBase { } @Test - public void testVSPIsArchivedValidation(){ + void testVSPIsArchivedValidation() { Resource resource = createResourceObject(); resource.setVspArchived(true); @@ -182,14 +181,14 @@ public class CertificationChangeTransitionTests extends LifecycleTestBase { @Test - public void testValidateAllResourceInstanceCertified_SuccessWithoutRI() { + void testValidateAllResourceInstanceCertified_SuccessWithoutRI() { Resource resource = new Resource(); Either<Boolean, ResponseFormat> validateAllResourceInstanceCertified = changeTransition.validateAllResourceInstanceCertified(resource); assertTrue(validateAllResourceInstanceCertified.isLeft()); } @Test - public void testValidateAllResourceInstanceCertified_SuccessWithCertifiedResources() { + void testValidateAllResourceInstanceCertified_SuccessWithCertifiedResources() { Resource resource = new Resource(); List<ComponentInstance> riList = new ArrayList<>(); ComponentInstance ri = new ComponentInstance(); @@ -202,7 +201,7 @@ public class CertificationChangeTransitionTests extends LifecycleTestBase { } @Test - public void testValidateAllResourceInstanceCertified_FailWithUnCertifiedResourcesMinorVersion() { + void testValidateAllResourceInstanceCertified_FailWithUnCertifiedResourcesMinorVersion() { Resource resource = createVFWithRI("0.3"); simulateCertifiedVersionExistForRI(); @@ -217,7 +216,7 @@ public class CertificationChangeTransitionTests extends LifecycleTestBase { } @Test - public void testValidateAllResourceInstanceCertified_FailWithUnCertifiedResourcesMajorVersion() { + void testValidateAllResourceInstanceCertified_FailWithUnCertifiedResourcesMajorVersion() { Resource resource = createVFWithRI("1.3"); simulateCertifiedVersionExistForRI(); @@ -232,7 +231,7 @@ public class CertificationChangeTransitionTests extends LifecycleTestBase { } @Test - public void testDeploymentArtifactRestriction() { + void testDeploymentArtifactRestriction() { Either<? extends Component, ResponseFormat> changeStateResult; service.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); @@ -242,7 +241,7 @@ public class CertificationChangeTransitionTests extends LifecycleTestBase { .thenReturn(Either.left(ModelConverter.convertToToscaElement(serviceAfterCertify))); when(serviceBusinessLogic.generateHeatEnvArtifacts(service, owner, false, true)).thenReturn(result); when(serviceBusinessLogic.generateVfModuleArtifacts(service, owner, false, true)).thenReturn(result); - when(serviceBusinessLogic.populateToscaArtifacts(service, owner, true, false, false)).thenReturn(resultArtifacts); + when(serviceBusinessLogic.populateToscaArtifacts(any(Service.class), eq(owner), eq(true), eq(true), eq(false))).thenReturn(resultArtifacts); changeStateResult = changeTransition.changeState(ComponentTypeEnum.SERVICE, service, serviceBusinessLogic, user, owner, false, true); assertTrue(changeStateResult.isLeft()); } @@ -266,4 +265,4 @@ public class CertificationChangeTransitionTests extends LifecycleTestBase { return resource; } -}
\ No newline at end of file +} diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionValidationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionValidationTest.java index 4e21350083..ae4cf47a9f 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionValidationTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionValidationTest.java @@ -7,9 +7,9 @@ * 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. @@ -21,8 +21,8 @@ package org.openecomp.sdc.be.components.lifecycle; import fj.data.Either; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -35,9 +35,9 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.common.api.UserRoleEnum; import org.openecomp.sdc.exception.ResponseFormat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class CertificationChangeTransitionValidationTest extends LifecycleTestBase { +class CertificationChangeTransitionValidationTest extends LifecycleTestBase { private CertificationChangeTransition certifyTransitionObj = null; @Mock @@ -45,11 +45,11 @@ public class CertificationChangeTransitionValidationTest extends LifecycleTestBa private User owner = null; - Resource resource; - Service service; + private Resource resource; + private Service service; @SuppressWarnings("unchecked") - @Before + @BeforeEach public void setup() { super.setup(); @@ -66,14 +66,14 @@ public class CertificationChangeTransitionValidationTest extends LifecycleTestBa } @Test - public void testVFCMTStateValidation(){ + void testVFCMTStateValidation() { Resource resource = createResourceVFCMTObject(); Either<Boolean, ResponseFormat> validateBeforeTransition = certifyTransitionObj.validateBeforeTransition(resource, ComponentTypeEnum.RESOURCE, user, owner, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); assertTrue(validateBeforeTransition.isLeft()); } @Test - public void testStateCheckInValidationSuccess() { + void testStateCheckInValidationSuccess() { Either<Boolean, ResponseFormat> changeStateResult = certifyTransitionObj.validateBeforeTransition(service, ComponentTypeEnum.SERVICE, user, owner, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); assertTrue(changeStateResult.isLeft()); @@ -82,16 +82,16 @@ public class CertificationChangeTransitionValidationTest extends LifecycleTestBa } @Test - public void testStateCheckOutValidationSuccess() { + void testStateCheckOutValidationSuccess() { Either<Boolean, ResponseFormat> changeStateResult = certifyTransitionObj.validateBeforeTransition(service, ComponentTypeEnum.SERVICE, user, owner, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); assertTrue(changeStateResult.isLeft()); changeStateResult = certifyTransitionObj.validateBeforeTransition(resource, ComponentTypeEnum.RESOURCE, user, owner, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); assertTrue(changeStateResult.isLeft()); } - + @Test - public void testStateCertifyValidationFail() { + void testStateCertifyValidationFail() { Either<Boolean, ResponseFormat> validateBeforeTransition = certifyTransitionObj.validateBeforeTransition(service, ComponentTypeEnum.SERVICE, user, owner, LifecycleStateEnum.CERTIFIED); assertValidationStateErrorResponse(validateBeforeTransition); @@ -100,7 +100,7 @@ public class CertificationChangeTransitionValidationTest extends LifecycleTestBa } @Test - public void testRolesSuccess() { + void testRolesSuccess() { resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); assertSuccessWithResourceAndService(); @@ -111,7 +111,7 @@ public class CertificationChangeTransitionValidationTest extends LifecycleTestBa } @Test - public void testRolesFail() { + void testRolesFail() { user.setRole(UserRoleEnum.TESTER.getName()); assertBeforeTransitionRoleFalis(); assertBeforeTransitionRoleFalis(); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckinTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckinTest.java index 18a17a9797..ae18f75b57 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckinTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckinTest.java @@ -7,9 +7,9 @@ * 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. @@ -21,8 +21,8 @@ package org.openecomp.sdc.be.components.lifecycle; import fj.data.Either; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.model.LifecycleStateEnum; @@ -32,24 +32,24 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.exception.ResponseFormat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class CheckinTest extends LifecycleTestBase { +class CheckinTest extends LifecycleTestBase { private CheckinTransition checkinObj = null; - @Before + @BeforeEach public void setup() { super.setup(); // checkout transition object - checkinObj = new CheckinTransition(componentsUtils, toscaElementLifecycleOperation, toscaOperationFacade, janusGraphDao, vesionUpdateHandler); + checkinObj = new CheckinTransition(componentsUtils, toscaElementLifecycleOperation, toscaOperationFacade, janusGraphDao, vesionUpdateHandler); checkinObj.setLifeCycleOperation(toscaElementLifecycleOperation); checkinObj.setConfigurationManager(configurationManager); } @Test - public void testSimpleCheckin() { + void testSimpleCheckin() { Either<Boolean, ResponseFormat> changeStateResult; Resource resource = createResourceObject(); @@ -63,7 +63,7 @@ public class CheckinTest extends LifecycleTestBase { } @Test - public void testSimpleServiceCheckin() { + void testSimpleServiceCheckin() { Either<Boolean, ResponseFormat> changeStateResult; Service service = createServiceObject(); @@ -77,7 +77,7 @@ public class CheckinTest extends LifecycleTestBase { } @Test - public void testCheckinTwiceValidation() { + void testCheckinTwiceValidation() { Either<Resource, ResponseFormat> changeStateResult; Resource resource = createResourceObject(); @@ -95,7 +95,7 @@ public class CheckinTest extends LifecycleTestBase { } @Test - public void testServiceCheckinTwiceValidation() { + void testServiceCheckinTwiceValidation() { Either<Service, ResponseFormat> changeStateResult; Service service = createServiceObject(); @@ -112,7 +112,7 @@ public class CheckinTest extends LifecycleTestBase { } @Test - public void testCheckoutByAnotherUserValidation() { + void testCheckoutByAnotherUserValidation() { Either<Resource, ResponseFormat> changeStateResult; Resource resource = createResourceObject(); @@ -138,7 +138,7 @@ public class CheckinTest extends LifecycleTestBase { } @Test - public void testServiceCheckoutByAnotherUserValidation() { + void testServiceCheckoutByAnotherUserValidation() { Either<Service, ResponseFormat> changeStateResult; Service service = createServiceObject(); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java index 8650f9a10b..641ae65ed8 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java @@ -20,11 +20,9 @@ package org.openecomp.sdc.be.components.lifecycle; -import static org.junit.jupiter.api.Assertions.assertTrue; - import fj.data.Either; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.openecomp.sdc.be.components.csar.CsarArtifactsAndGroupsBusinessLogic; import org.openecomp.sdc.be.components.csar.CsarBusinessLogic; @@ -40,7 +38,6 @@ import org.openecomp.sdc.be.components.impl.PropertyBusinessLogic; import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic; import org.openecomp.sdc.be.components.impl.ResourceImportManager; import org.openecomp.sdc.be.components.merge.resource.ResourceDataMergeBusinessLogic; -import org.openecomp.sdc.be.components.merge.utils.MergeInstanceUtils; import org.openecomp.sdc.be.components.validation.component.ComponentContactIdValidator; import org.openecomp.sdc.be.components.validation.component.ComponentNameValidator; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -54,17 +51,20 @@ import org.openecomp.sdc.be.model.operations.impl.ModelOperation; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.exception.ResponseFormat; -public class CheckoutTest extends LifecycleTestBase { - - private CheckoutTransition checkoutObj = null; - private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class); - private final ResourceImportManager resourceImportManager = Mockito.mock(ResourceImportManager.class); - private final InputsBusinessLogic inputsBusinessLogic = Mockito.mock(InputsBusinessLogic.class); - private final OutputsBusinessLogic outputsBusinessLogic = Mockito.mock(OutputsBusinessLogic.class); - private final CompositionBusinessLogic compositionBusinessLogic = Mockito.mock(CompositionBusinessLogic.class); - private final ResourceDataMergeBusinessLogic resourceDataMergeBusinessLogic = Mockito.mock(ResourceDataMergeBusinessLogic.class); - private final CsarArtifactsAndGroupsBusinessLogic csarArtifactsAndGroupsBusinessLogic = Mockito.mock(CsarArtifactsAndGroupsBusinessLogic.class); - private final MergeInstanceUtils mergeInstanceUtils = Mockito.mock(MergeInstanceUtils.class); +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +class CheckoutTest extends LifecycleTestBase { + + private CheckoutTransition checkoutObj = null; + private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class); + private final ResourceImportManager resourceImportManager = Mockito.mock(ResourceImportManager.class); + private final InputsBusinessLogic inputsBusinessLogic = Mockito.mock(InputsBusinessLogic.class); + private final OutputsBusinessLogic outputsBusinessLogic = Mockito.mock(OutputsBusinessLogic.class); + private final CompositionBusinessLogic compositionBusinessLogic = Mockito.mock(CompositionBusinessLogic.class); + private final ResourceDataMergeBusinessLogic resourceDataMergeBusinessLogic = Mockito.mock(ResourceDataMergeBusinessLogic.class); + private final CsarArtifactsAndGroupsBusinessLogic csarArtifactsAndGroupsBusinessLogic = Mockito.mock(CsarArtifactsAndGroupsBusinessLogic.class); private final UiComponentDataConverter uiComponentDataConverter = Mockito.mock(UiComponentDataConverter.class); private final CsarBusinessLogic csarBusinessLogic = Mockito.mock(CsarBusinessLogic.class); private final PropertyBusinessLogic propertyBusinessLogic = Mockito.mock(PropertyBusinessLogic.class); @@ -77,20 +77,20 @@ public class CheckoutTest extends LifecycleTestBase { private final ModelOperation modelOperation = Mockito.mock(ModelOperation.class); ResourceBusinessLogic bl = new ResourceBusinessLogic(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, - groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation, artifactsBusinessLogic, - componentInstanceBusinessLogic, resourceImportManager, inputsBusinessLogic, outputsBusinessLogic, compositionBusinessLogic, - resourceDataMergeBusinessLogic, csarArtifactsAndGroupsBusinessLogic, uiComponentDataConverter, csarBusinessLogic, artifactToscaOperation, - propertyBusinessLogic, componentContactIdValidator, componentNameValidator, componentTagsValidator, componentValidator, - componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator, policyBusinessLogic, modelBusinessLogic, - dataTypeBusinessLogic, policyTypeBusinessLogic, modelOperation); - - @Before + groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation, artifactsBusinessLogic, + componentInstanceBusinessLogic, resourceImportManager, inputsBusinessLogic, outputsBusinessLogic, compositionBusinessLogic, + resourceDataMergeBusinessLogic, csarArtifactsAndGroupsBusinessLogic, uiComponentDataConverter, csarBusinessLogic, artifactToscaOperation, + propertyBusinessLogic, componentContactIdValidator, componentNameValidator, componentTagsValidator, componentValidator, + componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator, policyBusinessLogic, modelBusinessLogic, + dataTypeBusinessLogic, policyTypeBusinessLogic, modelOperation); + + @BeforeEach public void setup() { super.setup(); // checkout transition object checkoutObj = new CheckoutTransition(componentsUtils, toscaElementLifecycleOperation, toscaOperationFacade, - janusGraphDao); + janusGraphDao); checkoutObj.setLifeCycleOperation(toscaElementLifecycleOperation); checkoutObj.setConfigurationManager(configurationManager); bl.setToscaOperationFacade(toscaOperationFacade); @@ -98,73 +98,74 @@ public class CheckoutTest extends LifecycleTestBase { } - @Test - public void testCheckoutStateValidation() { - Either<? extends Component, ResponseFormat> changeStateResult; - Resource resource = createResourceObject(); + @Test + void testCheckoutStateValidation() { + Either<? extends Component, ResponseFormat> changeStateResult; + Resource resource = createResourceObject(); - resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - Either<User, ResponseFormat> ownerResponse = checkoutObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE); - assertTrue(ownerResponse.isLeft()); - User owner = ownerResponse.left().value(); - changeStateResult = checkoutObj.changeState(ComponentTypeEnum.RESOURCE, resource, bl, user, owner, false, false); - assertTrue(changeStateResult.isLeft()); + resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); + Either<User, ResponseFormat> ownerResponse = checkoutObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE); + assertTrue(ownerResponse.isLeft()); + User owner = ownerResponse.left().value(); + when(toscaOperationFacade.updateToscaElement(any(Component.class))).thenReturn(Either.left(resource)); + changeStateResult = checkoutObj.changeState(ComponentTypeEnum.RESOURCE, resource, bl, user, owner, false, false); + assertTrue(changeStateResult.isLeft()); - resource.setLifecycleState(LifecycleStateEnum.CERTIFIED); + resource.setLifecycleState(LifecycleStateEnum.CERTIFIED); changeStateResult = checkoutObj.changeState(ComponentTypeEnum.RESOURCE, resource, bl, user, owner, false, false); assertTrue(changeStateResult.isLeft()); } - @Test - public void testAlreadyCheckout() { - Either<Resource, ResponseFormat> changeStateResult; - Resource resource = createResourceObject(); - - resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); - Either<User, ResponseFormat> ownerResponse = checkoutObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE); - assertTrue(ownerResponse.isLeft()); - User owner = ownerResponse.left().value(); - Either<Boolean, ResponseFormat> validateBeforeTransition = checkoutObj.validateBeforeTransition(resource, ComponentTypeEnum.RESOURCE, user, - owner, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); - assertTrue(validateBeforeTransition.isRight()); - changeStateResult = Either.right(validateBeforeTransition.right().value()); - - assertTrue(changeStateResult.isRight()); - assertResponse(changeStateResult, ActionStatus.COMPONENT_IN_CHECKOUT_STATE, resource.getName(), - ComponentTypeEnum.RESOURCE.name().toLowerCase(), user.getFirstName(), user.getLastName(), user.getUserId()); - - } - - @Test - public void testRoles() { - Either<Resource, ResponseFormat> changeStateResult; - Resource resource = createResourceObject(); - - resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - - User modifier = new User(); - modifier.setUserId("modifier"); - modifier.setFirstName("Albert"); - modifier.setLastName("Einstein"); - modifier.setRole(Role.DESIGNER.name()); - Either<User, ResponseFormat> ownerResponse = checkoutObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE); - assertTrue(ownerResponse.isLeft()); - User owner = ownerResponse.left().value(); - // changeStateResult = checkoutObj.changeStateOperation(resource, - // modifier, owner); - Either<Boolean, ResponseFormat> validateBeforeTransition = checkoutObj.validateBeforeTransition(resource, ComponentTypeEnum.RESOURCE, - modifier, owner, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - assertTrue(validateBeforeTransition.isLeft()); - - modifier.setRole(Role.TESTER.name()); - // changeStateResult = checkoutObj.changeStateOperation(resource, - // modifier, owner); - validateBeforeTransition = checkoutObj.validateBeforeTransition(resource, ComponentTypeEnum.RESOURCE, modifier, owner, - LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - assertTrue(validateBeforeTransition.isRight()); - changeStateResult = Either.right(validateBeforeTransition.right().value()); - assertResponse(changeStateResult, ActionStatus.RESTRICTED_OPERATION); - - } + @Test + void testAlreadyCheckout() { + Either<Resource, ResponseFormat> changeStateResult; + Resource resource = createResourceObject(); + + resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); + Either<User, ResponseFormat> ownerResponse = checkoutObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE); + assertTrue(ownerResponse.isLeft()); + User owner = ownerResponse.left().value(); + Either<Boolean, ResponseFormat> validateBeforeTransition = checkoutObj.validateBeforeTransition(resource, ComponentTypeEnum.RESOURCE, user, + owner, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); + assertTrue(validateBeforeTransition.isRight()); + changeStateResult = Either.right(validateBeforeTransition.right().value()); + + assertTrue(changeStateResult.isRight()); + assertResponse(changeStateResult, ActionStatus.COMPONENT_IN_CHECKOUT_STATE, resource.getName(), + ComponentTypeEnum.RESOURCE.name().toLowerCase(), user.getFirstName(), user.getLastName(), user.getUserId()); + + } + + @Test + void testRoles() { + Either<Resource, ResponseFormat> changeStateResult; + Resource resource = createResourceObject(); + + resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); + + User modifier = new User(); + modifier.setUserId("modifier"); + modifier.setFirstName("Albert"); + modifier.setLastName("Einstein"); + modifier.setRole(Role.DESIGNER.name()); + Either<User, ResponseFormat> ownerResponse = checkoutObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE); + assertTrue(ownerResponse.isLeft()); + User owner = ownerResponse.left().value(); + // changeStateResult = checkoutObj.changeStateOperation(resource, + // modifier, owner); + Either<Boolean, ResponseFormat> validateBeforeTransition = checkoutObj.validateBeforeTransition(resource, ComponentTypeEnum.RESOURCE, + modifier, owner, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); + assertTrue(validateBeforeTransition.isLeft()); + + modifier.setRole(Role.TESTER.name()); + // changeStateResult = checkoutObj.changeStateOperation(resource, + // modifier, owner); + validateBeforeTransition = checkoutObj.validateBeforeTransition(resource, ComponentTypeEnum.RESOURCE, modifier, owner, + LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); + assertTrue(validateBeforeTransition.isRight()); + changeStateResult = Either.right(validateBeforeTransition.right().value()); + assertResponse(changeStateResult, ActionStatus.RESTRICTED_OPERATION); + + } } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogicTest.java index bcec330409..9b6a1a39de 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogicTest.java @@ -21,13 +21,13 @@ package org.openecomp.sdc.be.components.lifecycle; import fj.data.Either; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.openecomp.sdc.be.catalog.enums.ChangeTypeEnum; import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -50,8 +50,8 @@ import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; -@RunWith(MockitoJUnitRunner.class) -public class LifecycleBusinessLogicTest extends LifecycleTestBase { +@ExtendWith(MockitoExtension.class) +class LifecycleBusinessLogicTest extends LifecycleTestBase { @Mock private IGraphLockOperation graphLockOperation; @@ -74,7 +74,7 @@ public class LifecycleBusinessLogicTest extends LifecycleTestBase { @Mock CatalogOperation catalogOperations; - @Before + @BeforeEach public void before() { lifecycleBusinessLogic.init(); Map<String, LifeCycleTransition> startTransition = lifecycleBusinessLogic.getStartTransition(); @@ -82,9 +82,8 @@ public class LifecycleBusinessLogicTest extends LifecycleTestBase { startTransition.put(LifeCycleTransitionEnum.CERTIFY.name(), certificationChangeTransition); } - @Test - public void certifyCheckedOutComponent() { + void certifyCheckedOutComponent() { String ID_BEFORE_CHECKIN = "id"; String ID_AFTER_CHECKIN = "id2"; String ID_AFTER_CERTIFY = "id3"; @@ -113,7 +112,7 @@ public class LifecycleBusinessLogicTest extends LifecycleTestBase { when(certificationChangeTransition.getComponentOwner(serviceAfterCheckIn, ComponentTypeEnum.SERVICE)).thenReturn(Either.left(modifier)); when(certificationChangeTransition.validateBeforeTransition(serviceAfterCheckIn, ComponentTypeEnum.SERVICE, modifier, modifier, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, remarks)).thenReturn(Either.left(true)); Mockito.doReturn(Either.left(serviceAfterCertify)).when(certificationChangeTransition).changeState(ComponentTypeEnum.SERVICE, serviceAfterCheckIn, serviceBusinessLogic, modifier, modifier, false, false); - when(catalogOperations.updateCatalog(ChangeTypeEnum.LIFECYCLE,serviceAfterCertify)).thenReturn(ActionStatus.OK); + when(catalogOperations.updateCatalog(ChangeTypeEnum.LIFECYCLE, serviceAfterCertify)).thenReturn(ActionStatus.OK); Either<? extends Component, ResponseFormat> serviceAfterCertificationEither = lifecycleBusinessLogic.changeComponentState(ComponentTypeEnum.SERVICE, ID_BEFORE_CHECKIN, modifier, LifeCycleTransitionEnum.CERTIFY, remarks, false, true); Component serviceAfterCertification = serviceAfterCertificationEither.left().value(); assertThat(serviceAfterCertification.getUniqueId()).isEqualTo(ID_AFTER_CERTIFY); @@ -121,7 +120,7 @@ public class LifecycleBusinessLogicTest extends LifecycleTestBase { } @Test - public void certifyCheckedInComponent() { + void certifyCheckedInComponent() { String ID_BEFORE_CERTIFY = "id"; String ID_AFTER_CERTIFY = "id2"; Service service = createServiceObject(); @@ -140,7 +139,7 @@ public class LifecycleBusinessLogicTest extends LifecycleTestBase { when(certificationChangeTransition.getComponentOwner(service, ComponentTypeEnum.SERVICE)).thenReturn(Either.left(modifier)); when(certificationChangeTransition.validateBeforeTransition(service, ComponentTypeEnum.SERVICE, modifier, modifier, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN, remarks)).thenReturn(Either.left(true)); Mockito.doReturn(Either.left(serviceAfterCertify)).when(certificationChangeTransition).changeState(ComponentTypeEnum.SERVICE, service, serviceBusinessLogic, modifier, modifier, false, false); - when(catalogOperations.updateCatalog(ChangeTypeEnum.LIFECYCLE,serviceAfterCertify)).thenReturn(ActionStatus.OK); + when(catalogOperations.updateCatalog(ChangeTypeEnum.LIFECYCLE, serviceAfterCertify)).thenReturn(ActionStatus.OK); Either<? extends Component, ResponseFormat> serviceAfterCertificationEither = lifecycleBusinessLogic.changeComponentState(ComponentTypeEnum.SERVICE, ID_BEFORE_CERTIFY, modifier, LifeCycleTransitionEnum.CERTIFY, remarks, false, true); Component serviceAfterCertification = serviceAfterCertificationEither.left().value(); assertThat(serviceAfterCertification.getUniqueId()).isEqualTo(ID_AFTER_CERTIFY); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java index a6ead78dcf..e0015ddf69 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java @@ -7,9 +7,9 @@ * 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. @@ -21,7 +21,7 @@ package org.openecomp.sdc.be.components.lifecycle; import fj.data.Either; -import org.junit.BeforeClass; +import org.junit.jupiter.api.BeforeAll; import org.mockito.InjectMocks; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; @@ -86,7 +86,8 @@ public class LifecycleTestBase extends ComponentBusinessLogicMock { protected WebApplicationContext webAppContext = Mockito.mock(WebApplicationContext.class); protected ToscaElementLifecycleOperation toscaElementLifecycleOperation = Mockito.mock(ToscaElementLifecycleOperation.class); protected VesionUpdateHandler vesionUpdateHandler = Mockito.mock(VesionUpdateHandler.class); - protected ArtifactsBusinessLogic artifactsManager = Mockito.mock(ArtifactsBusinessLogic.class);; + protected ArtifactsBusinessLogic artifactsManager = Mockito.mock(ArtifactsBusinessLogic.class); + ; protected User user = null; protected Resource resourceResponse; protected Service serviceResponse; @@ -102,7 +103,7 @@ public class LifecycleTestBase extends ComponentBusinessLogicMock { protected final NodeFilterOperation serviceFilterOperation = Mockito.mock(NodeFilterOperation.class); protected final NodeFilterValidator serviceFilterValidator = Mockito.mock(NodeFilterValidator.class); - @BeforeClass + @BeforeAll public static void setupClass() { ExternalConfiguration.setAppName("catalog-be"); new ConfigurationManager(new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be")); @@ -191,7 +192,7 @@ public class LifecycleTestBase extends ComponentBusinessLogicMock { protected Resource createResourceVFCMTObject() { ResourceMetadataDataDefinition rMetadataDataDefinition = new ResourceMetadataDataDefinition(); rMetadataDataDefinition.setResourceType(ResourceTypeEnum.VFCMT); - ComponentMetadataDefinition cMetadataDataDefinition = new ComponentMetadataDefinition(rMetadataDataDefinition) ; + ComponentMetadataDefinition cMetadataDataDefinition = new ComponentMetadataDefinition(rMetadataDataDefinition); Resource resource = new Resource(cMetadataDataDefinition); resource.setUniqueId("rid"); @@ -212,6 +213,7 @@ public class LifecycleTestBase extends ComponentBusinessLogicMock { return resource; } + protected Service createServiceObject() { return createServiceObject("sid"); } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTest.java index 9b7c23f07a..5df6c6b07a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTest.java @@ -7,9 +7,9 @@ * 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. @@ -21,8 +21,8 @@ package org.openecomp.sdc.be.components.lifecycle; import fj.data.Either; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.model.LifecycleStateEnum; @@ -31,26 +31,26 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.exception.ResponseFormat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class UndoCheckoutTest extends LifecycleTestBase { +class UndoCheckoutTest extends LifecycleTestBase { private UndoCheckoutTransition undoCheckoutObj = null; - @Before + @BeforeEach public void setup() { super.setup(); // checkout transition object undoCheckoutObj = new UndoCheckoutTransition(componentsUtils, toscaElementLifecycleOperation, toscaOperationFacade, - janusGraphDao); + janusGraphDao); undoCheckoutObj.setLifeCycleOperation(toscaElementLifecycleOperation); undoCheckoutObj.setConfigurationManager(configurationManager); } @Test - public void testResourceNotCheckedOutValidation() { + void testResourceNotCheckedOutValidation() { Either<Resource, ResponseFormat> changeStateResult; Resource resource = createResourceObject(); @@ -77,7 +77,7 @@ public class UndoCheckoutTest extends LifecycleTestBase { } @Test - public void testDifferentResourceOwnerValidation() { + void testDifferentResourceOwnerValidation() { Either<Resource, ResponseFormat> changeStateResult; Resource resource = createResourceObject(); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java index 36c3fae376..1585901734 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java @@ -7,9 +7,9 @@ * 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. @@ -20,448 +20,44 @@ package org.openecomp.sdc.be.tosca.model; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; - - -public class ToscaMetadataTest { - - private ToscaMetadata createTestSubject() { - return new ToscaMetadata(); - } - - - @Test - public void testServiceFunction() { - ToscaMetadata testSubject = createTestSubject(); - testSubject.setServiceFunction("testServiceFunction"); - assertEquals("testServiceFunction", testSubject.getServiceFunction()); - } - - @Test - public void testInstantiationType() { - ToscaMetadata testSubject = createTestSubject(); - testSubject.setInstantiationType("testInstantiationType"); - assertEquals("testInstantiationType", testSubject.getInstantiationType()); - } - - @Test - public void testEcompGeneratedNaming() { - ToscaMetadata testSubject = createTestSubject(); - testSubject.setEcompGeneratedNaming(null); - assertEquals(false, testSubject.isEcompGeneratedNaming()); - testSubject.setEcompGeneratedNaming(true); - assertEquals(true, testSubject.isEcompGeneratedNaming()); - } - - @Test - public void testServiceEcompNaming() { - ToscaMetadata testSubject = createTestSubject(); - testSubject.setServiceEcompNaming(null); - assertEquals(false, testSubject.getServiceEcompNaming()); - testSubject.setServiceEcompNaming(false); - assertEquals(false, testSubject.getServiceEcompNaming()); - } - - @Test - public void testSourceModelInvariant() { - ToscaMetadata testSubject = createTestSubject(); - testSubject.setSourceModelInvariant("sourceModelInvariant"); - assertEquals("sourceModelInvariant", testSubject.getSourceModelInvariant()); - } - - @Test - public void testSourceModelName() { - ToscaMetadata testSubject = createTestSubject(); - testSubject.setSourceModelName("sourceModelName"); - assertEquals("sourceModelName", testSubject.getSourceModelName()); - } - - @Test - public void testSourceModelUuid() { - ToscaMetadata testSubject = createTestSubject(); - testSubject.setSourceModelUuid("sourceModelUuid"); - assertEquals("sourceModelUuid", testSubject.getSourceModelUuid()); - } - - @Test - public void testEnvironmentContext() { - ToscaMetadata testSubject = createTestSubject(); - testSubject.setEnvironmentContext("environmentContext"); - assertEquals("environmentContext", testSubject.getEnvironmentContext()); - } - - @Test - public void testGetName() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getName(); - } - - - @Test - public void testSetName() throws Exception { - ToscaMetadata testSubject; - String name = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setName(name); - } - - - @Test - public void testGetInvariantUUID() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInvariantUUID(); - } - - - @Test - public void testSetInvariantUUID() throws Exception { - ToscaMetadata testSubject; - String invariantUUID = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setInvariantUUID(invariantUUID); - } - - - @Test - public void testGetUUID() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getUUID(); - } - - - @Test - public void testSetUUID() throws Exception { - ToscaMetadata testSubject; - String uUID = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setUUID(uUID); - } - - - @Test - public void testGetDescription() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDescription(); - } - - - @Test - public void testSetDescription() throws Exception { - ToscaMetadata testSubject; - String description = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setDescription(description); - } - - - @Test - public void testGetType() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getType(); - } - - - @Test - public void testSetType() throws Exception { - ToscaMetadata testSubject; - String type = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setType(type); - } - - - @Test - public void testGetCategory() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCategory(); - } - - - @Test - public void testSetCategory() throws Exception { - ToscaMetadata testSubject; - String category = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setCategory(category); - } - - - @Test - public void testGetSubcategory() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getSubcategory(); - } - - - @Test - public void testSetSubcategory() throws Exception { - ToscaMetadata testSubject; - String subcategory = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setSubcategory(subcategory); - } - - - @Test - public void testGetResourceVendor() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceVendor(); - } - - - @Test - public void testSetResourceVendor() throws Exception { - ToscaMetadata testSubject; - String resourceVendor = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceVendor(resourceVendor); - } - - - @Test - public void testGetResourceVendorRelease() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceVendorRelease(); - } - - - @Test - public void testSetResourceVendorRelease() throws Exception { - ToscaMetadata testSubject; - String resourceVendorRelease = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceVendorRelease(resourceVendorRelease); - } - - - @Test - public void testGetResourceVendorModelNumber() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceVendorModelNumber(); - } - - - @Test - public void testSetResourceVendorModelNumber() throws Exception { - ToscaMetadata testSubject; - String resourceVendorModelNumber = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceVendorModelNumber(resourceVendorModelNumber); - } - - - @Test - public void testGetServiceType() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getServiceType(); - } - - - @Test - public void testSetServiceType() throws Exception { - ToscaMetadata testSubject; - String serviceType = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setServiceType(serviceType); - } - - - @Test - public void testGetServiceRole() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getServiceRole(); - } - - - @Test - public void testSetServiceRole() throws Exception { - ToscaMetadata testSubject; - String serviceRole = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setServiceRole(serviceRole); - } - - - @Test - public void testIsEcompGeneratedNaming() throws Exception { - ToscaMetadata testSubject; - Boolean result; - - // default test - testSubject = createTestSubject(); - result = testSubject.isEcompGeneratedNaming(); - } - - - @Test - public void testSetEcompGeneratedNaming() throws Exception { - ToscaMetadata testSubject; - Boolean ecompGeneratedNaming = null; - - // default test - testSubject = createTestSubject(); - testSubject.setEcompGeneratedNaming(ecompGeneratedNaming); - } - - - @Test - public void testIsNamingPolicy() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.isNamingPolicy(); - } - - - @Test - public void testSetNamingPolicy() throws Exception { - ToscaMetadata testSubject; - String namingPolicy = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setNamingPolicy(namingPolicy); - } - - - @Test - public void testGetServiceEcompNaming() throws Exception { - ToscaMetadata testSubject; - Boolean result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getServiceEcompNaming(); - } - - - @Test - public void testSetServiceEcompNaming() throws Exception { - ToscaMetadata testSubject; - Boolean serviceEcompNaming = null; - - // default test - testSubject = createTestSubject(); - testSubject.setServiceEcompNaming(serviceEcompNaming); - } - - - @Test - public void testGetVersion() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getVersion(); - } - - - @Test - public void testSetVersion() throws Exception { - ToscaMetadata testSubject; - String version = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setVersion(version); - } - - - @Test - public void testGetCustomizationUUID() throws Exception { - ToscaMetadata testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCustomizationUUID(); - } - - - @Test - public void testSetCustomizationUUID() throws Exception { - ToscaMetadata testSubject; - String customizationUUID = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setCustomizationUUID(customizationUUID); - } +import static org.junit.jupiter.api.Assertions.assertFalse; + +class ToscaMetadataTest { + + private ToscaMetadata testSubject; + + @BeforeEach + void setup() { + testSubject = new ToscaMetadata(); + } + + @Test + void testEcompGeneratedNaming() { + testSubject.setEcompGeneratedNaming(null); + assertEquals(false, testSubject.isEcompGeneratedNaming()); + testSubject.setEcompGeneratedNaming(true); + assertEquals(true, testSubject.isEcompGeneratedNaming()); + } + + @Test + void testServiceEcompNaming() { + testSubject.setServiceEcompNaming(null); + assertFalse(testSubject.getServiceEcompNaming()); + testSubject.setServiceEcompNaming(false); + assertFalse(testSubject.getServiceEcompNaming()); + } + + @Test + void testIsEcompGeneratedNaming() throws Exception { + assertFalse(testSubject.isEcompGeneratedNaming()); + } + + @Test + void testGetServiceEcompNaming() throws Exception { + assertFalse(testSubject.getServiceEcompNaming()); + } } |