killbill-aplcache

Details

diff --git a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/BundleJsonSimple.java b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/BundleJsonSimple.java
index 4b8d09f..f2735b3 100644
--- a/jaxrs/src/main/java/com/ning/billing/jaxrs/json/BundleJsonSimple.java
+++ b/jaxrs/src/main/java/com/ning/billing/jaxrs/json/BundleJsonSimple.java
@@ -48,4 +48,32 @@ public class BundleJsonSimple {
     public String getExternalKey() {
         return externalKey;
     }
+
+    @Override
+    public boolean equals(final Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        final BundleJsonSimple that = (BundleJsonSimple) o;
+
+        if (bundleId != null ? !bundleId.equals(that.bundleId) : that.bundleId != null) {
+            return false;
+        }
+        if (externalKey != null ? !externalKey.equals(that.externalKey) : that.externalKey != null) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = bundleId != null ? bundleId.hashCode() : 0;
+        result = 31 * result + (externalKey != null ? externalKey.hashCode() : 0);
+        return result;
+    }
 }
diff --git a/jaxrs/src/test/java/com/ning/billing/jaxrs/json/TestBundleJsonSimple.java b/jaxrs/src/test/java/com/ning/billing/jaxrs/json/TestBundleJsonSimple.java
new file mode 100644
index 0000000..1530ba5
--- /dev/null
+++ b/jaxrs/src/test/java/com/ning/billing/jaxrs/json/TestBundleJsonSimple.java
@@ -0,0 +1,28 @@
+package com.ning.billing.jaxrs.json;
+
+import java.util.UUID;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class TestBundleJsonSimple {
+    private static final ObjectMapper mapper = new ObjectMapper();
+
+    @Test(groups = "fast")
+    public void testJson() throws Exception {
+        final String bundleId = UUID.randomUUID().toString();
+        final String externalKey = UUID.randomUUID().toString();
+        final BundleJsonSimple bundleJsonSimple = new BundleJsonSimple(bundleId, externalKey);
+        Assert.assertEquals(bundleJsonSimple.getBundleId(), bundleId);
+        Assert.assertEquals(bundleJsonSimple.getExternalKey(), externalKey);
+
+        final String asJson = mapper.writeValueAsString(bundleJsonSimple);
+        Assert.assertEquals(asJson, "{\"bundleId\":\"" + bundleJsonSimple.getBundleId() + "\"," +
+                "\"externalKey\":\"" + bundleJsonSimple.getExternalKey() + "\"}");
+
+        final BundleJsonSimple fromJson = mapper.readValue(asJson, BundleJsonSimple.class);
+        Assert.assertEquals(fromJson, bundleJsonSimple);
+    }
+}