aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2018-05-23 18:54:31 +0300
committerTal Gitelman <tg851x@intl.att.com>2018-05-23 18:56:00 +0300
commitbd1e21e8e0aa2f04527be97506588597f7577314 (patch)
tree9bfa6b6a434a6c361d49f7b4d590dfb432d9e6f1 /catalog-be
parent636c993f04cbc3e52d40fd5c4c7126772d074179 (diff)
new unit tests for sdc-be
Change-Id: I00e47a2209aca116ee47ce4d20994086a292746b Issue-ID: SDC-1333 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/common/transaction/impl/ESActionTest.java29
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/common/transaction/impl/ESRollbackHandlerTest.java98
2 files changed, 127 insertions, 0 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/impl/ESActionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/impl/ESActionTest.java
new file mode 100644
index 0000000000..e01879226f
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/impl/ESActionTest.java
@@ -0,0 +1,29 @@
+package org.openecomp.sdc.common.transaction.impl;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.dao.impl.ESCatalogDAO;
+import org.openecomp.sdc.be.resources.data.ESArtifactData;
+import org.openecomp.sdc.common.transaction.api.TransactionUtils.DBActionCodeEnum;
+import org.openecomp.sdc.common.transaction.api.TransactionUtils.ESActionTypeEnum;
+import org.openecomp.sdc.exception.IndexingServiceException;
+
+public class ESActionTest {
+
+ @Test
+ public void testDoAction() throws Exception {
+ ESAction testSubject = new ESAction(new ESCatalogDAO(), new ESArtifactData(), ESActionTypeEnum.ADD_ARTIFACT);;
+ DBActionCodeEnum result;
+
+ // default test
+ result = testSubject.doAction();
+ }
+
+ @Test(expected = IndexingServiceException.class)
+ public void testDoAction1() throws Exception {
+ ESAction testSubject = new ESAction(new ESCatalogDAO(), new ESArtifactData(), ESActionTypeEnum.REMOVE_ARTIFACT);;
+ DBActionCodeEnum result;
+
+ // default test
+ result = testSubject.doAction();
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/impl/ESRollbackHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/impl/ESRollbackHandlerTest.java
new file mode 100644
index 0000000000..1c31949c1a
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/impl/ESRollbackHandlerTest.java
@@ -0,0 +1,98 @@
+package org.openecomp.sdc.common.transaction.impl;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.dao.api.ResourceUploadStatus;
+import org.openecomp.sdc.be.dao.impl.ESCatalogDAO;
+import org.openecomp.sdc.be.resources.data.ESArtifactData;
+import org.openecomp.sdc.common.transaction.api.TransactionUtils.DBActionCodeEnum;
+import org.openecomp.sdc.common.transaction.api.TransactionUtils.DBTypeEnum;
+import org.openecomp.sdc.common.transaction.api.TransactionUtils.ESActionTypeEnum;
+import org.openecomp.sdc.common.util.MethodActivationStatusEnum;
+
+import fj.data.Either;
+import mockit.Deencapsulation;
+
+public class ESRollbackHandlerTest {
+
+ @InjectMocks
+ ESRollbackHandler testSubject;
+ @Mock
+ ESCatalogDAO esCatalogDao;
+
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ private ESRollbackHandler createTestSubject() {
+ return new ESRollbackHandler(null, "", "");
+ }
+
+ @Test
+ public void testGetDBType() throws Exception {
+ DBTypeEnum result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getDBType();
+ }
+
+ @Test
+ public void testIsRollbackForPersistenceData() throws Exception {
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = Deencapsulation.invoke(testSubject, "isRollbackForPersistenceData");
+ }
+
+ @Test
+ public void testIsRollbackResultValid() throws Exception {
+ boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.isRollbackResultValid(DBActionCodeEnum.FAIL_GENERAL);
+ result = testSubject.isRollbackResultValid(DBActionCodeEnum.SUCCESS);
+ }
+
+ @Test
+ public void testBuildEsRollbackAction() throws Exception {
+ ESArtifactData artifactData = new ESArtifactData();
+ artifactData.setId("mock");
+ Either<ESAction, MethodActivationStatusEnum> result;
+
+ Either<ESArtifactData, ResourceUploadStatus> value = Either.left(new ESArtifactData());
+ Mockito.when(esCatalogDao.getArtifact(Mockito.anyString())).thenReturn(value);
+
+ // default test
+ for (ESActionTypeEnum iterable_element : ESActionTypeEnum.values()) {
+ testSubject = createTestSubject();
+ result = testSubject.buildEsRollbackAction(esCatalogDao, artifactData, iterable_element);
+ }
+ result = testSubject.buildEsRollbackAction(esCatalogDao, null, ESActionTypeEnum.ADD_ARTIFACT);
+ }
+
+ @Test
+ public void testBuildEsRollbackAction2() throws Exception {
+ ESArtifactData artifactData = new ESArtifactData();
+ artifactData.setId("mock");
+ Either<ESAction, MethodActivationStatusEnum> result;
+
+ Either<ESArtifactData, ResourceUploadStatus> value = Either.right(ResourceUploadStatus.NOT_EXIST);
+ Mockito.when(esCatalogDao.getArtifact(Mockito.anyString())).thenReturn(value);
+
+ // default test
+ for (ESActionTypeEnum iterable_element : ESActionTypeEnum.values()) {
+ testSubject = createTestSubject();
+ result = testSubject.buildEsRollbackAction(esCatalogDao, artifactData, iterable_element);
+ }
+ result = testSubject.buildEsRollbackAction(esCatalogDao, null, ESActionTypeEnum.ADD_ARTIFACT);
+ }
+} \ No newline at end of file