-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from scompo/master
Fixes #157
- Loading branch information
Showing
8 changed files
with
113 additions
and
6 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/integration-test/java/de/danielbechler/diff/categories/CategoriesTestIT.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package de.danielbechler.diff.categories | ||
|
||
import de.danielbechler.diff.ObjectDifferBuilder | ||
import de.danielbechler.diff.introspection.ObjectDiffProperty | ||
import de.danielbechler.diff.node.DiffNode | ||
import de.danielbechler.diff.node.Visit | ||
import de.danielbechler.diff.path.NodePath | ||
import spock.lang.Specification | ||
|
||
class CategoriesTestIT extends Specification{ | ||
|
||
def "should return all categories"(){ | ||
setup: | ||
def obj1 = new MyObject("aaa","aaa") | ||
def obj2 = new MyObject("bbb","bbb") | ||
def differ = ObjectDifferBuilder.startBuilding() | ||
.categories() | ||
.ofNode(NodePath.with("firstString")).toBe("cat1") | ||
.ofNode(NodePath.with("secondString")).toBe("cat1") | ||
.and() | ||
.build() | ||
def node = differ.compare(obj1,obj2) | ||
|
||
expect : | ||
node.getChild("firstString").getCategories() == ["cat1"] as Set | ||
node.getChild("secondString").getCategories() == ["cat1", "catAnnotation"] as Set | ||
} | ||
|
||
class MyObject{ | ||
|
||
def firstString | ||
def secondString | ||
|
||
MyObject(firstString,secondString) { | ||
|
||
this.firstString = firstString | ||
this.secondString = secondString | ||
} | ||
|
||
@ObjectDiffProperty(categories = ["catAnnotation"]) | ||
def getSecondString() { | ||
return secondString | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,4 +279,5 @@ public ObjectDifferBuilder and() | |
{ | ||
return rootConfiguration; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters