summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/test
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2022-10-04 20:29:28 +0100
committerMichael Morris <michael.morris@est.tech>2022-10-17 14:42:22 +0000
commitaa72781388f3e6408bb43f1b024d88ec1c9d2c10 (patch)
tree15002a934486557f1d62eec49e57af1e2e59b443 /catalog-model/src/test
parentb75fe3c7ce231c86cd4c6d052da453d02809c8f9 (diff)
Add data type properties workspace
Implements the properties workspace for a data type, with the list and filter feature. Change-Id: I2ec337a0481bddd5fe32e45644abdc88e197fa49 Issue-ID: SDC-4214 Signed-off-by: André Schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-model/src/test')
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperationTest.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperationTest.java
index 0efb751124..1f448fd875 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperationTest.java
@@ -20,6 +20,7 @@ package org.openecomp.sdc.be.model.operations.impl;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
@@ -43,8 +44,11 @@ import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.DataTypeDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.exception.OperationException;
+import org.openecomp.sdc.be.exception.supplier.DataTypeOperationExceptionSupplier;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.Model;
+import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.resources.data.DataTypeData;
import org.springframework.test.context.ContextConfiguration;
@@ -57,6 +61,8 @@ class DataTypeOperationTest {
private ModelOperation modelOperation;
@Mock
private HealingJanusGraphGenericDao janusGraphGenericDao;
+ @Mock
+ private PropertyOperation propertyOperation;
private final String modelName = "ETSI-SDC-MODEL-TEST";
private final List<DataTypeData> dataTypesWithoutModel = new ArrayList<>();
@@ -69,6 +75,7 @@ class DataTypeOperationTest {
void beforeEachInit() {
MockitoAnnotations.openMocks(this);
dataTypeOperation.setModelOperation(modelOperation);
+ dataTypeOperation.setPropertyOperation(propertyOperation);
initTestData();
}
@@ -135,6 +142,51 @@ class DataTypeOperationTest {
assertTrue(result.isEmpty());
}
+ @Test
+ void findAllPropertiesTest_Success() {
+ final PropertyDefinition property1 = new PropertyDefinition();
+ property1.setName("property1");
+ final PropertyDefinition property2 = new PropertyDefinition();
+ property2.setName("property2");
+ final PropertyDefinition property3 = new PropertyDefinition();
+ property3.setName("property3");
+
+ when(propertyOperation.findPropertiesOfNode(NodeTypeEnum.DataType, "uniqueId"))
+ .thenReturn(Either.left(Map.of(property3.getName(), property3, property1.getName(), property1, property2.getName(), property2)));
+ final List<PropertyDefinition> dataTypeProperties = dataTypeOperation.findAllProperties("uniqueId");
+ assertEquals(3, dataTypeProperties.size());
+ assertEquals(property1.getName(), dataTypeProperties.get(0).getName());
+ assertEquals(property2.getName(), dataTypeProperties.get(1).getName());
+ assertEquals(property3.getName(), dataTypeProperties.get(2).getName());
+ }
+
+ @Test
+ void findAllPropertiesTest_propertiesNotFoundSuccess() {
+ when(propertyOperation.findPropertiesOfNode(NodeTypeEnum.DataType, "uniqueId"))
+ .thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
+ final List<PropertyDefinition> dataTypeProperties = dataTypeOperation.findAllProperties("uniqueId");
+ assertTrue(dataTypeProperties.isEmpty());
+ }
+
+ @Test
+ void findAllPropertiesTest_emptyPropertiesSuccess() {
+ when(propertyOperation.findPropertiesOfNode(NodeTypeEnum.DataType, "uniqueId"))
+ .thenReturn(Either.left(Map.of()));
+ final List<PropertyDefinition> dataTypeProperties = dataTypeOperation.findAllProperties("uniqueId");
+ assertTrue(dataTypeProperties.isEmpty());
+ }
+
+ @Test
+ void findAllPropertiesTest_unknownError() {
+ final String uniqueId = "uniqueId";
+ when(propertyOperation.findPropertiesOfNode(NodeTypeEnum.DataType, uniqueId))
+ .thenReturn(Either.right(JanusGraphOperationStatus.GENERAL_ERROR));
+ final OperationException actualException = assertThrows(OperationException.class, () -> dataTypeOperation.findAllProperties(uniqueId));
+ final OperationException expectedException =
+ DataTypeOperationExceptionSupplier.unexpectedErrorWhileFetchingProperties(uniqueId).get();
+ assertEquals(expectedException.getMessage(), actualException.getMessage());
+ }
+
private void initTestData() {
model = new Model(modelName, ModelTypeEnum.NORMATIVE);
final String TEST_DATA_TYPE_001 = "test.data.type001";