@@ -21,12 +21,9 @@ import de.danielbechler.diff.collection.CollectionItemElement
2121import groovy.transform.EqualsAndHashCode
2222import groovy.transform.ToString
2323import spock.lang.Specification
24- import spock.lang.Stepwise
25-
2624/**
2725 * Created by dbechler.
2826 */
29- @Stepwise
3027class InclusionAndExclusionITCase extends Specification {
3128
3229 def builder = ObjectDifferBuilder . startBuilding()
@@ -131,17 +128,103 @@ class InclusionAndExclusionITCase extends Specification {
131128 node. getChild(' revision' ) == null
132129 }
133130
134- def " Inclusion via property name" () {
131+ def " including an element via property name" () {
135132 given :
136- configurable. inclusion(). toInclude(). propertyNames(' name' , ' contacts' )
133+ configurable. inclusion(). toInclude(). propertyNames(' name' )
134+
137135 when :
138136 def node = builder. build(). compare(working, base)
137+
139138 then :
140139 node. getChild(" name" ). changed
141- and :
142- def element = new CollectionItemElement (new Contact (id : " george" ))
143- node. getChild(" contacts" ). childCount() == 1
144- node. getChild(" contacts" ). getChild(element). getChild(" name" ). changed
140+ node. getChild(" contacts" ) == null
141+ }
142+
143+ def " including an element via property name includes all its children" () {
144+ given :
145+ configurable. inclusion(). toInclude(). propertyNames(' contacts' )
146+
147+ when :
148+ def node = builder. build(). compare(working, base)
149+
150+ then :
151+ node. getChild(' contacts' ). changed
152+ node. getChild(" contacts" ). childCount() == 2
153+ }
154+
155+ def " including an element via path includes all its children" () {
156+
157+ }
158+
159+ def " including an element via category" () {
160+ def includedCategory = " representation"
161+
162+ given : " the name property of the phonebook is part of our included category"
163+ configurable. categories(). ofNode(NodePath . buildWith(" name" )). toBe(includedCategory)
164+
165+ and : " the category is included"
166+ configurable. inclusion(). toInclude(). categories(includedCategory)
167+
168+ when :
169+ def node = builder. build(). compare(working, base)
170+
171+ then :
172+ node. getChild(' name' ). changed
173+ }
174+
175+ def " including an element implicitly includes its children" () {
176+ given :
177+ configurable. inclusion(). toInclude(). nodes(NodePath . buildWith(' contacts' ))
178+
179+ when :
180+ def node = builder. build(). compare(working, base)
181+
182+ then :
183+ node. getChild(' contacts' ). changed
184+ node. getChild(' contacts' ). childCount() == 2
185+ }
186+
187+ def " including an element only works if its parent element is also included" () {
188+ // configurable.inclusion().toInclude().propertyNames()
189+ // configurable.inclusion().node(NodePath.buildRootPath()).toInclude().propertyNames('foo', 'bar')
190+ // // NOTE NodePath Element => ElementSelector?
191+ // configurable.inclusion().type(Contact).toInclude().propertyNames('foo', 'bar')
192+ // configurable.inclusion().type(Contact).toInclude().propertyNames('foo', 'bar')
193+ }
194+
195+ def " children of included elements can be excluded" () {
196+
197+ }
198+
199+ def " elements can be excluded via wildcard" () {
200+
201+ }
202+
203+ def " elements can be excluded via exclude-all-but(x, y, ...) rule" () {
204+
205+ }
206+
207+ def " including an element via category only includes properties if any their parent elements is also somehow included" () {
208+ def includedCategory = " representation"
209+ def nodePathToKramer = NodePath . createBuilder()
210+ .withRoot()
211+ .withPropertyName(" contacts" )
212+ .withCollectionItem(new Contact (id : " kramer" ))
213+ .build()
214+
215+ given :
216+ configurable. categories(). ofNode(NodePath . buildWith(" name" )). toBe(includedCategory)
217+ // configurable.categories().ofNode(NodePath.buildWith("contacts")).toBe(includedCategory)
218+ configurable. categories(). ofNode(nodePathToKramer). toBe(includedCategory)
219+
220+ and : " the category is included"
221+ configurable. inclusion(). toInclude(). categories(includedCategory)
222+
223+ when :
224+ def node = builder. build(). compare(working, base)
225+
226+ then :
227+ node. getChild(' name' ). changed
145228 }
146229
147230 @EqualsAndHashCode
0 commit comments