diff options
author | 2018-03-15 15:59:25 +0200 | |
---|---|---|
committer | 2018-03-19 10:45:48 +0200 | |
commit | 705fc2b672d5802696074be94b446a89d228b94d (patch) | |
tree | 135b0d30b36eaf0180314d68531186648ac29882 /openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org | |
parent | 3c24190cca30ee77c8c81d1738d7d5cbf454d647 (diff) |
Archive Item
Change-Id: Idd5eedc3b0ca9e3cc72f7de9fd432cdbbf77631d
Issue-ID: SDC-1086
Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org')
2 files changed, 100 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImplTest.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImplTest.java index bfa660a5a1..e67dc57de2 100644 --- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImplTest.java +++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImplTest.java @@ -10,6 +10,7 @@ import org.openecomp.core.zusammen.api.ZusammenAdaptor; import org.openecomp.sdc.common.session.SessionContextProviderFactory; import org.openecomp.sdc.versioning.dao.types.VersionStatus; import org.openecomp.sdc.versioning.types.Item; +import org.openecomp.sdc.versioning.types.ItemStatus; import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -28,6 +29,7 @@ import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.openecomp.sdc.versioning.dao.impl.zusammen.TestUtil.createZusammenContext; +import static org.testng.Assert.assertEquals; public class ItemZusammenDaoImplTest { @@ -114,6 +116,8 @@ public class ItemZusammenDaoImplTest { Assert.assertNotNull(item); assertItemEquals(item, toBeReturned); + assertEquals(item.getStatus(), ItemStatus.ACTIVE); + } @Test diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ItemManagerImplTest.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ItemManagerImplTest.java new file mode 100644 index 0000000000..fadfe3686e --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ItemManagerImplTest.java @@ -0,0 +1,96 @@ +package org.openecomp.sdc.versioning.impl; + +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.itempermissions.PermissionsServices; +import org.openecomp.sdc.notification.services.SubscriptionService; +import org.openecomp.sdc.versioning.dao.ItemDao; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; +import org.openecomp.sdc.versioning.types.Item; +import org.openecomp.sdc.versioning.types.ItemStatus; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import static org.mockito.Mockito.verify; +import static org.testng.Assert.assertEquals; + +public class ItemManagerImplTest { + + private static final String USER = "user1"; + private static final String ITEM_ID = "item1"; + private static final String ITEM_NAME = "item 1 name"; + private static final String ITEM_TYPE_A = "A"; + private static final String ITEM_TYPE_B = "B"; + private static final String tenant = "dox"; + @Mock + private ItemDao itemDao; + @Mock + private PermissionsServices permissionsServices; + @Mock + private SubscriptionService subscriptionService; + @InjectMocks + private ItemManagerImpl itemManager; + + @BeforeMethod + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @AfterMethod + public void tearDown(){ + itemManager = null; + } + + @Test + public void ArchiveTest(){ + + Item item = createItem(ITEM_ID,ITEM_NAME,ITEM_TYPE_A); + itemManager.archive(item); + + verify(itemDao).update(item); + assertEquals(item.getStatus(), ItemStatus.ARCHIVED); + } + + @Test(expectedExceptions = CoreException.class,expectedExceptionsMessageRegExp = + "Archive item failed, item .* is already Archived") + public void ArchiveTestNegative(){ + + Item item = createItem(ITEM_ID,ITEM_NAME,ITEM_TYPE_B); + item.setStatus(ItemStatus.ARCHIVED); + itemManager.archive(item); + + } + + @Test + public void RestoreTest(){ + + Item item = createItem(ITEM_ID,ITEM_NAME,ITEM_TYPE_A); + item.setStatus(ItemStatus.ARCHIVED); + itemManager.restore(item); + + verify(itemDao).update(item); + assertEquals(item.getStatus(), ItemStatus.ACTIVE); + } + + @Test(expectedExceptions = CoreException.class,expectedExceptionsMessageRegExp = + "Restore item failed, item .* is already Active") + public void RestoreTestNegative(){ + + Item item = createItem(ITEM_ID,ITEM_NAME,ITEM_TYPE_B); + item.setStatus(ItemStatus.ACTIVE); + itemManager.restore(item); + + } + + + private Item createItem(String id, String name, String type) { + Item item = new Item(); + item.setId(id); + item.setName(name); + item.setType(type); + return item; + } +} |