summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasyl Razinkov <vasyl.razinkov@est.tech>2022-09-20 15:18:27 +0000
committerMichael Morris <michael.morris@est.tech>2022-09-23 09:16:04 +0000
commit0323aadb6038a630798ad133f8b86a9b9d50feea (patch)
tree36a192bd0d819cfa51d0f64886aabcd362c346d5
parent9a2c547065bc7ff4a23c680dfbafe4008a09290c (diff)
Revert "Fix 'Wrong Inputs creation on (Add Service)'"
This reverts commit ae24e28cda8247fdce38330356b63db1377be58f. Reason for revert: problem reported with 'default' values Issue-ID: SDC-4097 Change-Id: I8966470070329cc8aafcb45255f2febb9b00ab4e Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImpl.java55
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java110
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/property/DefaultPropertyDeclarator.java48
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java20
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InputConverter.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicBaseTestSetup.java5
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java190
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiNetworkServiceUiTests.java62
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ModelToscaTypeImportTest.java18
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/EditComponentInputsFlow.java67
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentInputTab.java74
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java22
13 files changed, 256 insertions, 425 deletions
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImpl.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImpl.java
index 18ba2ec21b..9572c44a6b 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImpl.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImpl.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -18,7 +19,9 @@
*/
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator;
+import com.google.common.collect.ImmutableMap;
import fj.data.Either;
+import groovy.util.MapEntry;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -69,7 +72,7 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
private static final List<String> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TYPE = Arrays
.asList("cds_model_name", "cds_model_version", "skip_post_instantiation_configuration", "controller_actor");
private static final List<String> ETSI_SOL_NSD_NS_NODE_TYPE_PROPERTIES = Arrays
- .asList("descriptor_id", "designer", "version", "name", "invariant_id", "flavour_id", "ns_profile", "service_availability_level");
+ .asList("descriptor_id", "designer", "version", "name", "invariant_id", "flavour_id", "ns_profile", "service_availability_level");
private static final List<String> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TEMPLATE = Arrays
.asList("nf_function", "nf_role", "nf_naming_code", "nf_type", "nf_naming", "availability_zone_max_count", "min_instances", "max_instances",
"multi_stage_design", "sdnc_model_name", "sdnc_model_version", "sdnc_artifact_name", "skip_post_instantiation_configuration",
@@ -199,7 +202,7 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
}
componentToscaTemplate.getTopology_template().setSubstitution_mappings(substitutionMapping);
}
-
+
private Map<String, String[]> adjustRequirementNamesToMatchVnfd(final Map<String, String[]> requirements) {
for (final Map.Entry<String, String[]> entry : requirements.entrySet()) {
try {
@@ -236,7 +239,7 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
removeCapabilitiesFromNodeTemplate(nodeTemplate);
}
}
-
+
private void setPropertiesForNodeTemplate(final Entry<String, ToscaNodeTemplate> nodeTemplate) {
final Map<String, Object> propertyMap = nodeTemplate.getValue().getProperties();
if (MapUtils.isEmpty(propertyMap)) {
@@ -258,13 +261,12 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
}
private void setRequirementsForNodeTemplate(final Entry<String, ToscaNodeTemplate> nodeTemplateMap) {
- final List<Map<String, ToscaTemplateRequirement>> requirementAssignments = nodeTemplateMap.getValue().getRequirements();
- if (requirementAssignments != null) {
- final List<Map<String, ToscaTemplateRequirement>> requirementAssignmentsMatchingVnfdRequirements = new ArrayList<>();
- for (final Map<String, ToscaTemplateRequirement> requirementAssignment : requirementAssignments) {
- final Map<String, ToscaTemplateRequirement> requirementAssignmentMatchingVnfd =
- requirementAssignment.entrySet().stream()
- .collect(Collectors.toMap(entry -> entry.getKey().substring(entry.getKey().lastIndexOf('.') + 1), Map.Entry::getValue));
+ final List<Map<String,ToscaTemplateRequirement>> requirementAssignments = nodeTemplateMap.getValue().getRequirements();
+ if (requirementAssignments != null) {
+ final List<Map<String,ToscaTemplateRequirement>> requirementAssignmentsMatchingVnfdRequirements = new ArrayList<>();
+ for (final Map<String, ToscaTemplateRequirement> requirementAssignment: requirementAssignments) {
+ final Map<String, ToscaTemplateRequirement> requirementAssignmentMatchingVnfd =
+ requirementAssignment.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey().substring(entry.getKey().lastIndexOf('.') + 1), Map.Entry::getValue));
requirementAssignmentsMatchingVnfdRequirements.add(requirementAssignmentMatchingVnfd);
}
nodeTemplateMap.getValue().setRequirements(requirementAssignmentsMatchingVnfdRequirements);
@@ -279,10 +281,10 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
private void removeOnapAndEtsiNsdPropertiesFromInputs(final ToscaTemplate template) {
final ToscaTopolgyTemplate topologyTemplate = template.getTopology_template();
final Map<String, ToscaProperty> inputMap = topologyTemplate.getInputs();
-
+
+
if (MapUtils.isNotEmpty(inputMap)) {
- inputMap.entrySet().removeIf(entry -> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TYPE.contains(entry.getKey())
- || ETSI_SOL_NSD_NS_NODE_TYPE_PROPERTIES.contains(entry.getKey()));
+ inputMap.entrySet().removeIf(entry -> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TYPE.contains(entry.getKey()) || ETSI_SOL_NSD_NS_NODE_TYPE_PROPERTIES.contains(entry.getKey()));
}
if (MapUtils.isEmpty(inputMap)) {
topologyTemplate.setInputs(null);
@@ -317,7 +319,7 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
}
private Map<String, Map<String, String>> generateDefaultImportEntry() {
- return Map.of("etsi_nfv_sol001_nsd_types", Map.of("file", "etsi_nfv_sol001_nsd_types.yaml"));
+ return ImmutableMap.of("etsi_nfv_sol001_nsd_types", ImmutableMap.of("file", "etsi_nfv_sol001_nsd_types.yaml"));
}
private ToscaNodeType createEtsiSolNsNodeType(final ToscaNodeType nsNodeType, final ToscaTemplate componentToscaTemplate) {
@@ -334,34 +336,29 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
}
propertiesInNsNodeType.entrySet().removeIf(entry -> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TYPE.contains(entry.getKey()));
toscaNodeType.setProperties(propertiesInNsNodeType);
-
- final List<Map<String, ToscaRequirement>> requirementsInNsNodeType = getRequirementsForNsNodeType(nsNodeType.getRequirements(),
- componentToscaTemplate);
+
+ final List<Map<String, ToscaRequirement>> requirementsInNsNodeType = getRequirementsForNsNodeType(nsNodeType.getRequirements(), componentToscaTemplate);
if (!requirementsInNsNodeType.isEmpty()) {
- toscaNodeType.setRequirements(requirementsInNsNodeType);
+ toscaNodeType.setRequirements(requirementsInNsNodeType);
}
return toscaNodeType;
}
-
- private List<Map<String, ToscaRequirement>> getRequirementsForNsNodeType(final List<Map<String, ToscaRequirement>> requirements,
- final ToscaTemplate componentToscaTemplate) {
- final Map<String, String[]> requirementsInSubstitutionMapping = componentToscaTemplate.getTopology_template().getSubstitution_mappings()
- .getRequirements();
+
+ private List<Map<String,ToscaRequirement>> getRequirementsForNsNodeType(final List<Map<String,ToscaRequirement>> requirements, final ToscaTemplate componentToscaTemplate) {
+ final Map<String, String[]> requirementsInSubstitutionMapping = componentToscaTemplate.getTopology_template().getSubstitution_mappings().getRequirements();
if (requirements == null || MapUtils.isEmpty(requirementsInSubstitutionMapping)) {
return Collections.emptyList();
}
- final List<Map<String, ToscaRequirement>> requirementsToAdd = new ArrayList<>();
- for (final Map<String, ToscaRequirement> requirementMap : requirements) {
- final Map<String, ToscaRequirement> neededRequirements = requirementMap.entrySet().stream()
- .filter(entry -> requirementsInSubstitutionMapping.containsKey(entry.getKey()))
- .collect(Collectors.toMap(Entry::getKey, Entry::getValue));
+ final List<Map<String,ToscaRequirement>> requirementsToAdd = new ArrayList<>();
+ for (final Map<String,ToscaRequirement> requirementMap : requirements) {
+ final Map<String,ToscaRequirement> neededRequirements = requirementMap.entrySet().stream().filter(entry -> requirementsInSubstitutionMapping.containsKey(entry.getKey())).collect(Collectors.toMap(Entry::getKey, Entry::getValue));
if (!neededRequirements.isEmpty()) {
requirementsToAdd.add(neededRequirements);
}
}
return requirementsToAdd;
-
+
}
private boolean propertyIsDefinedInNodeType(final String propertyName) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
index 763552fcf3..bca901ee8b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
@@ -213,7 +213,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
component = getComponentEither.left().value();
Optional<InputDefinition> op = component.getInputs().stream().filter(in -> in.getUniqueId().equals(inputId)).findFirst();
- if (op.isEmpty()) {
+ if (!op.isPresent()) {
ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
log.debug(FAILED_TO_FOUND_INPUT_UNDER_COMPONENT_ERROR, inputId, parentId, actionStatus);
return Either.right(componentsUtils.getResponseFormat(actionStatus));
@@ -369,7 +369,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
component = getComponentEither.left().value();
Optional<InputDefinition> op = component.getInputs().stream().filter(in -> in.getUniqueId().equals(inputId)).findFirst();
- if (op.isEmpty()) {
+ if (!op.isPresent()) {
ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
log.debug(FAILED_TO_FOUND_INPUT_UNDER_COMPONENT_ERROR, inputId, componentId, actionStatus);
return Either.right(componentsUtils.getResponseFormat(actionStatus));
@@ -664,7 +664,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
filter(input -> input.getUniqueId().equals(inputId)).
// Get the input
findAny();
- if (optionalInput.isEmpty()) {
+ if (!optionalInput.isPresent()) {
throw new ByActionStatusComponentException(ActionStatus.INPUT_IS_NOT_CHILD_OF_COMPONENT, inputId, componentId);
}
InputDefinition inputForDelete = optionalInput.get();
@@ -770,7 +770,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
Component component = getComponentEither.left().value();
Optional<InputDefinition> op = component.getInputs().stream().filter(in -> in.getUniqueId().equals(inputId)).findFirst();
- if (op.isEmpty()) {
+ if (!op.isPresent()) {
ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
log.debug(FAILED_TO_FOUND_INPUT_UNDER_COMPONENT_ERROR, inputId, componentId, actionStatus);
return Either.right(componentsUtils.getResponseFormat(actionStatus));
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
index 577d1f5e32..2cccc31ded 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
@@ -109,10 +109,8 @@ import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstInputsMap;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.ComponentInstanceInterface;
-import org.openecomp.sdc.be.model.ComponentInstancePropInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DistributionStatusEnum;
@@ -191,12 +189,13 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
private final ServiceInstantiationTypeValidator serviceInstantiationTypeValidator;
private final ServiceCategoryValidator serviceCategoryValidator;
private final ServiceValidator serviceValidator;
+ private final PolicyBusinessLogic policyBusinessLogic;
+ private final GroupBusinessLogic groupBusinessLogic;
private ForwardingPathOperation forwardingPathOperation;
private AuditCassandraDao auditCassandraDao;
private ServiceTypeValidator serviceTypeValidator;
private List<ServiceCreationPlugin> serviceCreationPluginList;
private ServiceFunctionValidator serviceFunctionValidator;
- private final InputsBusinessLogic inputsBusinessLogic;
public ServiceBusinessLogic(IElementOperation elementDao, IGroupOperation groupOperation, IGroupInstanceOperation groupInstanceOperation,
IGroupTypeOperation groupTypeOperation, GroupBusinessLogic groupBusinessLogic, InterfaceOperation interfaceOperation,
@@ -211,7 +210,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
final ServiceRoleValidator serviceRoleValidator,
final ServiceInstantiationTypeValidator serviceInstantiationTypeValidator,
final ServiceCategoryValidator serviceCategoryValidator, final ServiceValidator serviceValidator,
- final InputsBusinessLogic inputsBusinessLogic) {
+ final PolicyBusinessLogic policyBusinessLogic) {
super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, groupBusinessLogic, interfaceOperation,
interfaceLifecycleTypeOperation, artifactsBusinessLogic, artifactToscaOperation, componentContactIdValidator, componentNameValidator,
componentTagsValidator, componentValidator, componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator);
@@ -225,7 +224,8 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
this.serviceInstantiationTypeValidator = serviceInstantiationTypeValidator;
this.serviceCategoryValidator = serviceCategoryValidator;
this.serviceValidator = serviceValidator;
- this.inputsBusinessLogic = inputsBusinessLogic;
+ this.policyBusinessLogic = policyBusinessLogic;
+ this.groupBusinessLogic = groupBusinessLogic;
}
@Autowired
@@ -311,7 +311,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
Optional<ComponentInstance> serviceInstanceCandidate = componentInstances.stream()
.filter(instance -> instance.getUniqueId().equals(serviceInstanceId)).findAny();
- if (serviceInstanceCandidate.isEmpty()) {
+ if (!serviceInstanceCandidate.isPresent()) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.INTERFACE_OPERATION_NOT_FOUND, serviceInstanceId));
}
Map<String, List<ComponentInstanceInterface>> componentInstancesInterfaces = parentService.getComponentInstancesInterfaces();
@@ -324,7 +324,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
ComponentInstance serviceInstance = serviceInstanceCandidate.get();
Optional<InterfaceDefinition> interfaceCandidate = InterfaceOperationUtils.getInterfaceDefinitionFromOperationId(interfaces, operationId);
- if (interfaceCandidate.isEmpty()) {
+ if (!interfaceCandidate.isPresent()) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.INTERFACE_OPERATION_NOT_FOUND, serviceInstanceId));
}
InterfaceDefinition interfaceDefinition = interfaceCandidate.get();
@@ -336,7 +336,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
Either<Operation, ResponseFormat> operationEither = Either.left(operation);
ListDataDefinition<OperationInputDefinition> inputs = operation.getInputs();
Optional<OperationInputDefinition> inputCandidate = getOperationInputByInputId(serviceConsumptionData, inputs);
- if (inputCandidate.isEmpty()) {
+ if (!inputCandidate.isPresent()) {
return Either.right(new ResponseFormat(HttpStatus.NOT_FOUND.value()));
}
OperationInputDefinition operationInputDefinition = inputCandidate.get();
@@ -419,7 +419,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
.getListToscaDataDefinition();
} else {
Optional<ComponentInstance> getComponentInstance = containerService.getComponentInstanceById(source);
- if (getComponentInstance.isEmpty()) {
+ if (!getComponentInstance.isPresent()) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER, source));
}
ComponentInstance componentInstance = getComponentInstance.get();
@@ -692,7 +692,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
private Either<Service, ResponseFormat> createServiceByDao(final Service service, final User user) {
log.debug("send service {} to dao for create", service.getComponentMetadataDefinition().getMetadataDataDefinition().getName());
- final Either<Boolean, ResponseFormat> lockResult = lockComponentByName(service.getSystemName(), service, "Create Service");
+ Either<Boolean, ResponseFormat> lockResult = lockComponentByName(service.getSystemName(), service, "Create Service");
if (lockResult.isRight()) {
ResponseFormat responseFormat = lockResult.right().value();
componentsUtils.auditComponentAdmin(responseFormat, user, service, AuditingActionEnum.CREATE_RESOURCE, ComponentTypeEnum.SERVICE);
@@ -710,64 +710,25 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
generateAndAddInputsFromGenericTypeProperties(service, genericType);
}
beforeCreate(service);
- final Either<Service, StorageOperationStatus> dataModelResponse = toscaOperationFacade.createToscaComponent(service);
- if (dataModelResponse.isRight()) {
- ResponseFormat responseFormat = componentsUtils
- .getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(dataModelResponse.right().value()), service,
- ComponentTypeEnum.SERVICE);
- log.debug(AUDIT_BEFORE_SENDING_RESPONSE);
+ Either<Service, StorageOperationStatus> dataModelResponse = toscaOperationFacade.createToscaComponent(service);
+ if (dataModelResponse.isLeft()) {
+ log.debug("Service '{}' created successfully", service.getName());
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.CREATED);
componentsUtils.auditComponentAdmin(responseFormat, user, service, AuditingActionEnum.CREATE_RESOURCE, ComponentTypeEnum.SERVICE);
- return Either.right(responseFormat);
+ ASDCKpiApi.countCreatedServicesKPI();
+ return Either.left(dataModelResponse.left().value());
}
- final Service createdService = dataModelResponse.left().value();
- if (createdService.isSubstituteCandidate() || genericTypeBusinessLogic.hasMandatorySubstitutionType(createdService)) {
- updateInputs(createdService);
- }
- log.debug("Service '{}' created successfully", createdService.getName());
- final ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.CREATED);
- componentsUtils.auditComponentAdmin(responseFormat, user, createdService, AuditingActionEnum.CREATE_RESOURCE, ComponentTypeEnum.SERVICE);
- ASDCKpiApi.countCreatedServicesKPI();
- return Either.left(createdService);
+ ResponseFormat responseFormat = componentsUtils
+ .getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(dataModelResponse.right().value()), service,
+ ComponentTypeEnum.SERVICE);
+ log.debug(AUDIT_BEFORE_SENDING_RESPONSE);
+ componentsUtils.auditComponentAdmin(responseFormat, user, service, AuditingActionEnum.CREATE_RESOURCE, ComponentTypeEnum.SERVICE);
+ return Either.right(responseFormat);
} finally {
graphLockOperation.unlockComponentByName(service.getSystemName(), service.getUniqueId(), NodeTypeEnum.Service);
}
}
- private void updateInputs(final Service service) {
- final List<InputDefinition> genericTypeInputs = service.getInputs();
- final Either<List<InputDefinition>, ResponseFormat> inputs = inputsBusinessLogic.getInputs(service.getCreatorUserId(), service.getUniqueId());
- if (inputs.isRight() || CollectionUtils.isEmpty(inputs.left().value())) {
- log.warn("Failed to declare Generic Type Properties as Inputs");
- service.setInputs(null);
- return;
- }
- inputs.left().value().forEach(
- inputDefinition -> inputsBusinessLogic.deleteInput(service.getUniqueId(), service.getCreatorUserId(), inputDefinition.getUniqueId()));
-
- service.setInputs(null);
- if (CollectionUtils.isNotEmpty(genericTypeInputs)) {
- // From SELF
- final ComponentInstInputsMap componentInstInputsMap = new ComponentInstInputsMap();
- final List<ComponentInstancePropInput> componentInstancePropInputs = genericTypeInputs.stream()
- .map(prop -> {
- prop.setInstanceUniqueId(service.getUniqueId());
- prop.setParentUniqueId(service.getUniqueId());
- return new ComponentInstancePropInput(new ComponentInstanceProperty(prop));
- }
- ).collect(Collectors.toList());
- componentInstInputsMap.setServiceProperties(Collections.singletonMap(service.getUniqueId(), componentInstancePropInputs));
-
- final Either<List<InputDefinition>, ResponseFormat> listResponseFormatEither = inputsBusinessLogic.declareProperties(
- service.getCreatorUserId(), service.getUniqueId(), ComponentTypeEnum.SERVICE, componentInstInputsMap);
- if (listResponseFormatEither.isRight()) {
- log.warn("Failed to declare Generic Type Properties as Inputs");
- service.setInputs(null);
- return;
- }
- service.setInputs(listResponseFormatEither.left().value());
- }
- }
-
private void beforeCreate(final Service service) {
if (CollectionUtils.isEmpty(serviceCreationPluginList)) {
return;
@@ -784,7 +745,10 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
@SuppressWarnings("unchecked")
private void createServiceApiArtifactsData(Service service, User user) {
// create mandatory artifacts
- // TODO it must be removed after that artifact uniqueId creation will be moved to ArtifactOperation
+
+ // TODO it must be removed after that artifact uniqueId creation will be
+
+ // moved to ArtifactOperation
String serviceUniqueId = service.getUniqueId();
Map<String, ArtifactDefinition> artifactMap = service.getServiceApiArtifacts();
if (artifactMap == null) {
@@ -1666,13 +1630,13 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
BeEcompErrorManager.getInstance()
.logBeComponentMissingError("markDistributionAsDeployed", ComponentTypeEnum.SERVICE.getValue(), serviceId);
log.debug("service {} not found", serviceId);
- ResponseFormat responseFormat = auditDeployError(did, user, null,
+ ResponseFormat responseFormat = auditDeployError(did, user, auditAction, null,
componentsUtils.convertFromStorageResponse(getServiceResponse.right().value(), ComponentTypeEnum.SERVICE), "");
return Either.right(responseFormat);
}
Service service = getServiceResponse.left().value();
user = validateRoleForDeploy(did, user, auditAction, service);
- return checkDistributionAndDeploy(did, user, service);
+ return checkDistributionAndDeploy(did, user, auditAction, service);
}
public Either<Service, ResponseFormat> generateVfModuleArtifacts(Service service, User modifier, boolean shouldLock, boolean inTransaction) {
@@ -1746,13 +1710,13 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
return null;
}
- private synchronized Either<Service, ResponseFormat> checkDistributionAndDeploy(String distributionId, User user,
+ private synchronized Either<Service, ResponseFormat> checkDistributionAndDeploy(String distributionId, User user, AuditingActionEnum auditAction,
Service service) {
boolean isDeployed = isDistributionDeployed(distributionId);
if (isDeployed) {
return Either.left(service);
}
- Either<Boolean, ResponseFormat> distributionSuccess = checkDistributionSuccess(distributionId, user, service);
+ Either<Boolean, ResponseFormat> distributionSuccess = checkDistributionSuccess(distributionId, user, auditAction, service);
if (distributionSuccess.isRight()) {
return Either.right(distributionSuccess.right().value());
}
@@ -1775,20 +1739,20 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
return isDeployed;
}
- protected Either<Boolean, ResponseFormat> checkDistributionSuccess(String did, User user, Service service) {
+ protected Either<Boolean, ResponseFormat> checkDistributionSuccess(String did, User user, AuditingActionEnum auditAction, Service service) {
log.trace("checkDistributionSuccess");
// get all "DRequest" records for this distribution
Either<List<ResourceAdminEvent>, ActionStatus> distRequestsResponse = auditCassandraDao
.getDistributionRequest(did, AuditingActionEnum.DISTRIBUTION_STATE_CHANGE_REQUEST.getName());
if (distRequestsResponse.isRight()) {
- ResponseFormat error = auditDeployError(did, user, service, distRequestsResponse.right().value());
+ ResponseFormat error = auditDeployError(did, user, auditAction, service, distRequestsResponse.right().value());
return Either.right(error);
}
List<ResourceAdminEvent> distributionRequests = distRequestsResponse.left().value();
if (distributionRequests.isEmpty()) {
BeEcompErrorManager.getInstance().logBeDistributionMissingError("markDistributionAsDeployed", did);
log.info("distribution {} is not found", did);
- ResponseFormat error = auditDeployError(did, user, service, ActionStatus.DISTRIBUTION_REQUESTED_NOT_FOUND);
+ ResponseFormat error = auditDeployError(did, user, auditAction, service, ActionStatus.DISTRIBUTION_REQUESTED_NOT_FOUND);
return Either.right(error);
}
boolean isRequestSucceeded = false;
@@ -1803,7 +1767,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
Either<List<DistributionNotificationEvent>, ActionStatus> distNotificationsResponse = auditCassandraDao
.getDistributionNotify(did, AuditingActionEnum.DISTRIBUTION_NOTIFY.getName());
if (distNotificationsResponse.isRight()) {
- ResponseFormat error = auditDeployError(did, user, service, distNotificationsResponse.right().value());
+ ResponseFormat error = auditDeployError(did, user, auditAction, service, distNotificationsResponse.right().value());
return Either.right(error);
}
List<DistributionNotificationEvent> distributionNotifications = distNotificationsResponse.left().value();
@@ -1819,13 +1783,13 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
if (!(isRequestSucceeded && isNotificationsSucceeded)) {
log.info("distribution {} has failed", did);
ResponseFormat error = componentsUtils.getResponseFormat(ActionStatus.DISTRIBUTION_REQUESTED_FAILED, did);
- auditDeployError(did, user, service, ActionStatus.DISTRIBUTION_REQUESTED_FAILED, did);
+ auditDeployError(did, user, auditAction, service, ActionStatus.DISTRIBUTION_REQUESTED_FAILED, did);
return Either.right(error);
}
return Either.left(true);
}
- private ResponseFormat auditDeployError(String did, User user, Service service, ActionStatus status,
+ private ResponseFormat auditDeployError(String did, User user, AuditingActionEnum auditAction, Service service, ActionStatus status,
String... params) {
ResponseFormat error = componentsUtils.getResponseFormat(status, params);
String message = "";
@@ -1853,7 +1817,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
validateUserRole(user, service, roles, auditAction, null);
} catch (ByActionStatusComponentException e) {
log.info("role {} is not allowed to perform this action", user.getRole());
- auditDeployError(did, user, service, e.getActionStatus());
+ auditDeployError(did, user, auditAction, service, e.getActionStatus());
throw e;
}
return user;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/property/DefaultPropertyDeclarator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/property/DefaultPropertyDeclarator.java
index 07d5ba0f24..0412516390 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/property/DefaultPropertyDeclarator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/property/DefaultPropertyDeclarator.java
@@ -126,7 +126,7 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
private Either<List<PolicyDefinition>, StorageOperationStatus> declarePropertiesAsPolicies(Component component, PROPERTYOWNER propertiesOwner,
List<ComponentInstancePropInput> propsToDeclare) {
- PropertiesDeclarationData policyProperties = createPoliciesAndOverridePropertiesValues(propertiesOwner.getUniqueId(),
+ PropertiesDeclarationData policyProperties = createPoliciesAndOverridePropertiesValues(propertiesOwner.getUniqueId(), propertiesOwner,
propsToDeclare);
return updatePropertiesValues(component, propertiesOwner.getUniqueId(), policyProperties.getPropertiesToUpdate()).left()
.map(updatePropsRes -> policyProperties.getPoliciesToCreate());
@@ -144,7 +144,8 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
.map(updatePropsRes -> inputsProperties.getInputsToCreate());
}
- private PropertiesDeclarationData createPoliciesAndOverridePropertiesValues(String componentId, List<ComponentInstancePropInput> propsToDeclare) {
+ private PropertiesDeclarationData createPoliciesAndOverridePropertiesValues(String componentId, PROPERTYOWNER propertiesOwner,
+ List<ComponentInstancePropInput> propsToDeclare) {
List<PROPERTYTYPE> declaredProperties = new ArrayList<>();
List<PolicyDefinition> policies = new ArrayList<>();
propsToDeclare.forEach(property -> policies.add(declarePropertyPolicy(componentId, declaredProperties, property)));
@@ -249,7 +250,7 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
if (propertyCapability.isPresent()) {
String capName = propertyCapability.get().getName();
if (capName.contains(".")) {
- capName = capName.replace(".", UNDERSCORE);
+ capName = capName.replaceAll("\\.", UNDERSCORE);
}
generatedInputPrefix =
generatedInputPrefix == null || generatedInputPrefix.isEmpty() ? capName : generatedInputPrefix + UNDERSCORE + capName;
@@ -314,12 +315,12 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
input.setInputPath(propertiesName);
input.setInstanceUniqueId(propertiesOwner.getUniqueId());
input.setPropertyId(propInput.getUniqueId());
- if (Objects.isNull(input.getSubPropertyInputPath()) || (StringUtils.isNotEmpty(propertiesName) && input.getSubPropertyInputPath()
+ if (Objects.isNull(input.getSubPropertyInputPath()) || (Objects.nonNull(propertiesName) && input.getSubPropertyInputPath()
.substring(input.getSubPropertyInputPath().lastIndexOf('#')).equals(propertiesName.substring(propertiesName.lastIndexOf('#'))))) {
input.setParentPropertyType(propInput.getType());
input.setSubPropertyInputPath(propertiesName);
}
- changePropertyValueToGetInputValue(parsedPropNames, input, prop, complexProperty);
+ changePropertyValueToGetInputValue(inputName, parsedPropNames, input, prop, complexProperty);
if (prop instanceof IComponentInstanceConnectedElement) {
((IComponentInstanceConnectedElement) prop).setComponentInstanceId(propertiesOwner.getUniqueId());
((IComponentInstanceConnectedElement) prop).setComponentInstanceName(propertiesOwner.getName());
@@ -327,43 +328,42 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
return input;
}
- private void changePropertyValueToGetInputValue(String[] parsedPropNames, InputDefinition input, PropertyDataDefinition prop,
+ private void changePropertyValueToGetInputValue(String inputName, String[] parsedPropNames, InputDefinition input, PropertyDataDefinition prop,
boolean complexProperty) {
JSONObject jsonObject = new JSONObject();
- final String value = prop.getValue();
- final String inputName = input.getName();
+ String value = prop.getValue();
if (value == null || value.isEmpty()) {
if (complexProperty) {
jsonObject = createJSONValueForProperty(parsedPropNames.length - 1, parsedPropNames, jsonObject, inputName);
prop.setValue(jsonObject.toJSONString());
} else {
- jsonObject.put(GET_INPUT, inputName);
+ jsonObject.put(GET_INPUT, input.getName());
prop.setValue(jsonObject.toJSONString());
}
} else {
- final Object objValue = new Yaml().load(value);
+ Object objValue = new Yaml().load(value);
if (objValue instanceof Map || objValue instanceof List) {
if (!complexProperty) {
- jsonObject.put(GET_INPUT, inputName);
+ jsonObject.put(GET_INPUT, input.getName());
prop.setValue(jsonObject.toJSONString());
} else {
- final Map<String, Object> mappedToscaTemplate = (Map<String, Object>) objValue;
+ Map<String, Object> mappedToscaTemplate = (Map<String, Object>) objValue;
createInputValue(mappedToscaTemplate, 1, parsedPropNames, inputName);
- final String json = gson.toJson(mappedToscaTemplate);
+ String json = gson.toJson(mappedToscaTemplate);
prop.setValue(json);
}
} else {
- jsonObject.put(GET_INPUT, inputName);
+ jsonObject.put(GET_INPUT, input.getName());
prop.setValue(jsonObject.toJSONString());
}
}
if (CollectionUtils.isEmpty(prop.getGetInputValues())) {
prop.setGetInputValues(new ArrayList<>());
}
- final List<GetInputValueDataDefinition> getInputValues = prop.getGetInputValues();
- final GetInputValueDataDefinition getInputValueDataDefinition = new GetInputValueDataDefinition();
+ List<GetInputValueDataDefinition> getInputValues = prop.getGetInputValues();
+ GetInputValueDataDefinition getInputValueDataDefinition = new GetInputValueDataDefinition();
getInputValueDataDefinition.setInputId(input.getUniqueId());
- getInputValueDataDefinition.setInputName(inputName);
+ getInputValueDataDefinition.setInputName(input.getName());
getInputValues.add(getInputValueDataDefinition);
}
@@ -460,7 +460,8 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
if (result.isLeft()) {
modifiedMappedToscaTemplate = (Map) result.left().value();
} else {
- log.warn("Map cleanup failed -> {}", result.right().value()); //continue, don't break operation
+ log.warn("Map cleanup failed -> " + result.right().value()
+ .toString()); //continue, don't break operation
}
value = gson.toJson(modifiedMappedToscaTemplate);
}
@@ -545,10 +546,11 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
boolean isEmpty = true;
if (element != null) {
if (element instanceof Map) {
- final Map map = (Map) element;
- if (MapUtils.isNotEmpty(map)) {
- for (final Object key : map.keySet()) {
- final Object value = map.get(key);
+ if (MapUtils.isEmpty((Map) element)) {
+ isEmpty = true;
+ } else {
+ for (Object key : ((Map) (element)).keySet()) {
+ Object value = ((Map) (element)).get(key);
isEmpty &= isEmptyNestedMap(value);
}
}
@@ -558,7 +560,7 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
}
return isEmpty;
}
- //@returns true if map nested maps are all empty
+ //@returns true iff map nested maps are all empty
private class PropertiesDeclarationData {
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 f3327d7206..85f29bf352 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
@@ -802,11 +802,11 @@ public class ToscaExportHandler {
if (CollectionUtils.isNotEmpty(component.getProperties())) {
List<PropertyDefinition> properties = component.getProperties();
Map<String, ToscaProperty> convertedProperties = properties.stream()
- .map(propertyDefinition -> resolvePropertyValueFromInput(propertyDefinition, component.getInputs()))
- .collect(Collectors.toMap(PropertyDataDefinition::getName,
- property -> propertyConvertor.convertProperty(dataTypes, property, PropertyConvertor.PropertyType.PROPERTY)));
+ .map(propertyDefinition -> resolvePropertyValueFromInput(propertyDefinition, component.getInputs())).collect(Collectors
+ .toMap(PropertyDataDefinition::getName,
+ property -> propertyConvertor.convertProperty(dataTypes, property, PropertyConvertor.PropertyType.PROPERTY)));
// merge component properties and inputs properties
- convertedProperties.forEach((k, v) -> mergedProperties.putIfAbsent(k, v));
+ mergedProperties.putAll(convertedProperties);
}
if (MapUtils.isNotEmpty(mergedProperties)) {
toscaNodeType.setProperties(mergedProperties);
@@ -940,7 +940,7 @@ public class ToscaExportHandler {
nodeTemplate.setType(componentInstance.getToscaComponentName());
nodeTemplate.setDirectives(componentInstance.getDirectives());
NodeFilter nodeFilter = convertToNodeTemplateNodeFilterComponent(componentInstance.getNodeFilter());
- if (nodeFilter != null && nodeFilter.hasData()) {
+ if(nodeFilter != null && nodeFilter.hasData()){
nodeTemplate.setNode_filter(nodeFilter);
}
final Either<Component, Boolean> originComponentRes = capabilityRequirementConverter
@@ -1755,7 +1755,7 @@ public class ToscaExportHandler {
}
private Map<String, ToscaProperty> convertInputsToProperties(Map<String, DataTypeDefinition> dataTypes, List<InputDefinition> componentInputs,
- String componentUniqueId) {
+ String componentUniqueId) {
if (CollectionUtils.isEmpty(componentInputs)) {
return new HashMap<>();
}
@@ -1776,10 +1776,6 @@ public class ToscaExportHandler {
.ofNullable(interfacesOperationsConverter.getInterfacesMap(proxyComponent, null, proxyComponentInterfaces, dataTypes, false, false));
}
- private Configuration getConfiguration() {
- return ConfigurationManager.getConfigurationManager().getConfiguration();
- }
-
private static class CustomRepresenter extends Representer {
CustomRepresenter() {
@@ -1935,4 +1931,8 @@ public class ToscaExportHandler {
}
}
+ private Configuration getConfiguration() {
+ return ConfigurationManager.getConfigurationManager().getConfiguration();
+ }
+
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InputConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InputConverter.java
index b94a32291e..55de9e5028 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InputConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InputConverter.java
@@ -56,7 +56,7 @@ public class InputConverter {
* description
* list of properties */
public Map<String, ToscaProperty> convertInputs(List<InputDefinition> inputDef, Map<String, DataTypeDefinition> dataTypes) {
- log.debug("convert inputs to tosca");
+ log.debug("convert inputs to to tosca ");
Map<String, ToscaProperty> inputs = new HashMap<>();
if (inputDef != null) {
inputDef.forEach(i -> {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicBaseTestSetup.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicBaseTestSetup.java
index f1ee0d4c6c..049f8a5541 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicBaseTestSetup.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicBaseTestSetup.java
@@ -140,7 +140,6 @@ class ServiceBusinessLogicBaseTestSetup extends BaseBusinessLogicMock {
ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
ForwardingPathValidator forwardingPathValidator = Mockito.mock(ForwardingPathValidator.class);
UiComponentDataConverter uiComponentDataConverter = Mockito.mock(UiComponentDataConverter.class);
- final InputsBusinessLogic inputsBusinessLogic = Mockito.mock(InputsBusinessLogic.class);
public ServiceBusinessLogicBaseTestSetup() {
@@ -173,7 +172,7 @@ class ServiceBusinessLogicBaseTestSetup extends BaseBusinessLogicMock {
user.setRole(Role.ADMIN.name());
when(mockUserAdmin.getUser("jh0003", false)).thenReturn(user);
- when(userValidations.validateUserExists("jh0003")).thenReturn(user);
+ when(userValidations.validateUserExists(eq("jh0003"))).thenReturn(user);
when(userValidations.validateUserNotEmpty(eq(user), anyString())).thenReturn(user);
when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager);
when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
@@ -205,7 +204,7 @@ class ServiceBusinessLogicBaseTestSetup extends BaseBusinessLogicMock {
interfaceLifecycleTypeOperation, artifactBl, distributionEngine, componentInstanceBusinessLogic, serviceDistributionValidation,
forwardingPathValidator, uiComponentDataConverter, artifactToscaOperation, componentContactIdValidator, componentNameValidator,
componentTagsValidator, componentValidator, componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator,
- modelOperation, serviceRoleValidator, serviceInstantiationTypeValidator, serviceCategoryValidator, serviceValidator, inputsBusinessLogic);
+ modelOperation, serviceRoleValidator, serviceInstantiationTypeValidator, serviceCategoryValidator, serviceValidator, null);
bl.setComponentContactIdValidator(componentContactIdValidator);
bl.setComponentIconValidator(componentIconValidator);
bl.setComponentTagsValidator(componentTagsValidator);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java
index 46173a2eb7..69938cd527 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java
@@ -31,8 +31,6 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
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;
import com.google.common.collect.Lists;
@@ -41,12 +39,12 @@ import fj.data.Either;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
+
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@@ -59,11 +57,9 @@ import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstInputsMap;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.ComponentInstanceInterface;
import org.openecomp.sdc.be.model.GroupInstance;
-import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.Model;
import org.openecomp.sdc.be.model.Operation;
import org.openecomp.sdc.be.model.PropertyDefinition;
@@ -90,16 +86,14 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
@Test
void testGetComponentAuditRecordsCertifiedVersion() {
- Either<List<Map<String, Object>>, ResponseFormat> componentAuditRecords = bl.getComponentAuditRecords(CERTIFIED_VERSION, COMPONNET_ID,
- user.getUserId());
+ Either<List<Map<String, Object>>, ResponseFormat> componentAuditRecords = bl.getComponentAuditRecords(CERTIFIED_VERSION, COMPONNET_ID, user.getUserId());
assertTrue(componentAuditRecords.isLeft());
assertEquals(3, componentAuditRecords.left().value().size());
}
@Test
void testGetComponentAuditRecordsUnCertifiedVersion() {
- Either<List<Map<String, Object>>, ResponseFormat> componentAuditRecords = bl.getComponentAuditRecords(UNCERTIFIED_VERSION, COMPONNET_ID,
- user.getUserId());
+ Either<List<Map<String, Object>>, ResponseFormat> componentAuditRecords = bl.getComponentAuditRecords(UNCERTIFIED_VERSION, COMPONNET_ID, user.getUserId());
assertTrue(componentAuditRecords.isLeft());
assertEquals(4, componentAuditRecords.left().value().size());
}
@@ -192,6 +186,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
final Service actualService = createResponse.left().value();
org.hamcrest.MatcherAssert.assertThat("Service should not be null", service, is(notNullValue()));
+
assertEqualsServiceObject(expectedService, actualService);
}
@@ -221,7 +216,6 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
}
assertEqualsServiceObject(createServiceObject(true), createResponse.left().value());
}
-
private void assertEqualsServiceObject(final Service expectedService, final Service actualService) {
assertEquals(expectedService.getContactId(), actualService.getContactId());
assertEquals(expectedService.getCategories(), actualService.getCategories());
@@ -302,9 +296,9 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
private void testServiceNameEmpty() {
Service serviceExccedsNameLimit = createServiceObject(false);
serviceExccedsNameLimit.setName(null);
- try {
+ try{
bl.createService(serviceExccedsNameLimit, user);
- } catch (ComponentException e) {
+ } catch(ComponentException e){
assertComponentException(e, ActionStatus.MISSING_COMPONENT_NAME, ComponentTypeEnum.SERVICE.getValue());
return;
}
@@ -316,9 +310,9 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
// contains :
String nameWrongFormat = "ljg\\fd";
service.setName(nameWrongFormat);
- try {
+ try{
bl.createService(service, user);
- } catch (ComponentException e) {
+ } catch(ComponentException e){
assertComponentException(e, ActionStatus.INVALID_COMPONENT_NAME, ComponentTypeEnum.SERVICE.getValue());
return;
}
@@ -331,21 +325,20 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
private void testServiceDescriptionEmpty() {
Service serviceExist = createServiceObject(false);
serviceExist.setDescription("");
- try {
+ try{
bl.createService(serviceExist, user);
- } catch (ComponentException e) {
+ } catch(ComponentException e){
assertComponentException(e, ActionStatus.COMPONENT_MISSING_DESCRIPTION, ComponentTypeEnum.SERVICE.getValue());
return;
}
fail();
}
-
private void testServiceDescriptionMissing() {
Service serviceExist = createServiceObject(false);
serviceExist.setDescription(null);
- try {
+ try{
bl.createService(serviceExist, user);
- } catch (ComponentException e) {
+ } catch(ComponentException e){
assertComponentException(e, ActionStatus.COMPONENT_MISSING_DESCRIPTION, ComponentTypeEnum.SERVICE.getValue());
return;
}
@@ -356,20 +349,19 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
Service serviceExccedsDescLimit = createServiceObject(false);
// 1025 chars, the limit is 1024
String tooLongServiceDesc = "1GUODojQ0sGzKR4NP7e5j82ADQ3KHTVOaezL95qcbuaqDtjZhAQGQ3iFwKAy580K4WiiXs3u3zq7RzXcSASl5fm0RsWtCMOIDP"
- + "AOf9Tf2xtXxPCuCIMCR5wOGnNTaFxgnJEHAGxilBhZDgeMNHmCN1rMK5B5IRJOnZxcpcL1NeG3APTCIMP1lNAxngYulDm9heFSBc8TfXAADq7703AvkJT0QPpGq2z2P"
- + "tlikcAnIjmWgfC5Tm7UH462BAlTyHg4ExnPPL4AO8c92VrD7kZSgSqiy73cN3gLT8uigkKrUgXQFGVUFrXVyyQXYtVM6bLBeuCGQf4C2j8lkNg6M0J3PC0PzMRoinOxk"
- + "Ae2teeCtVcIj4A1KQo3210j8q2v7qQU69Mabsa6DT9FgE4rcrbiFWrg0Zto4SXWD3o1eJA9o29lTg6kxtklH3TuZTmpi5KVp1NFhS1RpnqF83tzv4mZLKsx7Zh1fEgYvRFwx1"
- + "ar3RolyDfNoZiGBGTMsZzz7RPFBf2hTnLmNqVGQnHKhhGj0Y5s8t2cbqbO2nmHiJb9uaUVrCGypgbAcJL3KPOBfAVW8PcpmNj4yVjI3L4x5zHjmGZbp9vKshEQODcrmcgsYAoKqe"
- + "uu5u7jk8XVxEfQ0m5qL8UOErXPlJovSmKUmP5B5T0w299zIWDYCzSoNasHpHjOMDLAiDDeHbozUOn9t3Qou00e9POq4RMM0VnIx1H38nJoJZz2XH8CI5YMQe7oTagaxgQTF2aa0qaq2"
- + "V6nJsfRGRklGjNhFFYP2cS4Xv2IJO9DSX6LTXOmENrGVJJvMOZcvnBaZPfoAHN0LU4i1SoepLzulIxnZBfkUWFJgZ5wQ0Bco2GC1HMqzW21rwy4XHRxXpXbmW8LVyoA1KbnmVmROycU4"
- + "scTZ62IxIcIWCVeMjBIcTviXULbPUyqlfEPXWr8IMJtpAaELWgyquPClAREMDs2b9ztKmUeXlMccFES1XWbFTrhBHhmmDyVReEgCwfokrUFR13LTUK1k8I6OEHOs";
+ + "AOf9Tf2xtXxPCuCIMCR5wOGnNTaFxgnJEHAGxilBhZDgeMNHmCN1rMK5B5IRJOnZxcpcL1NeG3APTCIMP1lNAxngYulDm9heFSBc8TfXAADq7703AvkJT0QPpGq2z2P"
+ + "tlikcAnIjmWgfC5Tm7UH462BAlTyHg4ExnPPL4AO8c92VrD7kZSgSqiy73cN3gLT8uigkKrUgXQFGVUFrXVyyQXYtVM6bLBeuCGQf4C2j8lkNg6M0J3PC0PzMRoinOxk"
+ + "Ae2teeCtVcIj4A1KQo3210j8q2v7qQU69Mabsa6DT9FgE4rcrbiFWrg0Zto4SXWD3o1eJA9o29lTg6kxtklH3TuZTmpi5KVp1NFhS1RpnqF83tzv4mZLKsx7Zh1fEgYvRFwx1"
+ + "ar3RolyDfNoZiGBGTMsZzz7RPFBf2hTnLmNqVGQnHKhhGj0Y5s8t2cbqbO2nmHiJb9uaUVrCGypgbAcJL3KPOBfAVW8PcpmNj4yVjI3L4x5zHjmGZbp9vKshEQODcrmcgsYAoKqe"
+ + "uu5u7jk8XVxEfQ0m5qL8UOErXPlJovSmKUmP5B5T0w299zIWDYCzSoNasHpHjOMDLAiDDeHbozUOn9t3Qou00e9POq4RMM0VnIx1H38nJoJZz2XH8CI5YMQe7oTagaxgQTF2aa0qaq2"
+ + "V6nJsfRGRklGjNhFFYP2cS4Xv2IJO9DSX6LTXOmENrGVJJvMOZcvnBaZPfoAHN0LU4i1SoepLzulIxnZBfkUWFJgZ5wQ0Bco2GC1HMqzW21rwy4XHRxXpXbmW8LVyoA1KbnmVmROycU4"
+ + "scTZ62IxIcIWCVeMjBIcTviXULbPUyqlfEPXWr8IMJtpAaELWgyquPClAREMDs2b9ztKmUeXlMccFES1XWbFTrhBHhmmDyVReEgCwfokrUFR13LTUK1k8I6OEHOs";
serviceExccedsDescLimit.setDescription(tooLongServiceDesc);
- try {
+ try{
bl.createService(serviceExccedsDescLimit, user);
- } catch (ComponentException e) {
- assertComponentException(e, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT, ComponentTypeEnum.SERVICE.getValue(),
- "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
+ } catch(ComponentException e){
+ assertComponentException(e, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT, ComponentTypeEnum.SERVICE.getValue(), "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
return;
}
fail();
@@ -380,9 +372,9 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
// Not english
String tooLongServiceDesc = "\uC2B5";
notEnglish.setDescription(tooLongServiceDesc);
- try {
+ try{
bl.createService(notEnglish, user);
- } catch (ComponentException e) {
+ } catch(ComponentException e){
assertComponentException(e, ActionStatus.COMPONENT_INVALID_DESCRIPTION, ComponentTypeEnum.SERVICE.getValue());
return;
}
@@ -395,15 +387,14 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
private void testServiceIconEmpty() {
Service serviceExist = createServiceObject(false);
serviceExist.setIcon("");
- Either<Service, ResponseFormat> service = bl.validateServiceBeforeCreate(serviceExist, user, AuditingActionEnum.CREATE_SERVICE);
+ Either<Service, ResponseFormat> service = bl.validateServiceBeforeCreate(serviceExist,user,AuditingActionEnum.CREATE_SERVICE);
assertThat(service.left().value().getIcon()).isEqualTo(DEFAULT_ICON);
}
-
private void testServiceIconMissing() {
Service serviceExist = createServiceObject(false);
serviceExist.setIcon(null);
- Either<Service, ResponseFormat> service = bl.validateServiceBeforeCreate(serviceExist, user, AuditingActionEnum.CREATE_SERVICE);
+ Either<Service, ResponseFormat> service = bl.validateServiceBeforeCreate(serviceExist,user,AuditingActionEnum.CREATE_SERVICE);
assertThat(service.left().value().getIcon()).isEqualTo(DEFAULT_ICON);
}
@@ -422,9 +413,9 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
List<String> tagsList = new ArrayList<>();
tagsList.add(tag1);
serviceExccedsNameLimit.setTags(tagsList);
- try {
+ try{
bl.createService(serviceExccedsNameLimit, user);
- } catch (ComponentException e) {
+ } catch(ComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME);
return;
}
@@ -437,9 +428,9 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
List<String> tagsList = new ArrayList<>();
tagsList.add(tag1);
serviceExccedsNameLimit.setTags(tagsList);
- try {
+ try{
bl.createService(serviceExccedsNameLimit, user);
- } catch (ComponentException e) {
+ } catch(ComponentException e) {
assertComponentException(e, ActionStatus.INVALID_FIELD_FORMAT, "Service", "tag");
return;
}
@@ -470,23 +461,22 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
// 59 chars instead of 50
String contactIdTooLong = "thisNameIsVeryLongAndExeccedsTheNormalLengthForContactId";
serviceContactId.setContactId(contactIdTooLong);
- try {
+ try{
bl.createService(serviceContactId, user);
- } catch (ComponentException e) {
+ } catch(ComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.SERVICE.getValue());
return;
}
fail();
}
-
private void testContactIdWrongFormatCreate() {
Service serviceContactId = createServiceObject(false);
// 3 letters and 3 digits and special characters
String contactIdTooLong = "yrt134!!!";
serviceContactId.setContactId(contactIdTooLong);
- try {
+ try{
bl.createService(serviceContactId, user);
- } catch (ComponentException e) {
+ } catch(ComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.SERVICE.getValue());
return;
}
@@ -496,9 +486,9 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
private void testResourceContactIdMissing() {
Service resourceExist = createServiceObject(false);
resourceExist.setContactId(null);
- try {
+ try{
bl.createService(resourceExist, user);
- } catch (ComponentException e) {
+ } catch(ComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_MISSING_CONTACT, ComponentTypeEnum.SERVICE.getValue());
return;
}
@@ -511,15 +501,14 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
private void testServiceCategoryExist() {
Service serviceExist = createServiceObject(false);
serviceExist.setCategories(null);
- try {
+ try{
bl.createService(serviceExist, user);
- } catch (ComponentException e) {
+ } catch(ComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.SERVICE.getValue());
return;
}
fail();
}
-
@Test
void markDistributionAsDeployedTestAlreadyDeployed() {
String notifyAction = "DNotify";
@@ -540,7 +529,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
resultList.add(event);
Either<List<DistributionDeployEvent>, ActionStatus> eventList = Either.left(resultList);
- Mockito.when(auditingDao.getDistributionDeployByStatus(Mockito.anyString(), eq(resultAction), Mockito.anyString())).thenReturn(eventList);
+ Mockito.when(auditingDao.getDistributionDeployByStatus(Mockito.anyString(), Mockito.eq(resultAction), Mockito.anyString())).thenReturn(eventList);
Either<Service, ResponseFormat> markDeployed = bl.markDistributionAsDeployed(did, did, user);
assertTrue(markDeployed.isLeft());
@@ -572,7 +561,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
setupBeforeDeploy(notifyAction, requestAction, did);
List<ResourceAdminEvent> emptyList = new ArrayList<>();
Either<List<ResourceAdminEvent>, ActionStatus> emptyEventList = Either.left(emptyList);
- Mockito.when(auditingDao.getDistributionRequest(Mockito.anyString(), eq(requestAction))).thenReturn(emptyEventList);
+ Mockito.when(auditingDao.getDistributionRequest(Mockito.anyString(), Mockito.eq(requestAction))).thenReturn(emptyEventList);
Either<Component, StorageOperationStatus> notFound = Either.right(StorageOperationStatus.NOT_FOUND);
Mockito.when(toscaOperationFacade.getToscaElement(did)).thenReturn(notFound);
@@ -592,9 +581,9 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
List<CategoryDefinition> categories = new ArrayList<>();
categories.add(category);
serviceExist.setCategories(categories);
- try {
+ try{
bl.createService(serviceExist, user);
- } catch (ComponentException e) {
+ } catch(ComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_INVALID_CATEGORY, ComponentTypeEnum.SERVICE.getValue());
return;
}
@@ -611,8 +600,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
try {
bl.createService(serviceExist, user);
- } catch (ComponentException exp) {
- assertComponentException(exp, ActionStatus.INVALID_PROJECT_CODE);
+ } catch(ComponentException exp) {
+ assertComponentException(exp, ActionStatus.INVALID_PROJECT_CODE);
return;
}
fail();
@@ -626,7 +615,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
try {
bl.createService(serviceExist, user);
- } catch (ComponentException exp) {
+ } catch(ComponentException exp) {
assertComponentException(exp, ActionStatus.INVALID_PROJECT_CODE);
return;
}
@@ -641,7 +630,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
try {
bl.createService(serviceExist, user);
- } catch (ComponentException exp) {
+ } catch(ComponentException exp) {
assertComponentException(exp, ActionStatus.INVALID_PROJECT_CODE);
return;
}
@@ -690,7 +679,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
eitherService.left().value().setArchived(false);
Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(eitherService);
final ComponentException actualException = assertThrows(ComponentException.class, () -> bl.deleteServiceAllVersions(serviceId, user));
- assertEquals(ActionStatus.COMPONENT_NOT_ARCHIVED, actualException.getActionStatus());
+ assertEquals(actualException.getActionStatus(), ActionStatus.COMPONENT_NOT_ARCHIVED);
assertEquals(actualException.getParams()[0], serviceId);
}
@@ -698,20 +687,20 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
void testDeleteArchivedService_DeleteServiceSpecificModel() throws ToscaOperationException {
String serviceId = "12345";
String model = "serviceSpecificModel";
- List<String> deletedServcies = new ArrayList<>();
+ List<String> deletedServcies= new ArrayList<>();
deletedServcies.add("54321");
Model normativeExtensionModel = new Model("normativeExtensionModel", ModelTypeEnum.NORMATIVE_EXTENSION);
Either<Component, StorageOperationStatus> eitherService = Either.left(createNewService());
eitherService.left().value().setArchived(true);
eitherService.left().value().setModel(model);
Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(eitherService);
- Mockito.when(toscaOperationFacade.deleteService(Mockito.anyString(), eq(true))).thenReturn(deletedServcies);
+ Mockito.when(toscaOperationFacade.deleteService(Mockito.anyString(), Mockito.eq(true))).thenReturn(deletedServcies);
Mockito.when(modelOperation.findModelByName(model)).thenReturn(Optional.of(normativeExtensionModel));
bl.deleteServiceAllVersions(serviceId, user);
Mockito.verify(modelOperation, Mockito.times(1)).deleteModel(normativeExtensionModel, false);
}
- @SuppressWarnings({"unchecked", "rawtypes"})
+ @SuppressWarnings({ "unchecked", "rawtypes" })
@Test
void testFindGroupInstanceOnRelatedComponentInstance() {
@@ -724,7 +713,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
Either<ImmutablePair<ComponentInstance, GroupInstance>, ResponseFormat> findGroupInstanceRes;
Object[] argObjects = {service, componentInstances.get(1).getUniqueId(), componentInstances.get(1).getGroupInstances().get(1).getUniqueId()};
- Class[] argClasses = {Component.class, String.class, String.class};
+ Class[] argClasses = {Component.class, String.class,String.class};
try {
Method method = targetClass.getDeclaredMethod(methodName, argClasses);
method.setAccessible(true);
@@ -732,26 +721,27 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
findGroupInstanceRes = (Either<ImmutablePair<ComponentInstance, GroupInstance>, ResponseFormat>) method.invoke(bl, argObjects);
assertNotNull(findGroupInstanceRes);
assertEquals(findGroupInstanceRes.left().value().getKey().getUniqueId(), componentInstances.get(1)
- .getUniqueId());
+ .getUniqueId());
assertEquals(findGroupInstanceRes.left().value().getValue().getUniqueId(), componentInstances.get(1)
- .getGroupInstances()
- .get(1)
- .getUniqueId());
+ .getGroupInstances()
+ .get(1)
+ .getUniqueId());
- Object[] argObjectsInvalidCiId = {service, invalidId, componentInstances.get(1).getGroupInstances().get(1).getUniqueId()};
+ Object[] argObjectsInvalidCiId = {service, invalidId , componentInstances.get(1).getGroupInstances().get(1).getUniqueId()};
- findGroupInstanceRes = (Either<ImmutablePair<ComponentInstance, GroupInstance>, ResponseFormat>) method.invoke(bl, argObjectsInvalidCiId);
+ findGroupInstanceRes = (Either<ImmutablePair<ComponentInstance, GroupInstance>, ResponseFormat>) method.invoke(bl, argObjectsInvalidCiId);
assertNotNull(findGroupInstanceRes);
assertTrue(findGroupInstanceRes.isRight());
assertEquals("SVC4593", findGroupInstanceRes.right().value().getMessageId());
- Object[] argObjectsInvalidGiId = {service, componentInstances.get(1).getUniqueId(), invalidId};
+ Object[] argObjectsInvalidGiId = {service, componentInstances.get(1).getUniqueId() , invalidId};
- findGroupInstanceRes = (Either<ImmutablePair<ComponentInstance, GroupInstance>, ResponseFormat>) method.invoke(bl, argObjectsInvalidGiId);
+ findGroupInstanceRes = (Either<ImmutablePair<ComponentInstance, GroupInstance>, ResponseFormat>) method.invoke(bl, argObjectsInvalidGiId);
assertNotNull(findGroupInstanceRes);
assertTrue(findGroupInstanceRes.isRight());
assertEquals("SVC4653", findGroupInstanceRes.right().value().getMessageId());
- } catch (Exception e) {
+ }
+ catch (Exception e) {
e.printStackTrace();
}
}
@@ -764,15 +754,15 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
service.setUniqueId("serviceUniqueId");
List<ComponentInstance> componentInstances = new ArrayList<>();
ComponentInstance ci;
- for (int i = 0; i < listSize; ++i) {
+ for(int i= 0; i<listSize; ++i){
ci = new ComponentInstance();
ci.setName("ciName" + i);
ci.setUniqueId("ciId" + i);
- List<GroupInstance> groupInstances = new ArrayList<>();
+ List<GroupInstance> groupInstances= new ArrayList<>();
GroupInstance gi;
- for (int j = 0; j < listSize; ++j) {
+ for(int j = 0; j<listSize; ++j){
gi = new GroupInstance();
- gi.setName(ci.getName() + "giName" + j);
+ gi.setName(ci.getName( )+ "giName" + j);
gi.setUniqueId(ci.getName() + "giId" + j);
groupInstances.add(gi);
}
@@ -784,22 +774,15 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
}
protected Service createNewService() {
- return (Service) createNewComponent();
+ return (Service)createNewComponent();
}
@Test
void testDerivedFromGeneric() {
Service service = createServiceObject(true);
- Service newService = createServiceObject(false);
- newService.setInputs(Collections.singletonList(new InputDefinition()));
service.setDerivedFromGenericInfo(genericService);
- newService.setDerivedFromGenericInfo(genericService);
- when(toscaOperationFacade.createToscaComponent(service)).thenReturn(Either.left(newService));
+ when(toscaOperationFacade.createToscaComponent(service)).thenReturn(Either.left(service));
when(genericTypeBusinessLogic.fetchDerivedFromGenericType(service, null)).thenReturn(Either.left(genericService));
- when(inputsBusinessLogic.getInputs(any(), any())).thenReturn(Either.left(Collections.singletonList(new InputDefinition())));
- when(inputsBusinessLogic.declareProperties(any(), any(), eq(ComponentTypeEnum.SERVICE), any(ComponentInstInputsMap.class)))
- .thenReturn(Either.left(Collections.singletonList(new InputDefinition())));
-
Either<Service, ResponseFormat> createResponse = bl.createService(service, user);
assertTrue(createResponse.isLeft());
service = createResponse.left().value();
@@ -893,7 +876,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
@Test
void testCreateDefaultMetadataServiceFunction() {
Service currentService = createServiceObject(true);
- assertThat(currentService.getServiceFunction()).isEmpty();
+ assertThat(currentService.getServiceFunction()).isEqualTo("");
}
@Test
@@ -923,10 +906,11 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
newService.setServiceFunction(null);
resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
assertThat(resultOfUpdate.isLeft()).isTrue();
- assertThat(updatedService.getServiceFunction()).isEmpty();
+ assertThat(updatedService.getServiceFunction()).isEqualTo("");
}
+
@Test
void testServiceFunctionExceedLength() {
String serviceName = "Service";
@@ -945,7 +929,7 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
}
@Test
- void testServiceFunctionInvalidCharacter() {
+ void testServiceFunctionInvalidCharacter(){
String serviceName = "Service";
String serviceFunction = "a?";
Service serviceFunctionExceedLength = createServiceObject(false);
@@ -966,8 +950,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
Either<Operation, ResponseFormat> operationEither =
- bl.addPropertyServiceConsumption("1", "2", "3",
- user.getUserId(), new ServiceConsumptionData());
+ bl.addPropertyServiceConsumption("1", "2", "3",
+ user.getUserId(), new ServiceConsumptionData());
assertTrue(operationEither.isRight());
assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
}
@@ -978,8 +962,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(eitherService);
Either<Operation, ResponseFormat> operationEither =
- bl.addPropertyServiceConsumption("1", "2", "3",
- user.getUserId(), new ServiceConsumptionData());
+ bl.addPropertyServiceConsumption("1", "2", "3",
+ user.getUserId(), new ServiceConsumptionData());
assertTrue(operationEither.isRight());
assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
}
@@ -993,8 +977,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
String weirdUniqueServiceInstanceId = UUID.randomUUID().toString();
Either<Operation, ResponseFormat> operationEither =
- bl.addPropertyServiceConsumption("1", weirdUniqueServiceInstanceId, "3",
- user.getUserId(), new ServiceConsumptionData());
+ bl.addPropertyServiceConsumption("1", weirdUniqueServiceInstanceId, "3",
+ user.getUserId(), new ServiceConsumptionData());
assertTrue(operationEither.isRight());
assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
}
@@ -1007,8 +991,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(eitherService);
Either<Operation, ResponseFormat> operationEither =
- bl.addPropertyServiceConsumption("1", aService.getUniqueId(), "3",
- user.getUserId(), new ServiceConsumptionData());
+ bl.addPropertyServiceConsumption("1", aService.getUniqueId(), "3",
+ user.getUserId(), new ServiceConsumptionData());
assertTrue(operationEither.isRight());
assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
}
@@ -1021,15 +1005,15 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(eitherService);
Map<String, List<ComponentInstanceInterface>> componentInstancesInterfacesMap =
- Maps.newHashMap();
+ Maps.newHashMap();
componentInstancesInterfacesMap.put(aService.getUniqueId(),
- Lists.newArrayList(new ComponentInstanceInterface("1", new InterfaceInstanceDataDefinition())));
+ Lists.newArrayList(new ComponentInstanceInterface("1", new InterfaceInstanceDataDefinition())));
aService.setComponentInstancesInterfaces(componentInstancesInterfacesMap);
Either<Operation, ResponseFormat> operationEither =
- bl.addPropertyServiceConsumption("1", aService.getUniqueId(), "3",
- user.getUserId(), new ServiceConsumptionData());
+ bl.addPropertyServiceConsumption("1", aService.getUniqueId(), "3",
+ user.getUserId(), new ServiceConsumptionData());
assertTrue(operationEither.isRight());
assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
}
@@ -1043,10 +1027,10 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
String operationId = "operationId";
ComponentInstanceInterface componentInstanceInterface =
- new ComponentInstanceInterface("interfaceId", new InterfaceInstanceDataDefinition());
+ new ComponentInstanceInterface("interfaceId", new InterfaceInstanceDataDefinition());
Map<String, Operation> operationsMap = Maps.newHashMap();
operationsMap.put(operationId, new Operation(new ArtifactDataDefinition(), "1",
- new ListDataDefinition<>(), new ListDataDefinition<>()));
+ new ListDataDefinition<>(), new ListDataDefinition<>()));
componentInstanceInterface.setOperationsMap(operationsMap);
Map<String, List<ComponentInstanceInterface>> componentInstancesInterfacesMap = Maps.newHashMap();
@@ -1054,8 +1038,8 @@ class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
aService.setComponentInstancesInterfaces(componentInstancesInterfacesMap);
Either<Operation, ResponseFormat> operationEither =
- bl.addPropertyServiceConsumption("1", aService.getUniqueId(), operationId,
- user.getUserId(), new ServiceConsumptionData());
+ bl.addPropertyServiceConsumption("1", aService.getUniqueId(), operationId,
+ user.getUserId(), new ServiceConsumptionData());
assertTrue(operationEither.isRight());
assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
}
diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiNetworkServiceUiTests.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiNetworkServiceUiTests.java
index 38f0d37c21..061fb183f3 100644
--- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiNetworkServiceUiTests.java
+++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiNetworkServiceUiTests.java
@@ -60,7 +60,7 @@ import org.onap.sdc.frontend.ci.tests.flow.CreateServiceFlow;
import org.onap.sdc.frontend.ci.tests.flow.CreateVlmFlow;
import org.onap.sdc.frontend.ci.tests.flow.CreateVspFlow;
import org.onap.sdc.frontend.ci.tests.flow.DownloadCsarArtifactFlow;
-import org.onap.sdc.frontend.ci.tests.flow.EditComponentInputsFlow;
+import org.onap.sdc.frontend.ci.tests.flow.EditComponentPropertiesFlow;
import org.onap.sdc.frontend.ci.tests.flow.ImportVspFlow;
import org.onap.sdc.frontend.ci.tests.flow.composition.CreateRelationshipFlow;
import org.onap.sdc.frontend.ci.tests.flow.exception.UiTestFlowRuntimeException;
@@ -113,8 +113,8 @@ public class EtsiNetworkServiceUiTests extends SetupCDTest {
//adding node
componentPage = addNodesAndCreateRelationships(resourceName, serviceCreateData, componentPage);
- final Map<String, Object> inputToEditMap = createInputToEditMap();
- editInputs(componentPage, inputToEditMap);
+ final Map<String, Object> propertyMap = createPropertyToEditMap();
+ editProperties(componentPage, propertyMap);
final DownloadCsarArtifactFlow downloadCsarArtifactFlow = downloadCsarArtifact(componentPage);
final ToscaArtifactsPage toscaArtifactsPage = downloadCsarArtifactFlow.getLandedPage()
@@ -123,7 +123,8 @@ public class EtsiNetworkServiceUiTests extends SetupCDTest {
assertThat("No artifact download was found", toscaArtifactsPage.getDownloadedArtifactList(), not(empty()));
final String downloadedCsarName = toscaArtifactsPage.getDownloadedArtifactList().get(0);
- checkEtsiNsPackage(createServiceFlow.getServiceCreateData().getName(), downloadedCsarName, inputToEditMap);
+ propertyMap.entrySet().removeIf(e -> e.getValue() == null);
+ checkEtsiNsPackage(createServiceFlow.getServiceCreateData().getName(), downloadedCsarName, propertyMap);
}
private ServiceComponentPage addNodesAndCreateRelationships(final String resourceName, final ServiceCreateData serviceCreateData,
@@ -267,27 +268,29 @@ public class EtsiNetworkServiceUiTests extends SetupCDTest {
return checkVfPropertiesFlow;
}
+ private void editProperties(final ComponentPage componentPage, final Map<String, Object> propertyMap) {
+ final EditComponentPropertiesFlow editComponentPropertiesFlow = new EditComponentPropertiesFlow(webDriver, propertyMap);
+ editComponentPropertiesFlow.run(componentPage);
+ }
+
private DownloadCsarArtifactFlow downloadCsarArtifact(final ComponentPage componentPage) {
final DownloadCsarArtifactFlow downloadCsarArtifactFlow = new DownloadCsarArtifactFlow(webDriver);
downloadCsarArtifactFlow.run(componentPage);
return downloadCsarArtifactFlow;
}
- private Map<String, Object> createInputToEditMap() {
- final Map<String, Object> inputsMap = new HashMap<>();
- inputsMap.put("descriptor_id", "new descriptor_id");
- inputsMap.put("designer", "new designer");
- inputsMap.put("flavour_id", "new flavour_id");
- inputsMap.put("invariant_id", "new invariant_id");
- inputsMap.put("name", "new name");
- inputsMap.put("service_availability_level", 123);
- inputsMap.put("version", "new version");
- return inputsMap;
- }
-
- private void editInputs(final ComponentPage componentPage, final Map<String, Object> inputsMap) {
- final EditComponentInputsFlow editComponentInputsFlow = new EditComponentInputsFlow(webDriver, inputsMap);
- editComponentInputsFlow.run(componentPage);
+ private Map<String, Object> createPropertyToEditMap() {
+ final Map<String, Object> propertyMap = new HashMap<>();
+ propertyMap.put("designer", "designer1");
+ propertyMap.put("descriptor_id", "descriptor_id1");
+ propertyMap.put("flavour_id", "flavour_id1");
+ propertyMap.put("invariant_id", "invariant_id1");
+ propertyMap.put("name", "name1");
+ propertyMap.put("version", "version1");
+ propertyMap.put("service_availability_level", 1);
+ //does not work yet with TOSCA complex types
+ propertyMap.put("ns_profile", null);
+ return propertyMap;
}
private ServiceCreateData createServiceFormData() {
@@ -300,8 +303,8 @@ public class EtsiNetworkServiceUiTests extends SetupCDTest {
return serviceCreateData;
}
- private void checkEtsiNsPackage(final String serviceName, final String downloadedCsarName, final Map<String, Object> expectedInputMap)
- throws UnzipException {
+ private void checkEtsiNsPackage(final String serviceName, final String downloadedCsarName,
+ final Map<String, Object> expectedPropertyMap) throws UnzipException {
final String downloadFolderPath = getConfig().getDownloadAutomationFolder();
final Map<String, byte[]> filesFromZip = FileHandling.getFilesFromZip(downloadFolderPath, downloadedCsarName);
final Optional<String> etsiPackageEntryOpt =
@@ -324,19 +327,19 @@ public class EtsiNetworkServiceUiTests extends SetupCDTest {
assertThat("Expecting the NSD CSAR signature " + nsdCsarSignature, nsPackageFileMap, hasKey(nsdCsarSignature));
final String nsdCertificate = nsdPackageBaseName + ".cert";
assertThat("Expecting the NSD CSAR certificate " + nsdCertificate, nsPackageFileMap, hasKey(nsdCertificate));
- checkNsCsar(nsdPackageBaseName, nodeType, nsPackageFileMap.get(nsdCsarFile), expectedInputMap);
+ checkNsCsar(nsdPackageBaseName, nodeType, expectedPropertyMap, nsPackageFileMap.get(nsdCsarFile));
return;
}
if (etsiPackageEntry.endsWith(".csar")) {
final Map<String, byte[]> nsPackageFileMap = FileHandling.getFilesFromZip(etsiPackageBytes);
- checkNsCsar(nsdPackageBaseName, nodeType, nsPackageFileMap.get(nsdCsarFile), expectedInputMap);
+ checkNsCsar(nsdPackageBaseName, nodeType, expectedPropertyMap, nsPackageFileMap.get(nsdCsarFile));
return;
}
fail(String.format("Unexpected ETSI NS PACKAGE entry '%s'. Expecting a '.csar' or '.zip'", etsiPackageEntry));
}
- private void checkNsCsar(final String expectedServiceName, final String expectedServiceNodeType,
- final byte[] nsCsar, final Map<String, Object> expectedInputMap) throws UnzipException {
+ private void checkNsCsar(final String expectedServiceName, final String expectedServiceNodeType, final Map<String, Object> expectedPropertiesMap,
+ final byte[] nsCsar) throws UnzipException {
final Map<String, byte[]> csarFileMap = FileHandling.getFilesFromZip(nsCsar);
final String mainDefinitionFile = String.format("Definitions/%s.yaml", expectedServiceName);
@@ -372,9 +375,9 @@ public class EtsiNetworkServiceUiTests extends SetupCDTest {
final Map<String, Object> properties = getMapEntry(serviceNodeTemplate, "properties");
assertThat(String.format("'%s' node template in '%s' should contain a properties entry", expectedServiceNodeType, mainDefinitionFile),
properties, notNullValue());
- assertThat(String.format("'%s' node template should contain '%s' properties", expectedServiceNodeType, expectedInputMap.size()),
- properties.size(), is(expectedInputMap.size()));
- for (final Entry<String, Object> expectedPropertyEntry : expectedInputMap.entrySet()) {
+ assertThat(String.format("'%s' node template should contain '%s' properties", expectedServiceNodeType, expectedPropertiesMap.size()),
+ properties.size(), is(expectedPropertiesMap.size()));
+ for (final Entry<String, Object> expectedPropertyEntry : expectedPropertiesMap.entrySet()) {
final String expectedPropertyName = expectedPropertyEntry.getKey();
assertThat(String.format("'%s' node template should contain the property '%s'", expectedServiceNodeType, expectedPropertyName),
properties, hasKey(expectedPropertyName));
@@ -382,7 +385,7 @@ public class EtsiNetworkServiceUiTests extends SetupCDTest {
if (expectedPropertyValue != null) {
final Object actualPropertyValue = properties.get(expectedPropertyName);
final String msg = String.format("The property '%s', in '%s' node template should have the expected value '%s'",
- expectedPropertyName, expectedServiceNodeType, expectedPropertyValue);
+ expectedPropertyName, expectedServiceNodeType, actualPropertyValue);
assertThat(msg, actualPropertyValue, is(expectedPropertyValue));
}
}
@@ -432,3 +435,4 @@ public class EtsiNetworkServiceUiTests extends SetupCDTest {
}
}
+
diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ModelToscaTypeImportTest.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ModelToscaTypeImportTest.java
index 1e57bb426a..3e8b0297a2 100644
--- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ModelToscaTypeImportTest.java
+++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ModelToscaTypeImportTest.java
@@ -27,7 +27,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
-import java.util.Collections;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -104,7 +104,7 @@ public class ModelToscaTypeImportTest extends SetupCDTest {
final var vf = new ResourceCreateData();
vf.setRandomName(ElementFactory.getResourcePrefix() + "-VF");
vf.setCategory(ResourceCategoryEnum.GENERIC_ABSTRACT.getSubCategory());
- vf.setTagList(Collections.singletonList(vf.getName()));
+ vf.setTagList(Arrays.asList(vf.getName()));
vf.setDescription("Test");
vf.setVendorName("EST");
vf.setVendorRelease("2.5.1");
@@ -149,13 +149,13 @@ public class ModelToscaTypeImportTest extends SetupCDTest {
final Map<String, byte[]> csarFiles = FileHandling.getFilesFromZip(downloadFolderPath, toscaArtifactsPage.getDownloadedArtifactList().get(0));
assertEquals(8, csarFiles.size());
- assertTrue(csarFiles.keySet().stream().anyMatch(filename -> filename.contains(NODE_TYPE_TO_ADD.concat("-template.yml"))));
- assertTrue(csarFiles.keySet().stream().anyMatch(filename -> filename.contains(MODEL_VNFD_TYPES.concat(".yaml"))));
- assertTrue(csarFiles.keySet().stream().anyMatch(filename -> filename.contains(MODEL_NSD_TYPES.concat(".yaml"))));
- assertTrue(csarFiles.keySet().stream().anyMatch(filename -> filename.contains("-template-interface".concat(".yml"))));
- assertTrue(csarFiles.keySet().stream().anyMatch(filename -> filename.contains(ADDITIONAL_TYPE_DEFINITIONS.concat(".yaml"))));
- assertTrue(csarFiles.values().stream().anyMatch(bytes -> new String(bytes).contains(TOSCA_CAPABILITIES_NETWORK_LINK)));
- assertTrue(csarFiles.values().stream().anyMatch(bytes -> new String(bytes).contains(ADDITIONAL_SERVICE_DATA)));
+ assertTrue(csarFiles.keySet().stream().filter(filename -> filename.contains(NODE_TYPE_TO_ADD.concat("-template.yml"))).findAny().isPresent());
+ assertTrue(csarFiles.keySet().stream().filter(filename -> filename.contains(MODEL_VNFD_TYPES.concat(".yaml"))).findAny().isPresent());
+ assertTrue(csarFiles.keySet().stream().filter(filename -> filename.contains(MODEL_NSD_TYPES.concat(".yaml"))).findAny().isPresent());
+ assertTrue(csarFiles.keySet().stream().filter(filename -> filename.contains("-template-interface".concat(".yml"))).findAny().isPresent());
+ assertTrue(csarFiles.keySet().stream().filter(filename -> filename.contains(ADDITIONAL_TYPE_DEFINITIONS.concat(".yaml"))).findAny().isPresent());
+ assertTrue(csarFiles.values().stream().filter(bytes -> new String(bytes).contains(TOSCA_CAPABILITIES_NETWORK_LINK)).findAny().isPresent());
+ assertTrue(csarFiles.values().stream().filter(bytes -> new String(bytes).contains(ADDITIONAL_SERVICE_DATA)).findAny().isPresent());
}
private ComponentPage addProperty(ComponentPage serviceComponentPage, final Map<String, String> propertyMap, String name) {
diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/EditComponentInputsFlow.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/EditComponentInputsFlow.java
deleted file mode 100644
index 0eac3d9339..0000000000
--- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/EditComponentInputsFlow.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.sdc.frontend.ci.tests.flow;
-
-import com.aventstack.extentreports.Status;
-import java.util.Map;
-import java.util.Optional;
-import org.apache.commons.collections4.MapUtils;
-import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions;
-import org.onap.sdc.frontend.ci.tests.pages.ComponentPage;
-import org.onap.sdc.frontend.ci.tests.pages.PageObject;
-import org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesAssignmentPage;
-import org.openqa.selenium.WebDriver;
-
-public class EditComponentInputsFlow extends AbstractUiTestFlow {
-
- private final Map<String, Object> inputsMap;
- private ComponentPage componentPage;
-
- public EditComponentInputsFlow(final WebDriver webDriver, final Map<String, Object> inputsMap) {
- super(webDriver);
- this.inputsMap = inputsMap;
- }
-
- @Override
- public Optional<ComponentPage> run(final PageObject... pageObjects) {
- componentPage = getParameter(pageObjects, ComponentPage.class).orElseGet(() -> new ComponentPage(webDriver));
- componentPage.isLoaded();
- if (MapUtils.isEmpty(inputsMap)) {
- return Optional.of(componentPage);
- }
- final ResourcePropertiesAssignmentPage resourcePropertiesAssignmentPage = componentPage.goToPropertiesAssignment();
- resourcePropertiesAssignmentPage.isLoaded();
- resourcePropertiesAssignmentPage.selectInputTab();
- final String inputNames = String.join(", ", inputsMap.keySet());
- ExtentTestActions.takeScreenshot(Status.INFO, "etsi-ns-edited-properties", String.format("Before editing inputs: %s", inputNames));
- extendTest.log(Status.INFO, "Editing inputs " + inputNames);
-
- inputsMap.forEach(resourcePropertiesAssignmentPage::setInputValue);
- resourcePropertiesAssignmentPage.saveInputs();
- ExtentTestActions.takeScreenshot(Status.INFO, "etsi-ns-edited-properties", String.format("Inputs edited: %s", inputNames));
- resourcePropertiesAssignmentPage.selectPropertiesTab();
- return Optional.of(componentPage);
- }
-
- @Override
- public Optional<ComponentPage> getLandedPage() {
- return Optional.ofNullable(componentPage);
- }
-}
diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentInputTab.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentInputTab.java
index 75f54167ba..a46e9a9bee 100644
--- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentInputTab.java
+++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentInputTab.java
@@ -20,35 +20,28 @@
package org.onap.sdc.frontend.ci.tests.pages;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.onap.sdc.frontend.ci.tests.pages.PropertyNameBuilder.buildInputField;
-import com.aventstack.extentreports.Status;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
+
import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions;
-import org.onap.sdc.frontend.ci.tests.utilities.LoaderHelper;
-import org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent;
-import org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent.NotificationType;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
-import org.openqa.selenium.support.ui.Select;
+
+import com.aventstack.extentreports.Status;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
/**
* Handles the Resource Properties Assignment Input Tab UI actions
*/
public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
- private LoaderHelper loaderHelper;
- private NotificationComponent notificationComponent;
-
public ResourcePropertiesAssignmentInputTab(final WebDriver webDriver) {
super(webDriver);
- notificationComponent = new NotificationComponent(webDriver);
- loaderHelper = new LoaderHelper(webDriver);
}
@Override
@@ -68,9 +61,8 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
/**
* Adds metadata to a property within the inputs tab based on a property name
- *
- * @param name used to determine which property to add metadata
- * @param key the metadata key to add
+ * @param name used to determine which property to add metadata
+ * @param key the metadata key to add
* @param value the metadata value to add
*/
public void setInputPropertyMetadata(String name, String key, String value) {
@@ -91,13 +83,12 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
public void saveInputProperties() {
findElement(By.xpath(XpathSelector.PROPERTY_SAVE_BTN.getXpath())).click();
- loaderHelper.waitForLoaderInvisibility(20);
- notificationComponent.waitForNotification(NotificationType.SUCCESS, 20);
+ waitForElementVisibility(XpathSelector.PROPERTY_SAVE_MESSAGE.getXpath());
+ waitForElementInvisibility(By.xpath(XpathSelector.PROPERTY_SAVE_MESSAGE.getXpath()));
}
/**
- * Adds an input
- *
+ * Adds a input
* @param inputsMap the inputs map to be added
*/
public void addInputs(final Map<String, String> inputsMap) {
@@ -115,7 +106,6 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
/**
* Fills the creation input modal.
- *
* @param inputName the input name to be created
* @param inputType the input type to be selected
*/
@@ -128,10 +118,9 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
/**
* Verifies if the added input is displayed on the UI.
- *
* @param inputsMap the input name to be found
*/
- public void verifyInputs(final Map<String, String> inputsMap) {
+ public void verifyInputs(final Map<String, String> inputsMap ) {
for (Map.Entry<String, String> input : inputsMap.entrySet()) {
assertTrue(this.getInputPropertyNames().contains(input.getKey()),
String.format("%s Input should be listed but found %s", input.getKey(),
@@ -140,8 +129,7 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
}
/**
- * Checks if an input exists.
- *
+ * Checks if a input exists.
* @param inputName the input name
* @return the value of the input
*/
@@ -155,40 +143,6 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
return true;
}
- public void setInputValue(final String inputName, final Object value) {
- if (value == null) {
- return;
- }
-
- if (value instanceof String) {
- setStringInputValue(inputName, (String) value);
- return;
- }
-
- if (value instanceof Integer) {
- setStringInputValue(inputName, ((Integer) value).toString());
- return;
- }
-
- if (value instanceof Boolean) {
- setBooleanPropertyValue(inputName, ((Boolean) value).toString());
- return;
- }
-
- throw new UnsupportedOperationException("Cannot set input value of type: " + value.getClass());
- }
-
- private void setStringInputValue(final String inputName, final String value) {
- isInputPropertiesTableLoaded();
- findElement(By.xpath(XpathSelector.INPUT_VALUE.formatXpath(buildInputField(inputName)))).sendKeys(value);
- }
-
- private void setBooleanPropertyValue(final String inputName, final String value) {
- isInputPropertiesTableLoaded();
- new Select(findElement(By.xpath(XpathSelector.INPUT_VALUE_BOOLEAN.formatXpath(buildInputField(inputName)))))
- .selectByVisibleText(value.toUpperCase());
- }
-
/**
* Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
*/
@@ -206,8 +160,6 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
INPUT_PROPERTY_ADD_METADATA_BUTTON(INPUT_PROPERTY_TABLE_ROW.getXpath().concat("//a")),
INPUT_PROPERTY_METADATA_KEY_VALUE_PAIR(INPUT_PROPERTY_TABLE_ROW.getXpath().concat("//input")),
INPUT_ADD_BTN("//div[contains(@class,'add-btn')]"),
- INPUT_VALUE("//input[contains(@class,'value-input') and @data-tests-id='%s']"),
- INPUT_VALUE_BOOLEAN("//select[@data-tests-id='%s']"),
MODAL_BACKGROUND("//div[@class='modal-background']");
@Getter
diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java
index 81c46a7907..cb4345c7cc 100644
--- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java
+++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java
@@ -45,8 +45,8 @@ public class ResourcePropertiesAssignmentPage extends ComponentPage {
@Override
public void isLoaded() {
super.isLoaded();
- waitForElementVisibility(XpathSelector.MAIN_DIV.getXpath());
- waitForElementVisibility(XpathSelector.TITLE_DIV.getXpath());
+ waitForElementVisibility((By.xpath(XpathSelector.MAIN_DIV.getXpath())));
+ waitForElementVisibility(By.xpath(XpathSelector.TITLE_DIV.getXpath()));
resourcePropertiesAssignmentTab.isLoaded();
}
@@ -54,7 +54,7 @@ public class ResourcePropertiesAssignmentPage extends ComponentPage {
* Select the Properties Tab to be displayed
*/
public void selectPropertiesTab() {
- findElement(XpathSelector.PROPERTIES_TAB.getXpath()).click();
+ findElement(By.xpath(XpathSelector.PROPERTIES_TAB.getXpath())).click();
resourcePropertiesAssignmentTab.isLoaded();
}
@@ -62,7 +62,7 @@ public class ResourcePropertiesAssignmentPage extends ComponentPage {
* Select the Input Tab to be displayed
*/
public void selectInputTab() {
- findElement(XpathSelector.INPUT_TAB.getXpath()).click();
+ findElement(By.xpath(XpathSelector.INPUT_TAB.getXpath())).click();
resourcePropertiesAssignmentInputTab.isLoaded();
}
@@ -74,10 +74,6 @@ public class ResourcePropertiesAssignmentPage extends ComponentPage {
resourcePropertiesAssignmentTab.setPropertyValue(propertyName, value);
}
- public void setInputValue(final String inputName, final Object value) {
- resourcePropertiesAssignmentInputTab.setInputValue(inputName, value);
- }
-
/**
* Retrieves a property value.
*
@@ -134,23 +130,23 @@ public class ResourcePropertiesAssignmentPage extends ComponentPage {
/**
* select property
*/
- public void selectProperty(String propertyName) {
+ public void selectProperty(String propertyName){
resourcePropertiesAssignmentTab.selectProperty(propertyName);
}
- public void loadComponentInstanceProperties(final String instanceName) {
+ public void loadComponentInstanceProperties(final String instanceName){
resourcePropertiesAssignmentTab.loadComponentInstanceProperties(instanceName);
}
- public void clickOnDeclareInput() {
+ public void clickOnDeclareInput(){
resourcePropertiesAssignmentTab.clickOnDeclareInput();
}
- public void loadCompositionTab() {
+ public void loadCompositionTab(){
resourcePropertiesAssignmentTab.loadCompositionTab();
}
- public void clickInputTab(String propertyName) {
+ public void clickInputTab(String propertyName){
waitForElementVisibility(By.xpath(XpathSelector.DECLARE_NOTIFIFICATION.getXpath()));
ExtentTestActions.takeScreenshot(Status.INFO, "Declare-Input", String.format("Added declared input for property %s", propertyName));
selectInputTab();