From 78be848fcf71bf970cf4de16e22a37e09edeaaa7 Mon Sep 17 00:00:00 2001 From: Atif Husain Date: Wed, 4 Dec 2019 16:40:38 +1100 Subject: Added datatypes for 3rd Party Partners Issue-ID: SDC-2385 Change-Id: Iedc5d5b9b30e7cccd3654a1b6e84514643b6d62f Signed-off-by: Atif Husain --- .../PropertyValueConstraintValidationUtilTest.java | 137 +++++++++++++++++++++ 1 file changed, 137 insertions(+) (limited to 'catalog-be/src/test/java/org/openecomp') diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtilTest.java index eb48a5f3ab..2308c25fd8 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtilTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/PropertyValueConstraintValidationUtilTest.java @@ -286,6 +286,142 @@ public class PropertyValueConstraintValidationUtilTest { Assert.assertTrue(responseEither.isRight()); } + @Test + public void bandwidthTypeValueSuccessTest(){ + Either, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap); + Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either); + + PropertyDefinition propertyDefinition = new PropertyDefinition(); + propertyDefinition.setType("onap.datatypes.partner.bandwidth"); + propertyDefinition.setValue("{\"bandwidth_type\":\"guaranteed\"}"); + propertyDefinition.setName("bandwidth_type"); + + Either responseEither = + propertyValueConstraintValidationUtil.validatePropertyConstraints( + Collections.singletonList(propertyDefinition), applicationDataTypeCache); + + Assert.assertTrue(responseEither.isLeft()); + } + + @Test + public void bandwidthTypeValueFailTest(){ + Either, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap); + Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either); + + PropertyDefinition propertyDefinition = new PropertyDefinition(); + propertyDefinition.setType("onap.datatypes.partner.bandwidth"); + propertyDefinition.setValue("{\"bandwidth_type\":\"incorrectValue\"}"); + propertyDefinition.setName("bandwidth_type"); + + Either responseEither = + propertyValueConstraintValidationUtil.validatePropertyConstraints( + Collections.singletonList(propertyDefinition), applicationDataTypeCache); + + Assert.assertTrue(responseEither.isRight()); + } + + @Test + public void bandwidthDownstreamValueSuccessTest(){ + Either, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap); + Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either); + + PropertyDefinition propertyDefinition = new PropertyDefinition(); + propertyDefinition.setType("onap.datatypes.partner.bandwidth"); + propertyDefinition.setValue("{\"downstream\":\"128\"}"); + propertyDefinition.setName("downstream"); + + Either responseEither = + propertyValueConstraintValidationUtil.validatePropertyConstraints( + Collections.singletonList(propertyDefinition), applicationDataTypeCache); + + Assert.assertTrue(responseEither.isLeft()); + } + + @Test + public void bandwidthDownstreamValueFailTest(){ + Either, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap); + Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either); + + PropertyDefinition propertyDefinition = new PropertyDefinition(); + propertyDefinition.setType("onap.datatypes.partner.bandwidth"); + propertyDefinition.setValue("{\"downstream\":\"incorrectValue\"}"); + propertyDefinition.setName("downstream"); + + Either responseEither = + propertyValueConstraintValidationUtil.validatePropertyConstraints( + Collections.singletonList(propertyDefinition), applicationDataTypeCache); + + Assert.assertTrue(responseEither.isRight()); + } + + @Test + public void bandwidthUpstreamValueSuccessTest(){ + Either, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap); + Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either); + + PropertyDefinition propertyDefinition = new PropertyDefinition(); + propertyDefinition.setType("onap.datatypes.partner.bandwidth"); + propertyDefinition.setValue("{\"upstream\":\"128\"}"); + propertyDefinition.setName("upstream"); + + Either responseEither = + propertyValueConstraintValidationUtil.validatePropertyConstraints( + Collections.singletonList(propertyDefinition), applicationDataTypeCache); + + Assert.assertTrue(responseEither.isLeft()); + } + + @Test + public void bandwidthUpstreamValueFailTest(){ + Either, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap); + Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either); + + PropertyDefinition propertyDefinition = new PropertyDefinition(); + propertyDefinition.setType("onap.datatypes.partner.bandwidth"); + propertyDefinition.setValue("{\"upstream\":\"incorrectValue\"}"); + propertyDefinition.setName("upstream"); + + Either responseEither = + propertyValueConstraintValidationUtil.validatePropertyConstraints( + Collections.singletonList(propertyDefinition), applicationDataTypeCache); + + Assert.assertTrue(responseEither.isRight()); + } + + @Test + public void bandwidthUnitsValueSuccessTest(){ + Either, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap); + Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either); + + PropertyDefinition propertyDefinition = new PropertyDefinition(); + propertyDefinition.setType("onap.datatypes.partner.bandwidth"); + propertyDefinition.setValue("{\"units\":\"M\"}"); + propertyDefinition.setName("units"); + + Either responseEither = + propertyValueConstraintValidationUtil.validatePropertyConstraints( + Collections.singletonList(propertyDefinition), applicationDataTypeCache); + + Assert.assertTrue(responseEither.isLeft()); + } + + @Test + public void bandwidthUnitsValueFailTest(){ + Either, JanusGraphOperationStatus> either = Either.left(dataTypeDefinitionMap); + Mockito.when(applicationDataTypeCache.getAll()).thenReturn(either); + + PropertyDefinition propertyDefinition = new PropertyDefinition(); + propertyDefinition.setType("onap.datatypes.partner.bandwidth"); + propertyDefinition.setValue("{\"units\":\"incorrectValue\"}"); + propertyDefinition.setName("units"); + + Either responseEither = + propertyValueConstraintValidationUtil.validatePropertyConstraints( + Collections.singletonList(propertyDefinition), applicationDataTypeCache); + + Assert.assertTrue(responseEither.isRight()); + } + private void createDataTypeMap() { Type constraintType = new TypeToken() {}.getType(); Type typeOfHashMap = new TypeToken>() { }.getType(); @@ -335,3 +471,4 @@ public class PropertyValueConstraintValidationUtilTest { } } + -- cgit 1.2.3-korg