summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCoreBPMN/src/main/java
diff options
context:
space:
mode:
authorbiniek <lukasz.biniek@nokia.com>2018-01-31 12:59:37 +0100
committerbiniek <lukasz.biniek@nokia.com>2018-01-31 13:54:06 +0100
commitebd504c48d03d25e5b77d9094f4baa31581ee0f1 (patch)
treea2602d48d3e5166e52904d95c277637341dfeb08 /bpmn/MSOCoreBPMN/src/main/java
parent9c55afa6a9f368d151b69c8f2766419ff8c8577c (diff)
Added unittests for RollbackData
Change-Id: I3c6f3b204e3cea6acce643f023f73561765226ee Issue-ID: SO-374 Signed-off-by: biniek <lukasz.biniek@nokia.com>
Diffstat (limited to 'bpmn/MSOCoreBPMN/src/main/java')
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java127
1 files changed, 60 insertions, 67 deletions
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java
index 7ece05ea9e..64068d2b90 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/RollbackData.java
@@ -23,6 +23,7 @@ package org.openecomp.mso.bpmn.core;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
+import java.util.stream.Collectors;
/**
* An object that stores data for rollbacks. Data is organized by type. A
@@ -30,80 +31,72 @@ import java.util.Map;
* in the same object for separate rollback operations.
*/
public class RollbackData implements Serializable {
- private static final long serialVersionUID = 1L;
- private Map<String, Map<String, Serializable>> dictionary =
- new HashMap<String, Map<String, Serializable>>();
-
- /**
- * Returns true if the specified type is stored in this object.
- * @param type the data type
- */
- public boolean hasType(String type) {
- return dictionary.containsKey(type);
- }
+ private static final long serialVersionUID = 1L;
- /**
- * Stores a single item.
- * @param type the data type
- * @param key the key
- * @param value the value
- */
- public void put(String type, String key, String value) {
- Map<String, Serializable> mapForType = dictionary.get(type);
+ private Map<String, Map<String, Serializable>> dictionary =
+ new HashMap<String, Map<String, Serializable>>();
- if (mapForType == null) {
- mapForType = new HashMap<String, Serializable>();
- dictionary.put(type, mapForType);
- }
+ /**
+ * Returns true if the specified type is stored in this object.
+ *
+ * @param type the data type
+ */
+ public boolean hasType(String type) {
+ return dictionary.containsKey(type);
+ }
- mapForType.put(key, value);
- }
+ /**
+ * Stores a single item.
+ *
+ * @param type the data type
+ * @param key the key
+ * @param value the value
+ */
+ public void put(String type, String key, String value) {
+ Map<String, Serializable> mapForType = dictionary.get(type);
- /**
- * Gets a single item.
- * @param type the data type
- * @param key the key
- * @return the item or null if there is no item for the specified type and key
- */
- public Serializable get(String type, String key) {
- Map<String, Serializable> mapForType = dictionary.get(type);
+ if (mapForType == null) {
+ mapForType = new HashMap<String, Serializable>();
+ dictionary.put(type, mapForType);
+ }
- if (mapForType == null) {
- return null;
- }
+ mapForType.put(key, value);
+ }
- return mapForType.get(key);
- }
+ /**
+ * Gets a single item.
+ *
+ * @param type the data type
+ * @param key the key
+ * @return the item or null if there is no item for the specified type and key
+ */
+ public Serializable get(String type, String key) {
+ Map<String, Serializable> mapForType = dictionary.get(type);
- /**
- * Gets a map containing all items associated with the specified data type.
- * @param type the data type
- * @return a map, or null if there are no items associated with the specified
- * data type
- */
- public Map<String, Serializable> get(String type) {
- return dictionary.get(type);
- }
+ if (mapForType == null) {
+ return null;
+ }
- /**
- * Returns a string representation of this object.
- */
- @Override
- public String toString() {
- StringBuilder out = new StringBuilder();
- out.append(getClass().getSimpleName());
- out.append('[');
- boolean hasOne = false;
- for (String type : dictionary.keySet()) {
- if (hasOne) {
- out.append(',');
- }
- out.append(type);
- out.append(dictionary.get(type));
- hasOne = true;
- }
- out.append(']');
- return out.toString();
- }
+ return mapForType.get(key);
+ }
+
+ /**
+ * Gets a map containing all items associated with the specified data type.
+ *
+ * @param type the data type
+ * @return a map, or null if there are no items associated with the specified data type
+ */
+ public Map<String, Serializable> get(String type) {
+ return dictionary.get(type);
+ }
+
+ /**
+ * Returns a string representation of this object.
+ */
+ @Override
+ public String toString() {
+ return dictionary.entrySet().stream().map(entry -> entry.getKey() + entry.getValue())
+ .collect(Collectors.joining(",", "[", "]"));
+ }
}