1 | package de.ugoe.cs.quest.assertions;
|
---|
2 |
|
---|
3 | import de.ugoe.cs.quest.IReplayDecorator;
|
---|
4 | import de.ugoe.cs.quest.eventcore.IReplayable;
|
---|
5 | import de.ugoe.cs.util.StringTools;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * <p>
|
---|
9 | * This class defines the replay for a textEquals assertion.
|
---|
10 | * </p>
|
---|
11 | *
|
---|
12 | * @author Jeffrey Hall, Steffen Herbold
|
---|
13 | * @version 2.0
|
---|
14 | */
|
---|
15 | public class TextEqualsReplay implements IReplayable {
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * <p>
|
---|
19 | * Reference value which is compared to the targets text.
|
---|
20 | * </p>
|
---|
21 | */
|
---|
22 | protected final String expectedValue;
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * <p>
|
---|
26 | * Target to which the text is compared.
|
---|
27 | * </p>
|
---|
28 | */
|
---|
29 | protected final String target;
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * <p>
|
---|
33 | * Id for object serialization.
|
---|
34 | * </p>
|
---|
35 | */
|
---|
36 | private static final long serialVersionUID = 1L;
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * <p>
|
---|
40 | * Constructor. Creates a new TextEqualsReplay.
|
---|
41 | *
|
---|
42 | * @param expectedValue
|
---|
43 | * expected string value
|
---|
44 | * @param target
|
---|
45 | * string description of the target whose string value is compared to the expected
|
---|
46 | * value
|
---|
47 | * @throws IllegalArgumentException
|
---|
48 | * thrown if target is null
|
---|
49 | */
|
---|
50 | public TextEqualsReplay(String expectedValue, String target) {
|
---|
51 | if (target == null) {
|
---|
52 | throw new IllegalArgumentException("target must not be null");
|
---|
53 | }
|
---|
54 | this.expectedValue = expectedValue;
|
---|
55 | this.target = target;
|
---|
56 | }
|
---|
57 |
|
---|
58 | /*
|
---|
59 | * (non-Javadoc)
|
---|
60 | *
|
---|
61 | * @see de.ugoe.cs.quest.eventcore.IReplayable#getReplay()
|
---|
62 | */
|
---|
63 | @Override
|
---|
64 | public String getReplay() {
|
---|
65 |
|
---|
66 | String expectedValueTmp = StringTools.xmlEntityReplacement(expectedValue);
|
---|
67 |
|
---|
68 | StringBuilder currentMsgStr = new StringBuilder(400);
|
---|
69 | currentMsgStr.append(" <textEquals expectedValue=\"" + expectedValueTmp + "\">");
|
---|
70 | currentMsgStr.append(StringTools.ENDLINE);
|
---|
71 | currentMsgStr.append("<target>");
|
---|
72 | currentMsgStr.append(StringTools.ENDLINE);
|
---|
73 | currentMsgStr.append(target);
|
---|
74 | currentMsgStr.append(StringTools.ENDLINE);
|
---|
75 | currentMsgStr.append("</target>");
|
---|
76 | currentMsgStr.append(StringTools.ENDLINE);
|
---|
77 | currentMsgStr.append("</textEquals>");
|
---|
78 | currentMsgStr.append(StringTools.ENDLINE);
|
---|
79 | return currentMsgStr.toString();
|
---|
80 | }
|
---|
81 |
|
---|
82 | /*
|
---|
83 | * (non-Javadoc)
|
---|
84 | *
|
---|
85 | * @see de.ugoe.cs.quest.eventcore.IReplayable#getTarget()
|
---|
86 | */
|
---|
87 | // @Override TODO
|
---|
88 | public String getTarget() {
|
---|
89 | return target;
|
---|
90 | }
|
---|
91 |
|
---|
92 | /*
|
---|
93 | * (non-Javadoc)
|
---|
94 | *
|
---|
95 | * @see de.ugoe.cs.quest.eventcore.IReplayable#getDecorator()
|
---|
96 | */
|
---|
97 | @Override
|
---|
98 | public IReplayDecorator getDecorator() {
|
---|
99 | return null;
|
---|
100 | }
|
---|
101 |
|
---|
102 | }
|
---|