-
Notifications
You must be signed in to change notification settings - Fork 2
/
Pojo4MatcherTest.java
97 lines (94 loc) · 5.15 KB
/
Pojo4MatcherTest.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
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* 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.Pojo1Matchers;
import ch.powerunit.matchers.MatcherTester;
import static ch.powerunit.matchers.MatcherTester.matcher;
import static ch.powerunit.matchers.MatcherTester.value;
public class Pojo4MatcherTest implements TestSuite {
//@formatter:off
@TestDelegate
public final MatcherTester<?> tester = testerOfMatcher(Pojo4Matchers.Pojo4MatcherImpl.class)
.with(
matcher((Pojo4Matchers.Pojo4MatcherImpl) Pojo4Matchers.pojo4With().msg2ContainsString("12"))
.describedAs("an instance of ch.powerunit.extensions.matchers.multi.children.Pojo4 with\n[parent ANYTHING]\n[msg2 a string containing \"12\"]\n")
.nullRejected("was null")
.accepting(
new Pojo4("12"),
new Pojo4("121"))
.rejecting(
value("").withMessage("was \"\""),
value(new Pojo4()).withMessage("[msg2 was null]\n"),
value(new Pojo4("11")).withMessage("[msg2 was \"11\"]\n")),
matcher((Pojo4Matchers.Pojo4MatcherImpl) Pojo4Matchers.pojo4With(Pojo1Matchers.pojo1With().msg1("x")).msg2ContainsString("12"))
.describedAs("an instance of ch.powerunit.extensions.matchers.multi.children.Pojo4 with\n[parent an instance of ch.powerunit.extensions.matchers.multi.parent.Pojo1 with\n[msg1 is \"x\"]\n]\n[msg2 a string containing \"12\"]\n")
.nullRejected("was null")
.accepting(
new Pojo4("x","12"),
new Pojo4("x","121"))
.rejecting(
value("").withMessage("was \"\""),
value(new Pojo4()).withMessage("[parent [msg1 was null]\n]\n[msg2 was null]\n"),
value(new Pojo4("11")).withMessage("[parent [msg1 was null]\n]\n[msg2 was \"11\"]\n"),
value(new Pojo4("z","11")).withMessage("[parent [msg1 was \"z\"]\n]\n[msg2 was \"11\"]\n")),
matcher((Pojo4Matchers.Pojo4MatcherImpl) Pojo4Matchers.pojo4WithSameValue(new Pojo4("x")))
.describedAs("an instance of ch.powerunit.extensions.matchers.multi.children.Pojo4 with\n[parent an instance of ch.powerunit.extensions.matchers.multi.parent.Pojo1 with\n[msg1 is null]\n]\n[msg2 is \"x\"]\n")
.nullRejected("was null")
.accepting(
new Pojo4("x"))
.rejecting(
value("").withMessage("was \"\""),
value(new Pojo4()).withMessage("[msg2 was null]\n"),
value(new Pojo4("11")).withMessage("[msg2 was \"11\"]\n")),
matcher((Pojo4Matchers.Pojo4MatcherImpl) Pojo4Matchers.pojo4WithSameValue(new Pojo4("y","x")))
.describedAs("an instance of ch.powerunit.extensions.matchers.multi.children.Pojo4 with\n[parent an instance of ch.powerunit.extensions.matchers.multi.parent.Pojo1 with\n[msg1 is \"y\"]\n]\n[msg2 is \"x\"]\n")
.nullRejected("was null")
.accepting(
new Pojo4("y","x"))
.rejecting(
value("").withMessage("was \"\""),
value(new Pojo4()).withMessage("[parent [msg1 was null]\n]\n[msg2 was null]\n"),
value(new Pojo4("11")).withMessage("[parent [msg1 was null]\n]\n[msg2 was \"11\"]\n"),
value(new Pojo4("z","x")).withMessage("[parent [msg1 was \"z\"]\n]\n")),
matcher((Pojo4Matchers.Pojo4MatcherImpl) Pojo4Matchers.pojo4WithSameValue(new Pojo4("y","x"),"msg2"))
.describedAs("an instance of ch.powerunit.extensions.matchers.multi.children.Pojo4 with\n[parent an instance of ch.powerunit.extensions.matchers.multi.parent.Pojo1 with\n[msg1 is \"y\"]\n]\n[msg2 ANYTHING]\n")
.nullRejected("was null")
.accepting(
new Pojo4("y","x"),
new Pojo4("y","x2"))
.rejecting(
value("").withMessage("was \"\""),
value(new Pojo4()).withMessage("[parent [msg1 was null]\n]\n"),
value(new Pojo4("11")).withMessage("[parent [msg1 was null]\n]\n"),
value(new Pojo4("z","x")).withMessage("[parent [msg1 was \"z\"]\n]\n")),
matcher((Pojo4Matchers.Pojo4MatcherImpl) Pojo4Matchers.pojo4WithSameValue(new Pojo4("y","x"),"msg1"))
.describedAs("an instance of ch.powerunit.extensions.matchers.multi.children.Pojo4 with\n[parent an instance of ch.powerunit.extensions.matchers.multi.parent.Pojo1 with\n[msg1 ANYTHING]\n]\n[msg2 is \"x\"]\n")
.nullRejected("was null")
.accepting(
new Pojo4("y","x"),
new Pojo4("y2","x"))
.rejecting(
value("").withMessage("was \"\""),
value(new Pojo4()).withMessage("[msg2 was null]\n"),
value(new Pojo4("11")).withMessage("[msg2 was \"11\"]\n")));
//@formatter:on
}