UpdateOp { void equals(@NotNull String property, @Nullable Object value) { equals(property, null, value); } UpdateOp(@NotNull String id, boolean isNew);   UpdateOp(@NotNull String id,
             boolean isNew,
             boolean isDelete,
             @NotNull Map<Key, Operation> changes,
             @Nullable Map<Key, Condition> conditions); UpdateOp shallowCopy(String id); UpdateOp copy(); @NotNull String getId(); boolean isNew(); void setNew(boolean isNew); Map<Key, Operation> getChanges(); Map<Key, Condition> getConditions(); boolean hasChanges(); void remove(@NotNull String property); void removeMapEntry(@NotNull String property, @NotNull Revision revision); void set(String property, long value); void set(String property, boolean value); void set(String property, String value); void increment(@NotNull String property, long value); UpdateOp getReverseOperation(); @Override String toString();  }
@Test public void keyEquals() { Revision r1 = Revision.newRevision(1); Revision r2 = Revision.newRevision(1); UpdateOp.Key k1 = new UpdateOp.Key("foo", null); UpdateOp.Key k2 = new UpdateOp.Key("bar", null); assertFalse(k1.equals(k2)); assertFalse(k2.equals(k1)); UpdateOp.Key k3 = new UpdateOp.Key("foo", null); assertTrue(k1.equals(k3)); assertTrue(k3.equals(k1)); UpdateOp.Key k4 = new UpdateOp.Key("foo", r1); assertFalse(k4.equals(k3)); assertFalse(k3.equals(k4)); UpdateOp.Key k5 = new UpdateOp.Key("foo", r2); assertFalse(k5.equals(k4)); assertFalse(k4.equals(k5)); UpdateOp.Key k6 = new UpdateOp.Key("foo", r1); assertTrue(k6.equals(k4)); assertTrue(k4.equals(k6)); UpdateOp.Key k7 = new UpdateOp.Key("bar", r1); assertFalse(k7.equals(k6)); assertFalse(k6.equals(k7)); }
@Test public void equalsTest() { Revision r = Revision.newRevision(1); UpdateOp op = new UpdateOp("id", true); try { op.equals("p", r, "v"); fail("expected " + IllegalStateException.class.getName()); } catch (IllegalStateException e) { } op = new UpdateOp("id", false); op.equals("p", r, "v"); assertEquals(1, op.getConditions().size()); UpdateOp.Key key = op.getConditions().keySet().iterator().next(); assertEquals(r, key.getRevision()); assertEquals("p", key.getName()); UpdateOp.Condition c = op.getConditions().get(key); assertEquals(UpdateOp.Condition.Type.EQUALS, c.type); assertEquals("v", c.value); }