diff options
author | vasraz <vasyl.razinkov@est.tech> | 2022-08-26 13:59:23 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2022-09-14 08:24:38 +0000 |
commit | e4a10c8950c35f21fd192f54c8a293af2dd02b1a (patch) | |
tree | a3f6760d9b9424b6fed62f2755ba079c02776f75 /catalog-be/src/test/java/org | |
parent | 1db6e26a7fa6b1afcf1562b239866198dc54ed92 (diff) |
Fix 'Optional license in onboarding'-bug
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Change-Id: I6b63629e834b8a5002372d6af59ae0a3a9460542
Issue-ID: SDC-3601
Diffstat (limited to 'catalog-be/src/test/java/org')
2 files changed, 78 insertions, 75 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java index cee47ec984..714ec20c10 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java @@ -322,7 +322,7 @@ class ResourceBusinessLogicTest { bl = new ResourceBusinessLogic(mockElementDao, groupOperation, groupInstanceOperation, groupTypeOperation, groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation, artifactManager, componentInstanceBusinessLogic, resourceImportManager, inputsBusinessLogic, outputsBusinessLogic, compositionBusinessLogic, resourceDataMergeBusinessLogic, - csarArtifactsAndGroupsBusinessLogic, mergeInstanceUtils, uiComponentDataConverter, csarBusinessLogic, + csarArtifactsAndGroupsBusinessLogic, uiComponentDataConverter, csarBusinessLogic, artifactToscaOperation, propertyBusinessLogic, componentContactIdValidator, componentNameValidator, componentTagsValidator, componentValidator, componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator, policyBusinessLogic, modelBusinessLogic, dataTypeBusinessLogic, policyTypeBusinessLogic, modelOperation); 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 765be0a779..8650f9a10b 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,6 +20,8 @@ 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; @@ -52,19 +54,17 @@ import org.openecomp.sdc.be.model.operations.impl.ModelOperation; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.exception.ResponseFormat; -import static org.junit.Assert.assertTrue; - 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); + 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); private final UiComponentDataConverter uiComponentDataConverter = Mockito.mock(UiComponentDataConverter.class); private final CsarBusinessLogic csarBusinessLogic = Mockito.mock(CsarBusinessLogic.class); private final PropertyBusinessLogic propertyBusinessLogic = Mockito.mock(PropertyBusinessLogic.class); @@ -78,11 +78,10 @@ public class CheckoutTest extends LifecycleTestBase { ResourceBusinessLogic bl = new ResourceBusinessLogic(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation, artifactsBusinessLogic, - componentInstanceBusinessLogic, resourceImportManager, inputsBusinessLogic, outputsBusinessLogic,compositionBusinessLogic, - resourceDataMergeBusinessLogic, csarArtifactsAndGroupsBusinessLogic, mergeInstanceUtils, - uiComponentDataConverter, csarBusinessLogic, artifactToscaOperation, propertyBusinessLogic, - componentContactIdValidator, componentNameValidator, componentTagsValidator, componentValidator, - componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator ,policyBusinessLogic, modelBusinessLogic, + componentInstanceBusinessLogic, resourceImportManager, inputsBusinessLogic, outputsBusinessLogic, compositionBusinessLogic, + resourceDataMergeBusinessLogic, csarArtifactsAndGroupsBusinessLogic, uiComponentDataConverter, csarBusinessLogic, artifactToscaOperation, + propertyBusinessLogic, componentContactIdValidator, componentNameValidator, componentTagsValidator, componentValidator, + componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator, policyBusinessLogic, modelBusinessLogic, dataTypeBusinessLogic, policyTypeBusinessLogic, modelOperation); @Before @@ -99,69 +98,73 @@ public class CheckoutTest extends LifecycleTestBase { } - @Test - public void testCheckoutStateValidation() { - Either<? extends Component, ResponseFormat> changeStateResult; - Resource resource = createResourceObject(); + @Test + public 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(); + 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 + 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); + + } } |