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