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