aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2023-06-29 18:00:52 +0100
committerMichael Morris <michael.morris@est.tech>2023-07-10 09:15:51 +0000
commitb76217740231c916fce669613e20fb70c7320a2e (patch)
treec52e77ecd9d367c0439f1ab75327635f3a9a1570 /catalog-be
parent01eb0ed11a0e97a3ae3a5ccfc5afc0702ad9d2fa (diff)
Include version in metadata
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: Ia7278b7e6a751c69a4fc50c66697c14c4025f178 Issue-ID: SDC-4558
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java42
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/IToscaMetadata.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java184
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionTests.java49
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransitionValidationTest.java32
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckinTest.java28
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java175
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogicTest.java23
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java14
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/UndoCheckoutTest.java20
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaMetadataTest.java482
13 files changed, 250 insertions, 819 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java
index f33a87b696..17d01c64b1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CertificationChangeTransition.java
@@ -20,10 +20,6 @@
package org.openecomp.sdc.be.components.lifecycle;
import fj.data.Either;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic;
import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic;
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
@@ -55,6 +51,11 @@ import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.common.util.ValidationUtils;
import org.openecomp.sdc.exception.ResponseFormat;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
public class CertificationChangeTransition extends LifeCycleTransition {
private static final String ALLOTTED_CATEGORY = "Allotted Resource";
@@ -122,7 +123,7 @@ public class CertificationChangeTransition extends LifeCycleTransition {
if (oldState != LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT && oldState != LifecycleStateEnum.NOT_CERTIFIED_CHECKIN) {
log.debug("Valid states for certification are NOT_CERTIFIED_CHECKIN and NOT_CERTIFIED_CHECKOUT. {} is invalid state", oldState);
ResponseFormat error = componentUtils
- .getResponseFormat(ActionStatus.ILLEGAL_COMPONENT_STATE, componentName, componentType.name().toLowerCase(), oldState.name());
+ .getResponseFormat(ActionStatus.ILLEGAL_COMPONENT_STATE, componentName, componentType.name().toLowerCase(), oldState.name());
return Either.right(error);
}
return Either.left(true);
@@ -135,24 +136,26 @@ public class CertificationChangeTransition extends LifeCycleTransition {
log.info("start performing certification change for resource {}", component.getUniqueId());
Either<T, ResponseFormat> result = null;
try {
- handleValidationsAndArtifactsGenerationBeforeCertifying(componentType, component, componentBl, modifier, shouldLock, inTransaction);
+ component = handleValidationsBeforeCertifying(componentType, component, modifier, shouldLock, inTransaction);
Either<ToscaElement, StorageOperationStatus> certificationChangeResult = lifeCycleOperation
- .certifyToscaElement(component.getUniqueId(), modifier.getUserId(), owner.getUserId());
+ .certifyToscaElement(component.getUniqueId(), modifier.getUserId(), owner.getUserId());
if (certificationChangeResult.isRight()) {
ResponseFormat responseFormat = formatCertificationError(component, certificationChangeResult.right().value(), componentType);
result = Either.right(responseFormat);
return result;
}
+
ToscaElement certificationResult = certificationChangeResult.left().value();
T componentAfterCertification = ModelConverter.convertFromToscaElement(certificationResult);
if (result == null || result.isLeft()) {
- //update edges for allotted resource
+ //update edges for allotted resource
StorageOperationStatus status = handleConnectionsForAllotted(componentAfterCertification);
if (status != StorageOperationStatus.OK) {
ResponseFormat responseFormat = formatCertificationError(componentAfterCertification, status, componentType);
result = Either.right(responseFormat);
}
}
+ componentBl.populateToscaArtifacts(componentAfterCertification, modifier, true, inTransaction, shouldLock);
updateCalculatedCapabilitiesRequirements(componentAfterCertification);
updateCapReqPropertiesOwnerId(componentAfterCertification);
result = Either.left(componentAfterCertification);
@@ -183,21 +186,21 @@ public class CertificationChangeTransition extends LifeCycleTransition {
Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
if (component.isVspArchived()) {
return Either.right(
- componentUtils.getResponseFormat(ActionStatus.ARCHIVED_ORIGINS_FOUND, component.getComponentType().name(), component.getName()));
+ componentUtils.getResponseFormat(ActionStatus.ARCHIVED_ORIGINS_FOUND, component.getComponentType().name(), component.getName()));
}
List<ComponentInstance> resourceInstance = component.getComponentInstances();
if (resourceInstance != null) {
//Filter components instances with archived origins
Optional<ComponentInstance> archivedRIOptional = resourceInstance.stream().filter(ComponentInstanceDataDefinition::isOriginArchived)
- .findAny();
+ .findAny();
//RIs with archived origins found, return relevant error
if (archivedRIOptional.isPresent()) {
return Either.right(
- componentUtils.getResponseFormat(ActionStatus.ARCHIVED_ORIGINS_FOUND, component.getComponentType().name(), component.getName()));
+ componentUtils.getResponseFormat(ActionStatus.ARCHIVED_ORIGINS_FOUND, component.getComponentType().name(), component.getName()));
}
//Continue with searching for non certified RIs
Optional<ComponentInstance> nonCertifiedRIOptional = resourceInstance.stream()
- .filter(p -> !ValidationUtils.validateCertifiedVersion(p.getComponentVersion())).findAny();
+ .filter(p -> !ValidationUtils.validateCertifiedVersion(p.getComponentVersion())).findAny();
// Uncertified Resource Found
if (nonCertifiedRIOptional.isPresent()) {
ComponentInstance nonCertifiedRI = nonCertifiedRIOptional.get();
@@ -232,9 +235,8 @@ public class CertificationChangeTransition extends LifeCycleTransition {
return componentUtils.getResponseFormat(actionStatus, componentType == ComponentTypeEnum.RESOURCE ? "VF" : "service", resource.getName());
}
- private void handleValidationsAndArtifactsGenerationBeforeCertifying(ComponentTypeEnum componentType, Component component,
- ComponentBusinessLogic componentBl, User modifier, boolean shouldLock,
- boolean inTransaction) {
+ private Component handleValidationsBeforeCertifying(ComponentTypeEnum componentType, Component component,
+ User modifier, boolean shouldLock, boolean inTransaction) {
if (component.isTopologyTemplate()) {
Either<Boolean, ResponseFormat> statusCert = validateAllResourceInstanceCertified(component);
if (statusCert.isRight()) {
@@ -243,18 +245,18 @@ public class CertificationChangeTransition extends LifeCycleTransition {
}
if (componentType == ComponentTypeEnum.SERVICE) {
Either<Service, ResponseFormat> generateHeatEnvResult = serviceBusinessLogic
- .generateHeatEnvArtifacts((Service) component, modifier, shouldLock, inTransaction);
+ .generateHeatEnvArtifacts((Service) component, modifier, shouldLock, inTransaction);
if (generateHeatEnvResult.isRight()) {
throw new ByResponseFormatComponentException(generateHeatEnvResult.right().value());
}
Either<Service, ResponseFormat> generateVfModuleResult = serviceBusinessLogic
- .generateVfModuleArtifacts(generateHeatEnvResult.left().value(), modifier, shouldLock, inTransaction);
+ .generateVfModuleArtifacts(generateHeatEnvResult.left().value(), modifier, shouldLock, inTransaction);
if (generateVfModuleResult.isRight()) {
throw new ByResponseFormatComponentException(generateVfModuleResult.right().value());
}
component = generateVfModuleResult.left().value();
}
- componentBl.populateToscaArtifacts(component, modifier, true, inTransaction, shouldLock);
+ return component;
}
private void updateCalculatedCapabilitiesRequirements(Component certifiedComponent) {
@@ -285,7 +287,7 @@ public class CertificationChangeTransition extends LifeCycleTransition {
componentInstancesProperties.entrySet().forEach(e -> {
List<ComponentInstanceProperty> props = e.getValue();
Optional<ComponentInstanceProperty> findProp = props.stream()
- .filter(p -> p.getName().equals(DEPENDING_SRV_NAME) || p.getName().equals(PROVIDING_SRV_NAME)).findFirst();
+ .filter(p -> p.getName().equals(DEPENDING_SRV_NAME) || p.getName().equals(PROVIDING_SRV_NAME)).findFirst();
if (findProp.isPresent()) {
log.debug("Find specific properties [{} or {}]on instance {} ", DEPENDING_SRV_NAME, PROVIDING_SRV_NAME, e.getKey());
handleAllotedInstance(component.getUniqueId(), e.getKey(), e.getValue());
@@ -298,7 +300,7 @@ public class CertificationChangeTransition extends LifeCycleTransition {
private StorageOperationStatus handleAllotedInstance(String componentId, String instanceId, List<ComponentInstanceProperty> props) {
ComponentInstanceProperty serviceUUIDProp = props.stream()
- .filter(p -> p.getName().equals(PROVIDING_SRV_UUID) || p.getName().equals(DEPENDING_SRV_UUID)).findFirst().get();
+ .filter(p -> p.getName().equals(PROVIDING_SRV_UUID) || p.getName().equals(DEPENDING_SRV_UUID)).findFirst().get();
if (serviceUUIDProp.getValue() != null && !serviceUUIDProp.getValue().contains("get_input")) {
log.debug("Handle Allotted edge on instance {} for service UUID {} ", instanceId, serviceUUIDProp.getValue());
return nodeTemplateOperation.createAllottedOfEdge(componentId, instanceId, serviceUUIDProp.getValue());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java
index 90778105af..ced257fb18 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java
@@ -81,7 +81,7 @@ public class CheckoutTransition extends LifeCycleTransition {
log.debug("start performing {} for resource {}", getName(), component.getUniqueId());
Either<? extends Component, ResponseFormat> result = null;
try {
- Either<ToscaElement, StorageOperationStatus> checkoutResourceResult = lifeCycleOperation
+ final Either<ToscaElement, StorageOperationStatus> checkoutResourceResult = lifeCycleOperation
.checkoutToscaElement(component.getUniqueId(), modifier.getUserId(), owner.getUserId());
if (checkoutResourceResult.isRight()) {
log.debug("checkout failed on graph");
@@ -110,7 +110,7 @@ public class CheckoutTransition extends LifeCycleTransition {
}
}
result = Either.left(clonedComponent);
- Either<Boolean, ResponseFormat> upgradeToLatestGeneric = componentBl.shouldUpgradeToLatestGeneric(clonedComponent);
+ final Either<Boolean, ResponseFormat> upgradeToLatestGeneric = componentBl.shouldUpgradeToLatestGeneric(clonedComponent);
if (upgradeToLatestGeneric.isRight()) {
result = Either.right(upgradeToLatestGeneric.right().value());
} else if (upgradeToLatestGeneric.left().value()) {
@@ -123,6 +123,10 @@ public class CheckoutTransition extends LifeCycleTransition {
}
handleCalculatedCapabilitiesRequirements(clonedComponent);
updateCapReqPropertiesOwnerId(clonedComponent);
+ final Either<Component, StorageOperationStatus> updateEither = toscaOperationFacade.updateToscaElement(clonedComponent);
+ if (updateEither.isRight()){
+ result = Either.right(componentUtils.getResponseFormat(updateEither.right().value()));
+ }
}
} finally {
if (result == null || result.isRight()) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 44da4f2500..540ea6ec5c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -606,6 +606,7 @@ public class ToscaExportHandler {
}
toscaMetadata.put(JsonPresentationFields.RESOURCE_VENDOR_RELEASE.getPresentation(), resource.getVendorRelease());
toscaMetadata.put(JsonPresentationFields.RESOURCE_VENDOR_MODEL_NUMBER.getPresentation(), resource.getResourceVendorModelNumber());
+ toscaMetadata.put(resource.isTopologyTemplate() ? JsonPresentationFields.TEMPLATE_VERSION.getPresentation() : JsonPresentationFields.VERSION.getPresentation(), resource.getVersion());
break;
case SERVICE:
Service service = (Service) component;
@@ -614,6 +615,7 @@ public class ToscaExportHandler {
toscaMetadata.put(JsonPresentationFields.SERVICE_ROLE.getPresentation(), service.getServiceRole());
toscaMetadata.put(JsonPresentationFields.SERVICE_FUNCTION.getPresentation(), service.getServiceFunction());
toscaMetadata.put(JsonPresentationFields.ENVIRONMENT_CONTEXT.getPresentation(), service.getEnvironmentContext());
+ toscaMetadata.put(JsonPresentationFields.TEMPLATE_VERSION.getPresentation(), service.getVersion());
toscaMetadata.put(JsonPresentationFields.INSTANTIATION_TYPE.getPresentation(),
service.getEnvironmentContext() == null ? StringUtils.EMPTY : service.getInstantiationType());
if (!isInstance) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/IToscaMetadata.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/IToscaMetadata.java
index e24316ca02..c850bec68d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/IToscaMetadata.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/IToscaMetadata.java
@@ -21,13 +21,13 @@ package org.openecomp.sdc.be.tosca.model;
public interface IToscaMetadata {
- public void setName(String name);
+ void setName(String name);
- public void setInvariantUUID(String invariantUUID);
+ void setInvariantUUID(String invariantUUID);
- public void setUUID(String uUID);
+ void setUUID(String uUID);
- public void setVersion(String version);
+ void setVersion(String version);
- public void setCustomizationUUID(String customizationUUID);
+ void setCustomizationUUID(String customizationUUID);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java
index 54d382ff82..62a0a50733 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaMetadata.java
@@ -19,6 +19,11 @@
*/
package org.openecomp.sdc.be.tosca.model;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
public class ToscaMetadata implements IToscaMetadata {
private String invariantUUID;
@@ -46,121 +51,6 @@ public class ToscaMetadata implements IToscaMetadata {
private String serviceFunction;
private String model;
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- public String getInvariantUUID() {
- return invariantUUID;
- }
-
- @Override
- public void setInvariantUUID(String invariantUUID) {
- this.invariantUUID = invariantUUID;
- }
-
- public String getUUID() {
- return UUID;
- }
-
- @Override
- public void setUUID(String uUID) {
- UUID = uUID;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getCategory() {
- return category;
- }
-
- public void setCategory(String category) {
- this.category = category;
- }
-
- public String getSubcategory() {
- return subcategory;
- }
-
- public void setSubcategory(String subcategory) {
- this.subcategory = subcategory;
- }
-
- public String getResourceVendor() {
- return resourceVendor;
- }
-
- public void setResourceVendor(String resourceVendor) {
- this.resourceVendor = resourceVendor;
- }
-
- public String getResourceVendorRelease() {
- return resourceVendorRelease;
- }
-
- public void setResourceVendorRelease(String resourceVendorRelease) {
- this.resourceVendorRelease = resourceVendorRelease;
- }
-
- public String getResourceVendorModelNumber() {
- return resourceVendorModelNumber;
- }
-
- public void setResourceVendorModelNumber(String resourceVendorModelNumber) {
- this.resourceVendorModelNumber = resourceVendorModelNumber;
- }
-
- public String getServiceType() {
- return serviceType;
- }
-
- public void setServiceType(String serviceType) {
- this.serviceType = serviceType;
- }
-
- public String getServiceRole() {
- return serviceRole;
- }
-
- public void setServiceRole(String serviceRole) {
- this.serviceRole = serviceRole;
- }
-
- public String getServiceFunction() {
- return serviceFunction;
- }
-
- public void setServiceFunction(String serviceFunction) {
- this.serviceFunction = serviceFunction;
- }
-
- public String getInstantiationType() {
- return instantiationType;
- }
-
- public void setInstantiationType(String instantiationType) {
- this.instantiationType = instantiationType;
- }
-
public Boolean isEcompGeneratedNaming() {
return new Boolean(ecompGeneratedNaming);
}
@@ -169,14 +59,6 @@ public class ToscaMetadata implements IToscaMetadata {
this.ecompGeneratedNaming = ecompGeneratedNaming == null ? null : ecompGeneratedNaming.toString();
}
- public String isNamingPolicy() {
- return namingPolicy;
- }
-
- public void setNamingPolicy(String namingPolicy) {
- this.namingPolicy = namingPolicy;
- }
-
public Boolean getServiceEcompNaming() {
return new Boolean(serviceEcompNaming);
}
@@ -185,60 +67,4 @@ public class ToscaMetadata implements IToscaMetadata {
this.serviceEcompNaming = serviceEcompNaming == null ? null : serviceEcompNaming.toString();
}
- public String getVersion() {
- return version;
- }
-
- @Override
- public void setVersion(String version) {
- this.version = version;
- }
-
- public String getCustomizationUUID() {
- return customizationUUID;
- }
-
- public void setCustomizationUUID(String customizationUUID) {
- this.customizationUUID = customizationUUID;
- }
-
- public String getSourceModelInvariant() {
- return sourceModelInvariant;
- }
-
- public void setSourceModelInvariant(String sourceModelInvariant) {
- this.sourceModelInvariant = sourceModelInvariant;
- }
-
- public String getSourceModelName() {
- return sourceModelName;
- }
-
- public void setSourceModelName(String sourceModelName) {
- this.sourceModelName = sourceModelName;
- }
-
- public String getSourceModelUuid() {
- return sourceModelUuid;
- }
-
- public void setSourceModelUuid(String sourceModelUuid) {
- this.sourceModelUuid = sourceModelUuid;
- }
-
- public String getEnvironmentContext() {
- return environmentContext;
- }
-
- public void setEnvironmentContext(String environmentContext) {
- this.environmentContext = environmentContext;
- }
-
- public String getModel() {
- return model;
- }
-
- public void setModel(String model) {
- this.model = model;
- }
}
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());
+ }
}