killbill-memoizeit

util: add container objects for audit logs As we start exposing

8/10/2012 2:37:08 PM

Details

diff --git a/api/src/main/java/com/ning/billing/util/audit/AuditLogsForBundles.java b/api/src/main/java/com/ning/billing/util/audit/AuditLogsForBundles.java
new file mode 100644
index 0000000..0eecc75
--- /dev/null
+++ b/api/src/main/java/com/ning/billing/util/audit/AuditLogsForBundles.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.util.audit;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+public interface AuditLogsForBundles {
+
+    /**
+     * @return mapping between bundle id and associated audit logs
+     */
+    public Map<UUID, List<AuditLog>> getBundlesAuditLogs();
+
+    /**
+     * @return mapping between subscription event id and associated audit logs
+     */
+    public Map<UUID, List<AuditLog>> getSubscriptionEventsAuditLogs();
+}
diff --git a/api/src/main/java/com/ning/billing/util/audit/AuditLogsForInvoicePayments.java b/api/src/main/java/com/ning/billing/util/audit/AuditLogsForInvoicePayments.java
new file mode 100644
index 0000000..009fbe2
--- /dev/null
+++ b/api/src/main/java/com/ning/billing/util/audit/AuditLogsForInvoicePayments.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.util.audit;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+public interface AuditLogsForInvoicePayments {
+
+    /**
+     * @return mapping between invoice payment id and associated audit logs
+     */
+    public Map<UUID, List<AuditLog>> getInvoicePaymentsAuditLogs();
+}
diff --git a/api/src/main/java/com/ning/billing/util/audit/AuditLogsForInvoices.java b/api/src/main/java/com/ning/billing/util/audit/AuditLogsForInvoices.java
new file mode 100644
index 0000000..99e20a4
--- /dev/null
+++ b/api/src/main/java/com/ning/billing/util/audit/AuditLogsForInvoices.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.util.audit;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+public interface AuditLogsForInvoices {
+
+    /**
+     * @return mapping between invoice id and associated audit logs
+     */
+    public Map<UUID, List<AuditLog>> getInvoiceAuditLogs();
+
+    /**
+     * @return mapping between invoice item id and associated audit logs
+     */
+    public Map<UUID, List<AuditLog>> getInvoiceItemsAuditLogs();
+}
diff --git a/api/src/main/java/com/ning/billing/util/audit/AuditLogsForPayments.java b/api/src/main/java/com/ning/billing/util/audit/AuditLogsForPayments.java
new file mode 100644
index 0000000..8e1bc19
--- /dev/null
+++ b/api/src/main/java/com/ning/billing/util/audit/AuditLogsForPayments.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.util.audit;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+public interface AuditLogsForPayments {
+
+    /**
+     * @return mapping between payment id and associated audit logs
+     */
+    public Map<UUID, List<AuditLog>> getPaymentsAuditLogs();
+}
diff --git a/api/src/main/java/com/ning/billing/util/audit/AuditLogsForRefunds.java b/api/src/main/java/com/ning/billing/util/audit/AuditLogsForRefunds.java
new file mode 100644
index 0000000..152a1fc
--- /dev/null
+++ b/api/src/main/java/com/ning/billing/util/audit/AuditLogsForRefunds.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.util.audit;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+public interface AuditLogsForRefunds {
+
+    /**
+     * @return mapping between refund id and associated audit logs
+     */
+    public Map<UUID, List<AuditLog>> getRefundsAuditLogs();
+}
diff --git a/util/src/main/java/com/ning/billing/util/audit/DefaultAuditLogsForBundles.java b/util/src/main/java/com/ning/billing/util/audit/DefaultAuditLogsForBundles.java
new file mode 100644
index 0000000..4e35a2d
--- /dev/null
+++ b/util/src/main/java/com/ning/billing/util/audit/DefaultAuditLogsForBundles.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.util.audit;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+public class DefaultAuditLogsForBundles implements AuditLogsForBundles {
+
+    private final Map<UUID, List<AuditLog>> bundlesAuditLogs;
+
+    public DefaultAuditLogsForBundles(final Map<UUID, List<AuditLog>> bundlesAuditLogs) {
+        this.bundlesAuditLogs = bundlesAuditLogs;
+    }
+
+    @Override
+    public Map<UUID, List<AuditLog>> getBundlesAuditLogs() {
+        return bundlesAuditLogs;
+    }
+
+    @Override
+    public Map<UUID, List<AuditLog>> getSubscriptionEventsAuditLogs() {
+        // TODO
+        return null;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder();
+        sb.append("DefaultAuditLogsForBundles");
+        sb.append("{bundlesAuditLogs=").append(bundlesAuditLogs);
+        sb.append('}');
+        return sb.toString();
+    }
+
+    @Override
+    public boolean equals(final Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        final DefaultAuditLogsForBundles that = (DefaultAuditLogsForBundles) o;
+
+        if (bundlesAuditLogs != null ? !bundlesAuditLogs.equals(that.bundlesAuditLogs) : that.bundlesAuditLogs != null) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return bundlesAuditLogs != null ? bundlesAuditLogs.hashCode() : 0;
+    }
+}
diff --git a/util/src/main/java/com/ning/billing/util/audit/DefaultAuditLogsForInvoicePayments.java b/util/src/main/java/com/ning/billing/util/audit/DefaultAuditLogsForInvoicePayments.java
new file mode 100644
index 0000000..06c3935
--- /dev/null
+++ b/util/src/main/java/com/ning/billing/util/audit/DefaultAuditLogsForInvoicePayments.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.util.audit;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+public class DefaultAuditLogsForInvoicePayments implements AuditLogsForInvoicePayments {
+
+    private final Map<UUID, List<AuditLog>> invoicePaymentsAuditLogs;
+
+    public DefaultAuditLogsForInvoicePayments(final Map<UUID, List<AuditLog>> invoicePaymentsAuditLogs) {
+        this.invoicePaymentsAuditLogs = invoicePaymentsAuditLogs;
+    }
+
+    @Override
+    public Map<UUID, List<AuditLog>> getInvoicePaymentsAuditLogs() {
+        return invoicePaymentsAuditLogs;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder();
+        sb.append("DefaultAuditLogsForInvoicePayments");
+        sb.append("{invoicePaymentsAuditLogs=").append(invoicePaymentsAuditLogs);
+        sb.append('}');
+        return sb.toString();
+    }
+
+    @Override
+    public boolean equals(final Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        final DefaultAuditLogsForInvoicePayments that = (DefaultAuditLogsForInvoicePayments) o;
+
+        if (invoicePaymentsAuditLogs != null ? !invoicePaymentsAuditLogs.equals(that.invoicePaymentsAuditLogs) : that.invoicePaymentsAuditLogs != null) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return invoicePaymentsAuditLogs != null ? invoicePaymentsAuditLogs.hashCode() : 0;
+    }
+}
diff --git a/util/src/main/java/com/ning/billing/util/audit/DefaultAuditLogsForInvoices.java b/util/src/main/java/com/ning/billing/util/audit/DefaultAuditLogsForInvoices.java
new file mode 100644
index 0000000..b094dcf
--- /dev/null
+++ b/util/src/main/java/com/ning/billing/util/audit/DefaultAuditLogsForInvoices.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.util.audit;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+public class DefaultAuditLogsForInvoices implements AuditLogsForInvoices {
+
+    private final Map<UUID, List<AuditLog>> invoiceAuditLogs;
+    private final Map<UUID, List<AuditLog>> invoiceItemsAuditLogs;
+
+    public DefaultAuditLogsForInvoices(final Map<UUID, List<AuditLog>> invoiceAuditLogs, final Map<UUID, List<AuditLog>> invoiceItemsAuditLogs) {
+        this.invoiceAuditLogs = invoiceAuditLogs;
+        this.invoiceItemsAuditLogs = invoiceItemsAuditLogs;
+    }
+
+    @Override
+    public Map<UUID, List<AuditLog>> getInvoiceAuditLogs() {
+        return invoiceAuditLogs;
+    }
+
+    @Override
+    public Map<UUID, List<AuditLog>> getInvoiceItemsAuditLogs() {
+        return invoiceItemsAuditLogs;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder();
+        sb.append("DefaultAuditLogsForInvoices");
+        sb.append("{invoiceAuditLogs=").append(invoiceAuditLogs);
+        sb.append(", invoiceItemsAuditLogs=").append(invoiceItemsAuditLogs);
+        sb.append('}');
+        return sb.toString();
+    }
+
+    @Override
+    public boolean equals(final Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        final DefaultAuditLogsForInvoices that = (DefaultAuditLogsForInvoices) o;
+
+        if (invoiceAuditLogs != null ? !invoiceAuditLogs.equals(that.invoiceAuditLogs) : that.invoiceAuditLogs != null) {
+            return false;
+        }
+        if (invoiceItemsAuditLogs != null ? !invoiceItemsAuditLogs.equals(that.invoiceItemsAuditLogs) : that.invoiceItemsAuditLogs != null) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = invoiceAuditLogs != null ? invoiceAuditLogs.hashCode() : 0;
+        result = 31 * result + (invoiceItemsAuditLogs != null ? invoiceItemsAuditLogs.hashCode() : 0);
+        return result;
+    }
+}
diff --git a/util/src/main/java/com/ning/billing/util/audit/DefaultAuditLogsForPayments.java b/util/src/main/java/com/ning/billing/util/audit/DefaultAuditLogsForPayments.java
new file mode 100644
index 0000000..062813b
--- /dev/null
+++ b/util/src/main/java/com/ning/billing/util/audit/DefaultAuditLogsForPayments.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.util.audit;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+public class DefaultAuditLogsForPayments implements AuditLogsForPayments {
+
+    private final Map<UUID, List<AuditLog>> paymentsAuditLogs;
+
+    public DefaultAuditLogsForPayments(final Map<UUID, List<AuditLog>> paymentsAuditLogs) {
+        this.paymentsAuditLogs = paymentsAuditLogs;
+    }
+
+    @Override
+    public Map<UUID, List<AuditLog>> getPaymentsAuditLogs() {
+        return paymentsAuditLogs;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder();
+        sb.append("DefaultAuditLogsForPayments");
+        sb.append("{paymentsAuditLogs=").append(paymentsAuditLogs);
+        sb.append('}');
+        return sb.toString();
+    }
+
+    @Override
+    public boolean equals(final Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        final DefaultAuditLogsForPayments that = (DefaultAuditLogsForPayments) o;
+
+        if (paymentsAuditLogs != null ? !paymentsAuditLogs.equals(that.paymentsAuditLogs) : that.paymentsAuditLogs != null) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return paymentsAuditLogs != null ? paymentsAuditLogs.hashCode() : 0;
+    }
+}
diff --git a/util/src/main/java/com/ning/billing/util/audit/DefaultAuditLogsForRefunds.java b/util/src/main/java/com/ning/billing/util/audit/DefaultAuditLogsForRefunds.java
new file mode 100644
index 0000000..1cfd520
--- /dev/null
+++ b/util/src/main/java/com/ning/billing/util/audit/DefaultAuditLogsForRefunds.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.util.audit;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+public class DefaultAuditLogsForRefunds implements AuditLogsForRefunds {
+
+    private final Map<UUID, List<AuditLog>> refundsAuditLogs;
+
+    public DefaultAuditLogsForRefunds(final Map<UUID, List<AuditLog>> refundsAuditLogs) {
+        this.refundsAuditLogs = refundsAuditLogs;
+    }
+
+    @Override
+    public Map<UUID, List<AuditLog>> getRefundsAuditLogs() {
+        return refundsAuditLogs;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder();
+        sb.append("DefaultAuditLogsForRefunds");
+        sb.append("{refundsAuditLogs=").append(refundsAuditLogs);
+        sb.append('}');
+        return sb.toString();
+    }
+
+    @Override
+    public boolean equals(final Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        final DefaultAuditLogsForRefunds that = (DefaultAuditLogsForRefunds) o;
+
+        if (refundsAuditLogs != null ? !refundsAuditLogs.equals(that.refundsAuditLogs) : that.refundsAuditLogs != null) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return refundsAuditLogs != null ? refundsAuditLogs.hashCode() : 0;
+    }
+}
diff --git a/util/src/test/java/com/ning/billing/util/audit/AuditLogsTestBase.java b/util/src/test/java/com/ning/billing/util/audit/AuditLogsTestBase.java
new file mode 100644
index 0000000..6a54943
--- /dev/null
+++ b/util/src/test/java/com/ning/billing/util/audit/AuditLogsTestBase.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.util.audit;
+
+import java.util.List;
+import java.util.UUID;
+
+import org.mockito.Mockito;
+
+import com.ning.billing.util.ChangeType;
+import com.ning.billing.util.UtilTestSuite;
+import com.ning.billing.util.clock.Clock;
+import com.ning.billing.util.clock.ClockMock;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+public abstract class AuditLogsTestBase extends UtilTestSuite {
+
+    private final Clock clock = new ClockMock();
+
+    protected ImmutableMap<UUID, List<AuditLog>> createAuditLogsAssociation() {
+        final UUID id1 = UUID.randomUUID();
+        final UUID id2 = UUID.randomUUID();
+        final UUID id3 = UUID.randomUUID();
+        return ImmutableMap.<UUID, List<AuditLog>>of(id1, ImmutableList.<AuditLog>of(createAuditLog(), createAuditLog()),
+                                                     id2, ImmutableList.<AuditLog>of(createAuditLog(), createAuditLog()),
+                                                     id3, ImmutableList.<AuditLog>of(createAuditLog(), createAuditLog()));
+    }
+
+    protected AuditLog createAuditLog() {
+        final AuditLog auditLog = Mockito.mock(AuditLog.class);
+        Mockito.when(auditLog.getCreatedDate()).thenReturn(clock.getUTCNow());
+        Mockito.when(auditLog.getReasonCode()).thenReturn(UUID.randomUUID().toString());
+        Mockito.when(auditLog.getUserName()).thenReturn(UUID.randomUUID().toString());
+        Mockito.when(auditLog.getUserToken()).thenReturn(UUID.randomUUID().toString());
+        Mockito.when(auditLog.getComment()).thenReturn(UUID.randomUUID().toString());
+        Mockito.when(auditLog.getChangeType()).thenReturn(ChangeType.DELETE);
+
+        return auditLog;
+    }
+}
diff --git a/util/src/test/java/com/ning/billing/util/audit/TestDefaultAuditLogsForBundles.java b/util/src/test/java/com/ning/billing/util/audit/TestDefaultAuditLogsForBundles.java
new file mode 100644
index 0000000..5ba4a40
--- /dev/null
+++ b/util/src/test/java/com/ning/billing/util/audit/TestDefaultAuditLogsForBundles.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.util.audit;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class TestDefaultAuditLogsForBundles extends AuditLogsTestBase {
+
+    @Test(groups = "fast")
+    public void testEquals() throws Exception {
+        final Map<UUID, List<AuditLog>> bundlesAuditLogs = createAuditLogsAssociation();
+        Assert.assertEquals(new DefaultAuditLogsForBundles(bundlesAuditLogs).getBundlesAuditLogs(), bundlesAuditLogs);
+        Assert.assertNotEquals(new DefaultAuditLogsForBundles(createAuditLogsAssociation()).getBundlesAuditLogs(), bundlesAuditLogs);
+    }
+}
diff --git a/util/src/test/java/com/ning/billing/util/audit/TestDefaultAuditLogsForInvoicePayments.java b/util/src/test/java/com/ning/billing/util/audit/TestDefaultAuditLogsForInvoicePayments.java
new file mode 100644
index 0000000..2f0c6e4
--- /dev/null
+++ b/util/src/test/java/com/ning/billing/util/audit/TestDefaultAuditLogsForInvoicePayments.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.util.audit;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class TestDefaultAuditLogsForInvoicePayments extends AuditLogsTestBase {
+
+    @Test(groups = "fast")
+    public void testEquals() throws Exception {
+        final Map<UUID, List<AuditLog>> invoicePaymentsAuditLogs = createAuditLogsAssociation();
+        Assert.assertEquals(new DefaultAuditLogsForInvoicePayments(invoicePaymentsAuditLogs).getInvoicePaymentsAuditLogs(), invoicePaymentsAuditLogs);
+        Assert.assertNotEquals(new DefaultAuditLogsForInvoicePayments(createAuditLogsAssociation()).getInvoicePaymentsAuditLogs(), invoicePaymentsAuditLogs);
+    }
+}
diff --git a/util/src/test/java/com/ning/billing/util/audit/TestDefaultAuditLogsForInvoices.java b/util/src/test/java/com/ning/billing/util/audit/TestDefaultAuditLogsForInvoices.java
new file mode 100644
index 0000000..799c716
--- /dev/null
+++ b/util/src/test/java/com/ning/billing/util/audit/TestDefaultAuditLogsForInvoices.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.util.audit;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class TestDefaultAuditLogsForInvoices extends AuditLogsTestBase {
+
+    @Test(groups = "fast")
+    public void testEquals() throws Exception {
+        final Map<UUID, List<AuditLog>> invoicesAuditLogs = createAuditLogsAssociation();
+        final Map<UUID, List<AuditLog>> invoiceItemsAuditLogs = createAuditLogsAssociation();
+        Assert.assertEquals(new DefaultAuditLogsForInvoices(invoicesAuditLogs, invoiceItemsAuditLogs).getInvoiceAuditLogs(), invoicesAuditLogs);
+        Assert.assertEquals(new DefaultAuditLogsForInvoices(invoicesAuditLogs, invoiceItemsAuditLogs).getInvoiceItemsAuditLogs(), invoiceItemsAuditLogs);
+
+        Assert.assertNotEquals(new DefaultAuditLogsForInvoices(createAuditLogsAssociation(), invoiceItemsAuditLogs).getInvoiceAuditLogs(), invoicesAuditLogs);
+        Assert.assertEquals(new DefaultAuditLogsForInvoices(createAuditLogsAssociation(), invoiceItemsAuditLogs).getInvoiceItemsAuditLogs(), invoiceItemsAuditLogs);
+        Assert.assertEquals(new DefaultAuditLogsForInvoices(invoicesAuditLogs, createAuditLogsAssociation()).getInvoiceAuditLogs(), invoicesAuditLogs);
+        Assert.assertNotEquals(new DefaultAuditLogsForInvoices(invoicesAuditLogs, createAuditLogsAssociation()).getInvoiceItemsAuditLogs(), invoiceItemsAuditLogs);
+        Assert.assertNotEquals(new DefaultAuditLogsForInvoices(createAuditLogsAssociation(), createAuditLogsAssociation()).getInvoiceAuditLogs(), invoicesAuditLogs);
+        Assert.assertNotEquals(new DefaultAuditLogsForInvoices(createAuditLogsAssociation(), createAuditLogsAssociation()).getInvoiceItemsAuditLogs(), invoiceItemsAuditLogs);
+    }
+}
diff --git a/util/src/test/java/com/ning/billing/util/audit/TestDefaultAuditLogsForPayments.java b/util/src/test/java/com/ning/billing/util/audit/TestDefaultAuditLogsForPayments.java
new file mode 100644
index 0000000..d6074f1
--- /dev/null
+++ b/util/src/test/java/com/ning/billing/util/audit/TestDefaultAuditLogsForPayments.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.util.audit;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class TestDefaultAuditLogsForPayments extends AuditLogsTestBase {
+
+    @Test(groups = "fast")
+    public void testEquals() throws Exception {
+        final Map<UUID, List<AuditLog>> paymentsAuditLogs = createAuditLogsAssociation();
+        Assert.assertEquals(new DefaultAuditLogsForPayments(paymentsAuditLogs).getPaymentsAuditLogs(), paymentsAuditLogs);
+        Assert.assertNotEquals(new DefaultAuditLogsForPayments(createAuditLogsAssociation()).getPaymentsAuditLogs(), paymentsAuditLogs);
+    }
+}
diff --git a/util/src/test/java/com/ning/billing/util/audit/TestDefaultAuditLogsForRefunds.java b/util/src/test/java/com/ning/billing/util/audit/TestDefaultAuditLogsForRefunds.java
new file mode 100644
index 0000000..802ae4c
--- /dev/null
+++ b/util/src/test/java/com/ning/billing/util/audit/TestDefaultAuditLogsForRefunds.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2010-2012 Ning, Inc.
+ *
+ * Ning licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.util.audit;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class TestDefaultAuditLogsForRefunds extends AuditLogsTestBase {
+
+    @Test(groups = "fast")
+    public void testEquals() throws Exception {
+        final Map<UUID, List<AuditLog>> refundsAuditLogs = createAuditLogsAssociation();
+        Assert.assertEquals(new DefaultAuditLogsForRefunds(refundsAuditLogs).getRefundsAuditLogs(), refundsAuditLogs);
+        Assert.assertNotEquals(new DefaultAuditLogsForRefunds(createAuditLogsAssociation()).getRefundsAuditLogs(), refundsAuditLogs);
+    }
+}