aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java
diff options
context:
space:
mode:
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>2023-01-11 18:41:05 +0000
committerVasyl Razinkov <vasyl.razinkov@est.tech>2023-01-16 22:10:54 +0000
commitc29a4519545ff509c038c9a19781ef210b2ee14f (patch)
tree75d1967be32dc167f9d0c5f77ac528539447fa41 /catalog-be/src/test/java
parenta8d208b231237fc9f05f83c2b33fa207d58f1480 (diff)
Constraint validation - Policy Properties in a Service
Issue-ID: SDC-4320 Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech> Change-Id: I5f04b630f89b96d7a662fbab8894961670502f52
Diffstat (limited to 'catalog-be/src/test/java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java
index f54a70d3d7..d0a91e312a 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/PolicyBusinessLogicTest.java
@@ -69,6 +69,7 @@ import org.openecomp.sdc.be.model.ComponentInstInputsMap;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.ComponentInstancePropInput;
import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.PolicyDefinition;
@@ -234,6 +235,10 @@ class PolicyBusinessLogicTest {
policy.setProperties(Arrays.asList(properties));
policies.put(POLICY_NAME, policy);
+ Map<String, DataTypeDefinition> types = new HashMap<>();
+ DataTypeDefinition dataTypeDef = new DataTypeDefinition();
+ types.put("string", dataTypeDef);
+
List<ComponentInstance> instanceList = new ArrayList<>();
ComponentInstance componentInstance = new ComponentInstance();
componentInstance.setUniqueId(UNIQUE_ID_EXSISTS);
@@ -251,6 +256,7 @@ class PolicyBusinessLogicTest {
Either.left(policy));
when(propertyOperation.validateAndUpdatePropertyValue(eq(newResource), eq(properties[0]), anyMap())).thenReturn(Either.left(prop1));
when(propertyOperation.validateAndUpdatePropertyValue(eq(newResource), eq(properties[1]), anyMap())).thenReturn(Either.left(prop2));
+ when(applicationDataTypeCache.getAll(any())).thenReturn(Either.left(types));
Map<String, PolicyDefinition> createdPolicy = businessLogic.createPolicies(newResource, policies);
@@ -276,6 +282,10 @@ class PolicyBusinessLogicTest {
policy.setProperties(Arrays.asList(properties));
policies.put(POLICY_NAME, policy);
+ Map<String, DataTypeDefinition> types = new HashMap<>();
+ DataTypeDefinition dataTypeDef = new DataTypeDefinition();
+ types.put("string", dataTypeDef);
+
List<ComponentInstance> instanceList = new ArrayList<>();
ComponentInstance componentInstance = new ComponentInstance();
componentInstance.setUniqueId(UNIQUE_ID_EXSISTS);
@@ -293,6 +303,7 @@ class PolicyBusinessLogicTest {
Either.left(policy));
when(propertyOperation.validateAndUpdatePropertyValue(eq(newService), eq(properties[0]), anyMap())).thenReturn(Either.left(prop1));
when(propertyOperation.validateAndUpdatePropertyValue(eq(newService), eq(properties[1]), anyMap())).thenReturn(Either.left(prop2));
+ when(applicationDataTypeCache.getAll(any())).thenReturn(Either.left(types));
Map<String, PolicyDefinition> createdPolicy = businessLogic.createPolicies(newService, policies);
@@ -408,12 +419,17 @@ class PolicyBusinessLogicTest {
String prop1 = "Name";
String prop2 = "Type";
+ Map<String, DataTypeDefinition> types = new HashMap<>();
+ DataTypeDefinition dataTypeDef = new DataTypeDefinition();
+ types.put("string", dataTypeDef);
+
when(toscaOperationFacade.updatePolicyOfComponent(eq(COMPONENT_ID), any(PolicyDefinition.class), any(PromoteVersionEnum.class))).thenReturn(
policySuccessEither);
stubUnlockAndCommit();
PropertyDataDefinition[] properties = getProperties(prop1, prop2);
when(propertyOperation.validateAndUpdatePropertyValue(any(Resource.class), eq(properties[0]), anyMap())).thenReturn(Either.left(prop1));
when(propertyOperation.validateAndUpdatePropertyValue(any(Resource.class), eq(properties[1]), anyMap())).thenReturn(Either.left(prop2));
+ when(applicationDataTypeCache.getAll(any())).thenReturn(Either.left(types));
policy.setProperties(Arrays.asList(properties));
List<PropertyDataDefinition> updatedProperties =
businessLogic.updatePolicyProperties(ComponentTypeEnum.RESOURCE, COMPONENT_ID, POLICY_ID, properties, USER_ID, true);
@@ -554,9 +570,11 @@ class PolicyBusinessLogicTest {
PropertyDataDefinition property1 = new PropertyDataDefinition();
property1.setName(prop1);
property1.setValue(prop1);
+ property1.setType("string");
PropertyDataDefinition property2 = new PropertyDataDefinition();
property2.setName(prop2);
property2.setValue(prop2);
+ property2.setType("string");
return new PropertyDataDefinition[]{property1, property2};
}