/
Pojo6MatcherTest.java
84 lines (80 loc) · 4.23 KB
/
Pojo6MatcherTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* Powerunit - A JDK1.8 test framework
* Copyright (C) 2014 Mathieu Boretti.
*
* This file is part of Powerunit
*
* Powerunit is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Powerunit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Powerunit. If not, see <http://www.gnu.org/licenses/>.
*/
package ch.powerunit.extensions.matchers.multi.children;
import ch.powerunit.TestDelegate;
import ch.powerunit.TestSuite;
import ch.powerunit.extensions.matchers.multi.parent.Pojo1;
import ch.powerunit.matchers.MatcherTester;
import static ch.powerunit.matchers.MatcherTester.matcher;
import static ch.powerunit.matchers.MatcherTester.value;
public class Pojo6MatcherTest implements TestSuite {
//@formatter:off
@TestDelegate
public final MatcherTester<?> tester = testerOfMatcher(Pojo6Matchers.Pojo6MatcherImpl.class)
.with(
matcher((Pojo6Matchers.Pojo6MatcherImpl) Pojo6Matchers.pojo6With().field1With().msg1("x").end())
.describedAs("an instance of ch.powerunit.extensions.matchers.multi.children.Pojo6 with\n[field1 an instance of ch.powerunit.extensions.matchers.multi.parent.Pojo1 with\n[msg1 is \"x\"]\n]\n")
.nullRejected("was null")
.accepting(
new Pojo6(new Pojo1("x")))
.rejecting(
value("").withMessage("was \"\""),
value(new Pojo6()).withMessage("[field1 was null]\n"),
value(new Pojo6(new Pojo1())).withMessage("[field1 [msg1 was null]\n]\n"),
value(new Pojo6(new Pojo1("y"))).withMessage("[field1 [msg1 was \"y\"]\n]\n")),
matcher((Pojo6Matchers.Pojo6MatcherImpl) Pojo6Matchers.pojo6WithSameValue(new Pojo6()))
.describedAs("an instance of ch.powerunit.extensions.matchers.multi.children.Pojo6 with\n[field1 null]\n")
.nullRejected("was null")
.accepting(
new Pojo6())
.rejecting(
value("").withMessage("was \"\""),
value(new Pojo6(new Pojo1())).withMessage("[field1 was <Pojo1 [msg1=null]>]\n"),
value(new Pojo6(new Pojo1("x"))).withMessage("[field1 was <Pojo1 [msg1=x]>]\n")),
matcher((Pojo6Matchers.Pojo6MatcherImpl) Pojo6Matchers.pojo6WithSameValue(new Pojo6(new Pojo1())))
.describedAs("an instance of ch.powerunit.extensions.matchers.multi.children.Pojo6 with\n[field1 an instance of ch.powerunit.extensions.matchers.multi.parent.Pojo1 with\n[msg1 is null]\n]\n")
.nullRejected("was null")
.accepting(
new Pojo6(new Pojo1()))
.rejecting(
value("").withMessage("was \"\""),
value(new Pojo6()).withMessage("[field1 was null]\n"),
value(new Pojo6(new Pojo1("x"))).withMessage("[field1 [msg1 was \"x\"]\n]\n")),
matcher((Pojo6Matchers.Pojo6MatcherImpl) Pojo6Matchers.pojo6WithSameValue(new Pojo6(new Pojo1("a"))))
.describedAs("an instance of ch.powerunit.extensions.matchers.multi.children.Pojo6 with\n[field1 an instance of ch.powerunit.extensions.matchers.multi.parent.Pojo1 with\n[msg1 is \"a\"]\n]\n")
.nullRejected("was null")
.accepting(
new Pojo6(new Pojo1("a")))
.rejecting(
value("").withMessage("was \"\""),
value(new Pojo6()).withMessage("[field1 was null]\n"),
value(new Pojo6(new Pojo1())).withMessage("[field1 [msg1 was null]\n]\n"),
value(new Pojo6(new Pojo1("t"))).withMessage("[field1 [msg1 was \"t\"]\n]\n")),
matcher((Pojo6Matchers.Pojo6MatcherImpl) Pojo6Matchers.pojo6WithSameValue(new Pojo6(new Pojo1("a")),"field1.msg1"))
.describedAs("an instance of ch.powerunit.extensions.matchers.multi.children.Pojo6 with\n[field1 an instance of ch.powerunit.extensions.matchers.multi.parent.Pojo1 with\n[msg1 ANYTHING]\n]\n")
.nullRejected("was null")
.accepting(
new Pojo6(new Pojo1("a")),
new Pojo6(new Pojo1("b")))
.rejecting(
value("").withMessage("was \"\""),
value(new Pojo6()).withMessage("[field1 was null]\n")));
//@formatter:on
}