diff options
author | vasraz <vasyl.razinkov@est.tech> | 2022-10-03 13:34:10 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2022-10-05 08:17:59 +0000 |
commit | 404bfc9c50e95df1e75dbf8325fae41bfd96871a (patch) | |
tree | 3a957dd7d8e541235d8f88bd2a131b308a4f24de /catalog-model/src/test | |
parent | 0899720f168c09d037e577109d7cab665fe1fb91 (diff) |
Implement API for fetching single data type
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Change-Id: Icebf660d67d503250e4f6d4d7fd5a2e169cdc951
Issue-ID: SDC-4184
Diffstat (limited to 'catalog-model/src/test')
-rw-r--r-- | catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperationTest.java | 24 |
1 files changed, 24 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 1580fd34b8..0efb751124 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 @@ -19,6 +19,11 @@ 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.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; import fj.data.Either; @@ -27,6 +32,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; @@ -34,6 +40,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao; 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.model.DataTypeDefinition; @@ -110,6 +117,23 @@ class DataTypeOperationTest { assertThat(dataTypesFound).isEmpty(); } + @Test + void getDataTypeByUidTest_Success() { + doReturn(Either.left(createDataTypeData("test.data.type99", "test.data.type00099", 888L, 999L, modelName))) + .when(janusGraphGenericDao).getNode(eq("uid"), eq("dataType"), any()); + final Optional<DataTypeDataDefinition> dataType = dataTypeOperation.getDataTypeByUid("dataType"); + assertTrue(dataType.isPresent()); + assertEquals("test.data.type99", dataType.get().getName()); + assertEquals("test.data.type00099", dataType.get().getUniqueId()); + assertEquals(modelName, dataType.get().getModel()); + } + + @Test + void getDataTypeByUidTest_Fail() { + doReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)).when(janusGraphGenericDao).getNode(eq("uid"), eq("dataType"), any()); + Optional<DataTypeDataDefinition> result = dataTypeOperation.getDataTypeByUid("dataType"); + assertTrue(result.isEmpty()); + } private void initTestData() { model = new Model(modelName, ModelTypeEnum.NORMATIVE); |