summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib
diff options
context:
space:
mode:
authorayalaben <ayala.benzvi@amdocs.com>2018-03-15 15:59:25 +0200
committerayalaben <ayala.benzvi@amdocs.com>2018-03-19 10:45:48 +0200
commit705fc2b672d5802696074be94b446a89d228b94d (patch)
tree135b0d30b36eaf0180314d68531186648ac29882 /openecomp-be/lib
parent3c24190cca30ee77c8c81d1738d7d5cbf454d647 (diff)
Archive Item
Change-Id: Idd5eedc3b0ca9e3cc72f7de9fd432cdbbf77631d Issue-ID: SDC-1086 Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
Diffstat (limited to 'openecomp-be/lib')
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java1
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/ToggleableFeature.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/type/ActivityType.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/AsdcItemManager.java22
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/ItemManager.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/Version.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/Item.java9
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/ItemStatus.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/NotificationEventTypes.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImpl.java14
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/ItemManagerImpl.java31
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImplTest.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ItemManagerImplTest.java96
13 files changed, 174 insertions, 29 deletions
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
index 21636690f7..0bf8796910 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
@@ -42,6 +42,7 @@ public enum Messages {
DELETE_VSP_ERROR("VSP has been certified and cannot be deleted."),
DELETE_VLM_ERROR("VLM has been certified and cannot be deleted."),
+
ZIP_SHOULD_NOT_CONTAIN_FOLDERS("Zip file should not contain folders"),
VES_ZIP_SHOULD_CONTAIN_YML_ONLY(
"Wrong VES EVENT Artifact was uploaded - all files contained in Artifact must be YAML files" +
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/ToggleableFeature.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/ToggleableFeature.java
index c3cac50ebe..5080e00ea3 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/ToggleableFeature.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/togglz/ToggleableFeature.java
@@ -10,7 +10,13 @@ public enum ToggleableFeature implements Feature {
VLAN_TAGGING,
@Label ("Annotations")
- ANNOTATIONS;
+ ANNOTATIONS,
+
+ @Label("Archive Item")
+ ARCHIVE_ITEM,
+
+ @Label("Filter")
+ FILTER;
public boolean isActive() {
return FeatureContext.getFeatureManager().isActive(this);
diff --git a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/type/ActivityType.java b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/type/ActivityType.java
index 620113e2b5..3f5b1b6235 100644
--- a/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/type/ActivityType.java
+++ b/openecomp-be/lib/openecomp-sdc-activity-log-lib/openecomp-sdc-activity-log-api/src/main/java/org/openecomp/sdc/activitylog/dao/type/ActivityType.java
@@ -2,6 +2,8 @@ package org.openecomp.sdc.activitylog.dao.type;
public enum ActivityType {
Create,
+ Archive,
+ Restore,
Create_Version,
Commit,
Submit,
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/AsdcItemManager.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/AsdcItemManager.java
index a4ea65fa08..ad3d1f304c 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/AsdcItemManager.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/AsdcItemManager.java
@@ -16,25 +16,7 @@
package org.openecomp.sdc.versioning;
-import java.util.Collection;
-import java.util.function.Predicate;
-import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import org.openecomp.sdc.versioning.types.Item;
+public interface AsdcItemManager extends ItemManager {
-public interface AsdcItemManager {
-
- Collection<Item> list(Predicate<Item> predicate);
-
- Item get(String itemId);
-
- Item create(Item item);
-
- void updateVersionStatus(String itemId, VersionStatus addedVersionStatus,
- VersionStatus removedVersionStatus);
-
- void updateOwner(String itemId, String owner);
-
- void updateName(String itemId, String name);
-
- void delete(Item item);
+ void updateOwner(String itemId, String owner);
}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/ItemManager.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/ItemManager.java
index 41a2c12058..0448ee782f 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/ItemManager.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/ItemManager.java
@@ -32,9 +32,11 @@ public interface ItemManager {
void updateVersionStatus(String itemId, VersionStatus addedVersionStatus,
VersionStatus removedVersionStatus);
- void delete(Item item);
+ void archive(Item item);
+
+ void restore(Item item);
- void updateName(String itemId, String name);
+ void delete(Item item);
void update(Item item);
}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/Version.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/Version.java
index b1f0b71d90..4d4c194972 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/Version.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/dao/types/Version.java
@@ -209,7 +209,7 @@ public class Version {
return major == version.major && minor == version.minor;
}
- public int compateTo(Version other){
+ public int compareTo(Version other){
if (this.major>other.major) {
return 1;
} else if(this.major<other.major){
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/Item.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/Item.java
index d572373d44..161c22c389 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/Item.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/Item.java
@@ -12,6 +12,7 @@ public class Item {
private String type;
private String name;
private String owner;
+ private ItemStatus status;
private String description;
private Map<String, Object> properties = new HashMap<>();
private Map<VersionStatus, Integer> versionStatusCounters = new EnumMap<>(VersionStatus.class);
@@ -50,6 +51,14 @@ public class Item {
this.owner = owner;
}
+ public ItemStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(ItemStatus status) {
+ this.status = status;
+ }
+
public String getDescription() {
return description;
}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/ItemStatus.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/ItemStatus.java
new file mode 100644
index 0000000000..413c5a7f29
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/ItemStatus.java
@@ -0,0 +1,6 @@
+package org.openecomp.sdc.versioning.types;
+
+public enum ItemStatus {
+ ACTIVE,
+ ARCHIVED
+}
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/NotificationEventTypes.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/NotificationEventTypes.java
index 336db6496c..da53d8d6ed 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/NotificationEventTypes.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-api/src/main/java/org/openecomp/sdc/versioning/types/NotificationEventTypes.java
@@ -7,6 +7,8 @@ package org.openecomp.sdc.versioning.types;
public enum NotificationEventTypes {
SUBMIT("submit"),
DELETE("delete"),
+ ARCHIVE("archive"),
+ RESTORE("restore"),
COMMIT("commit");
private String eventName;
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImpl.java
index 5a212afc8e..665bf06b91 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImpl.java
@@ -7,6 +7,7 @@ import org.openecomp.core.zusammen.api.ZusammenUtil;
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 java.util.Collection;
import java.util.Map;
@@ -67,6 +68,12 @@ public class ItemZusammenDaoImpl implements ItemDao {
item.setCreationTime(zusammenItem.getCreationTime());
item.setModificationTime(zusammenItem.getModificationTime());
+
+ if(item.getStatus() == null){
+ item.setStatus(ItemStatus.ACTIVE);
+ update(item);
+ }
+
return item;
}
@@ -78,6 +85,9 @@ public class ItemZusammenDaoImpl implements ItemDao {
case InfoPropertyName.ITEM_OWNER:
item.setOwner((String) propertyValue);
break;
+ case InfoPropertyName.ITEM_STATUS:
+ item.setStatus(ItemStatus.valueOf((String)propertyValue));
+ break;
case InfoPropertyName.ITEM_VERSIONS_STATUSES:
for (Map.Entry<String, Number> statusCounter :
((Map<String, Number>) propertyValue).entrySet()) {
@@ -96,6 +106,9 @@ public class ItemZusammenDaoImpl implements ItemDao {
info.setDescription(item.getDescription());
info.addProperty(InfoPropertyName.ITEM_TYPE, item.getType());
info.addProperty(InfoPropertyName.ITEM_OWNER,item.getOwner());
+ if (item.getStatus() != null) {
+ info.addProperty(InfoPropertyName.ITEM_STATUS, item.getStatus());
+ }
info.addProperty(InfoPropertyName.ITEM_VERSIONS_STATUSES, item.getVersionStatusCounters());
item.getProperties().entrySet()
.forEach(property -> info.addProperty(property.getKey(), property.getValue()));
@@ -106,6 +119,7 @@ public class ItemZusammenDaoImpl implements ItemDao {
private static final String ITEM_TYPE = "item_type";
private static final String ITEM_VERSIONS_STATUSES = "item_versions_statuses";
private static final String ITEM_OWNER = "Owner";
+ private static final String ITEM_STATUS = "status";
private InfoPropertyName() {
throw new IllegalStateException("Constants class");
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/ItemManagerImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/ItemManagerImpl.java
index dadf456ad4..3b7b018678 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/ItemManagerImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/ItemManagerImpl.java
@@ -19,10 +19,14 @@ package org.openecomp.sdc.versioning.impl;
import java.util.Collection;
import java.util.function.Predicate;
import java.util.stream.Collectors;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.versioning.ItemManager;
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;
public class ItemManagerImpl implements ItemManager {
@@ -72,17 +76,34 @@ public class ItemManagerImpl implements ItemManager {
}
@Override
- public void updateName(String itemId, String name) {
- Item item = get(itemId);
- if (item == null) {
- return;
+ public void archive(Item item) {
+
+ if (item.getStatus() == ItemStatus.ARCHIVED) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withCategory(ErrorCategory.APPLICATION)
+ .withMessage(String.format("Archive item failed, item %s is already Archived", item.getId()))
+ .build());
}
- item.setName(name);
+ item.setStatus(ItemStatus.ARCHIVED);
itemDao.update(item);
}
@Override
+ public void restore(Item item) {
+
+ if (item.getStatus() == ItemStatus.ACTIVE) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withCategory(ErrorCategory.APPLICATION)
+ .withMessage(String.format("Restore item failed, item %s is already Active", item.getId()))
+ .build());
+ }
+
+ item.setStatus(ItemStatus.ACTIVE);
+ itemDao.update(item);
+ }
+
+ @Override
public void update(Item item) {
itemDao.update(item);
}
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;
+ }
+}