summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/test/java/org
diff options
context:
space:
mode:
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>2021-09-02 13:15:51 +0100
committerMichael Morris <michael.morris@est.tech>2021-09-20 13:35:20 +0000
commit3608fa7d186a3acffda0f3040abaad068a081410 (patch)
treef7591a69f107b42a2b82f8ff923f136eea4ea024 /catalog-model/src/test/java/org
parent79165dcada554b625553e982b39d817c7f9d1747 (diff)
Error re-importing VSP
Issue-ID: SDC-3728 Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech> Signed-off-by: André Schmid <andre.schmid@est.tech> Change-Id: I22d6186b8e6922511a7ede584d009cfae041fabd
Diffstat (limited to 'catalog-model/src/test/java/org')
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperationTest.java5
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelElementOperationTest.java96
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java12
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java2
4 files changed, 105 insertions, 10 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 d93b7986f8..1580fd34b8 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
@@ -38,7 +38,6 @@ import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.Model;
-import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.resources.data.DataTypeData;
import org.springframework.test.context.ContextConfiguration;
@@ -51,8 +50,6 @@ class DataTypeOperationTest {
private ModelOperation modelOperation;
@Mock
private HealingJanusGraphGenericDao janusGraphGenericDao;
- @Mock
- private ApplicationDataTypeCache applicationDataTypeCache;
private final String modelName = "ETSI-SDC-MODEL-TEST";
private final List<DataTypeData> dataTypesWithoutModel = new ArrayList<>();
@@ -61,10 +58,10 @@ class DataTypeOperationTest {
final Map<String, DataTypeDefinition> allDataTypesFoundDefinitionMap = new HashMap<>();
private Model model;
-
@BeforeEach
void beforeEachInit() {
MockitoAnnotations.openMocks(this);
+ dataTypeOperation.setModelOperation(modelOperation);
initTestData();
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelElementOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelElementOperationTest.java
new file mode 100644
index 0000000000..3de1369e83
--- /dev/null
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelElementOperationTest.java
@@ -0,0 +1,96 @@
+/*
+ * -
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.model.operations.impl;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao;
+import org.openecomp.sdc.be.model.Model;
+
+class ModelElementOperationTest {
+
+ @Mock
+ private JanusGraphGenericDao janusGraphGenericDao;
+ @Mock
+ private DataTypeOperation dataTypeOperation;
+ @Mock
+ private PolicyTypeOperation policyTypeOperation;
+ @InjectMocks
+ private ModelElementOperation modelElementOperation;
+
+ @BeforeEach
+ void setUp() {
+ MockitoAnnotations.openMocks(this);
+ }
+
+ @Test
+ void deleteModelElements_noTransactionSuccessTest() {
+ var model = new Model("name");
+ final String modelId = UniqueIdBuilder.buildModelUid(model.getName());
+ modelElementOperation.deleteModelElements(model, false);
+ verify(dataTypeOperation).deleteDataTypesByModelId(modelId);
+ verify(policyTypeOperation).deletePolicyTypesByModelId(modelId);
+ verify(janusGraphGenericDao).commit();
+ verify(janusGraphGenericDao, times(0)).rollback();
+ }
+
+ @Test
+ void deleteModelElements_inTransactionSuccessTest() {
+ var model = new Model("name");
+ final String modelId = UniqueIdBuilder.buildModelUid(model.getName());
+ modelElementOperation.deleteModelElements(model, true);
+ verify(dataTypeOperation).deleteDataTypesByModelId(modelId);
+ verify(policyTypeOperation).deletePolicyTypesByModelId(modelId);
+ verify(janusGraphGenericDao, times(0)).commit();
+ verify(janusGraphGenericDao, times(0)).rollback();
+ }
+
+ @Test
+ void deleteModelElements_noTransactionErrorTest() {
+ var model = new Model("name");
+ final String modelId = UniqueIdBuilder.buildModelUid(model.getName());
+ doThrow(new RuntimeException()).when(dataTypeOperation).deleteDataTypesByModelId(modelId);
+ assertThrows(RuntimeException.class, () -> modelElementOperation.deleteModelElements(model, false));
+ verify(dataTypeOperation).deleteDataTypesByModelId(modelId);
+ verify(janusGraphGenericDao).rollback();
+ verify(janusGraphGenericDao, times(0)).commit();
+ }
+
+ @Test
+ void deleteModelElements_inTransactionErrorTest() {
+ var model = new Model("name");
+ final String modelId = UniqueIdBuilder.buildModelUid(model.getName());
+ doThrow(new RuntimeException()).when(dataTypeOperation).deleteDataTypesByModelId(modelId);
+ assertThrows(RuntimeException.class, () -> modelElementOperation.deleteModelElements(model, true));
+ verify(dataTypeOperation).deleteDataTypesByModelId(modelId);
+ verify(janusGraphGenericDao, times(0)).commit();
+ verify(janusGraphGenericDao, times(0)).rollback();
+ }
+} \ No newline at end of file
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java
index 793af71bbd..a3c9bca4e5 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java
@@ -73,12 +73,12 @@ public class PropertyOperationTest extends ModelTestBase {
final DataTypeOperation dataTypeOperation = mock(DataTypeOperation.class);
- PropertyOperation propertyOperation = new PropertyOperation(janusGraphGenericDao, null, dataTypeOperation);
+ PropertyOperation propertyOperation = new PropertyOperation(janusGraphGenericDao, null);
@Before
public void setup() {
+ propertyOperation.setDataTypeOperation(dataTypeOperation);
propertyOperation.setJanusGraphGenericDao(janusGraphGenericDao);
-
}
private PropertyDefinition buildPropertyDefinition() {
@@ -456,9 +456,11 @@ public class PropertyOperationTest extends ModelTestBase {
}
- private PropertyOperation createTestSubject() {
- return new PropertyOperation(new HealingJanusGraphGenericDao(new JanusGraphClient()), null, dataTypeOperation);
- }
+ private PropertyOperation createTestSubject() {
+ final var propertyOperation = new PropertyOperation(new HealingJanusGraphGenericDao(new JanusGraphClient()), null);
+ propertyOperation.setDataTypeOperation(dataTypeOperation);
+ return propertyOperation;
+ }
@Test
public void testConvertPropertyDataToPropertyDefinition() throws Exception {
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java
index a80e44e921..b4f61563c1 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java
@@ -262,7 +262,7 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase {
expectedIds.add(vertex4.getUniqueId());
verifyInCatalogData(4, expectedIds);
- lifecycleOperation.undoCheckout(vertex4.getUniqueId());
+ lifecycleOperation.undoCheckout(vertex4.getUniqueId(), null);
expectedIds.remove(vertex4.getUniqueId());
verifyInCatalogData(3, expectedIds);