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