Tests for GORA-421, fixing setDirty()

Project: http://git-wip-us.apache.org/repos/asf/gora/repo
Commit: http://git-wip-us.apache.org/repos/asf/gora/commit/e66d8cd8
Tree: http://git-wip-us.apache.org/repos/asf/gora/tree/e66d8cd8
Diff: http://git-wip-us.apache.org/repos/asf/gora/diff/e66d8cd8

Branch: refs/heads/master
Commit: e66d8cd80c0fd29925050aec9ff96095617dd076
Parents: 546a1c7
Author: Alfonso Nishikawa Muñumer <alfonso.nishik...@gmail.com>
Authored: Thu Jan 11 08:40:20 2018 -0100
Committer: Alfonso Nishikawa Muñumer <alfonso.nishik...@gmail.com>
Committed: Thu Jan 11 08:40:20 2018 -0100

----------------------------------------------------------------------
 .../gora/persistency/impl/TestPersistentBase.java   | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/gora/blob/e66d8cd8/gora-core/src/test/java/org/apache/gora/persistency/impl/TestPersistentBase.java
----------------------------------------------------------------------
diff --git 
a/gora-core/src/test/java/org/apache/gora/persistency/impl/TestPersistentBase.java
 
b/gora-core/src/test/java/org/apache/gora/persistency/impl/TestPersistentBase.java
index cae635b..1a9374e 100644
--- 
a/gora-core/src/test/java/org/apache/gora/persistency/impl/TestPersistentBase.java
+++ 
b/gora-core/src/test/java/org/apache/gora/persistency/impl/TestPersistentBase.java
@@ -153,4 +153,20 @@ public class TestPersistentBase {
     
     assertEquals(employee, Employee.newBuilder(employee).build());
   }
+  
+  /**
+   * Test that #setDirty() sets all the shallow fields dirty.
+   * GORA-421
+   */
+  @Test
+  public void testSetDirty() {
+    WebPage page = WebPage.newBuilder().build();
+    assertEquals("Expected the new Persistent instance to not be dirty.", 
false, page.isDirty()) ;
+    page.setDirty();
+    
+    // Assert each field is dirty
+    for (Field field : page.getSchema().getFields()) {
+      assertEquals("The field " + field.name() + " is not dirty.", true, 
page.isDirty(field.name()));
+    }
+  }
 }

Reply via email to