Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0124c12

Browse files
committed
Tooks some Java code and made it Groovy, baby
1 parent ec4b73b commit 0124c12

File tree

4 files changed

+134
-250
lines changed

4 files changed

+134
-250
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright 2014 Daniel Bechler
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License")
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package de.danielbechler.diff.integration
18+
19+
import de.danielbechler.diff.ObjectDifferBuilder
20+
import de.danielbechler.diff.mock.ObjectWithCircularReference
21+
import de.danielbechler.diff.node.DiffNode
22+
import de.danielbechler.diff.path.NodePath
23+
import spock.lang.Specification
24+
25+
/**
26+
* @author Daniel Bechler
27+
*/
28+
public class IgnoreIT extends Specification {
29+
30+
def 'verify that ignore rules with complex paths works properly'() {
31+
given:
32+
def obj1 = new ObjectWithCircularReference("1")
33+
def obj2 = new ObjectWithCircularReference("2")
34+
def obj3 = new ObjectWithCircularReference("3")
35+
obj1.reference = obj2
36+
obj2.reference = obj3
37+
and:
38+
def modifiedObj1 = new ObjectWithCircularReference("1")
39+
def modifiedObj2 = new ObjectWithCircularReference("2")
40+
def modifiedObj3 = new ObjectWithCircularReference("4")
41+
modifiedObj1.reference = modifiedObj2
42+
modifiedObj2.reference = modifiedObj3
43+
and:
44+
def nodePath = NodePath.with("reference", "reference")
45+
when:
46+
def objectDiffer1 = ObjectDifferBuilder.startBuilding().build()
47+
def verification = objectDiffer1.compare(obj1, modifiedObj1)
48+
then: "verify that the node can be found when it's not excluded"
49+
verification.getChild(nodePath).state == DiffNode.State.CHANGED
50+
verification.getChild(nodePath).childCount() == 1
51+
when:
52+
def objectDiffer2 = ObjectDifferBuilder.startBuilding().inclusion().exclude().node(nodePath).and().build()
53+
def node = objectDiffer2.compare(obj1, modifiedObj1)
54+
then: "verify that the node can't be found, when it's excluded"
55+
node.getChild(nodePath) == null
56+
}
57+
}

‎src/integration-test/java/de/danielbechler/diff/integration/IgnoreIT.java‎

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright 2014 Daniel Bechler
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the 'License');
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an 'AS IS' BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package de.danielbechler.diff.issues.issue43
18+
19+
import de.danielbechler.diff.ObjectDifferBuilder
20+
import de.danielbechler.diff.path.NodePath
21+
import groovy.transform.EqualsAndHashCode
22+
import spock.lang.Issue
23+
import spock.lang.Specification
24+
25+
@Issue('https://github.com/SQiShER/java-object-diff/issues/43')
26+
public class Issue43IT extends Specification {
27+
28+
def objectDifferBuilder = ObjectDifferBuilder.startBuilding()
29+
30+
def 'should diff things'() {
31+
given:
32+
// @formatter:off
33+
['things', 'include'].collect({ property -> NodePath.with property }).each {
34+
objectDifferBuilder
35+
.comparison()
36+
.ofNode(it).toUseEqualsMethod()
37+
.and()
38+
.inclusion()
39+
.include().node(it)
40+
}
41+
// @formatter:on
42+
and:
43+
def thingOne = new Thing('a', 'b')
44+
def thingTwo = new Thing('aa', 'bb')
45+
and:
46+
def first = new ThingHolder([thingOne] as Set, 'ignore', 'include')
47+
def second = new ThingHolder([thingTwo] as Set, 'ignore this change', 'include')
48+
when:
49+
def node = objectDifferBuilder.build().compare(first, second)
50+
then:
51+
node.changed
52+
}
53+
54+
@EqualsAndHashCode
55+
private static class Thing {
56+
final String a
57+
final String b
58+
59+
Thing(String a, String b) {
60+
this.a = a
61+
this.b = b
62+
}
63+
}
64+
65+
@EqualsAndHashCode
66+
private static class ThingHolder {
67+
final Set<Thing> things
68+
final String ignore
69+
final String include
70+
71+
ThingHolder(Set<Thing> things, String ignore, String include) {
72+
this.things = things
73+
this.ignore = ignore
74+
this.include = include
75+
}
76+
}
77+
}

‎src/integration-test/java/de/danielbechler/diff/issues/issue43/Issue43IT.java‎

Lines changed: 0 additions & 185 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /