From 7457ecefb624682f6dddc558111b1d38f2a2ca83 Mon Sep 17 00:00:00 2001 From: JvD_Ericsson Date: Thu, 19 Jan 2023 14:43:33 +0000 Subject: Fix ability to add property to data type of different model Issue-ID: SDC-4339 Signed-off-by: JvD_Ericsson Change-Id: Ibc5b57a042ffc4e7f914d46ad264a0e16081b863 --- .../operations/impl/DataTypeOperationTest.java | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'catalog-model/src/test/java') 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 034269b715..5d68bf9bd9 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 @@ -113,6 +113,39 @@ class DataTypeOperationTest { assertThat(dataTypesFound.containsAll(dataTypesWithoutModel)).isFalse(); } + @Test + void getDataTypeByNameAndModelEtsiTest() { + final DataTypeData dataType = dataTypesWithModel.get(0); + final String dataTypeName = dataType.getDataTypeDataDefinition().getName(); + final String dataTypeUid = dataType.getDataTypeDataDefinition().getUniqueId(); + when(janusGraphGenericDao.getNode("name", dataTypeName, DataTypeData.class, modelName)) + .thenReturn(Either.left(dataType)); + final var dataTypeFound = dataTypeOperation.getDataTypeByNameAndModel(dataTypeName, model.getName()); + assertTrue(dataTypeFound.isPresent()); + DataTypeDataDefinition foundDataType = dataTypeFound.get(); + assertEquals(modelName ,foundDataType.getModel()); + assertEquals(dataTypeUid ,foundDataType.getUniqueId()); + } + + @Test + void getDataTypeByNameAndModelNotFoundTest() { + when(janusGraphGenericDao.getNode("name", "notReal", DataTypeData.class, modelName)) + .thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)); + final var dataTypesFound = dataTypeOperation.getDataTypeByNameAndModel("notReal", modelName); + assertTrue(dataTypesFound.isEmpty()); + } + + @Test + void getDataTypeByNameAndModelGeneralErrorTest() { + when(janusGraphGenericDao.getNode("name", "notReal", DataTypeData.class, modelName)) + .thenReturn(Either.right(JanusGraphOperationStatus.GENERAL_ERROR)); + final OperationException actualException = + assertThrows(OperationException.class, () -> dataTypeOperation.getDataTypeByNameAndModel("notReal", modelName)); + final OperationException expectedException = + DataTypeOperationExceptionSupplier.unexpectedErrorWhileFetchingProperties("notReal").get(); + assertEquals(expectedException.getMessage(), actualException.getMessage()); + } + @Test void getAllDataTypeNodesWithValidationErrorTest() { when(janusGraphGenericDao.getByCriteria(NodeTypeEnum.DataType, null, DataTypeData.class)) -- cgit 1.2.3-korg