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 file equals assertions.
|
---|
10 | * </p>
|
---|
11 | *
|
---|
12 | * @author Jeffrey Hall, Steffen Herbold
|
---|
13 | * @version 2.0
|
---|
14 | */
|
---|
15 | public class FileEqualsReplay implements IReplayable {
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * <p>
|
---|
19 | * The file that should be equal to expectedFile.
|
---|
20 | * </p>
|
---|
21 | */
|
---|
22 | protected final String actualFile;
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * <p>
|
---|
26 | * The file that is used as the reference.
|
---|
27 | * </p>
|
---|
28 | */
|
---|
29 | protected final String expectedFile;
|
---|
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 FileEqualsReplay.
|
---|
41 | * </p>
|
---|
42 | *
|
---|
43 | * @param expectedFile
|
---|
44 | * name and path of the expected file
|
---|
45 | * @param actualFile
|
---|
46 | * name and path of the actual file
|
---|
47 | * @throws IllegalArgumentException
|
---|
48 | * thrown if expectedFile or actualFile are null
|
---|
49 | */
|
---|
50 | public FileEqualsReplay(String expectedFile, String actualFile) {
|
---|
51 | if (expectedFile == null) {
|
---|
52 | throw new IllegalArgumentException("expected file must not be null");
|
---|
53 | }
|
---|
54 | if (actualFile == null) {
|
---|
55 | throw new IllegalArgumentException("actual file must not be null");
|
---|
56 | }
|
---|
57 | this.expectedFile = expectedFile;
|
---|
58 | this.actualFile = actualFile;
|
---|
59 | }
|
---|
60 |
|
---|
61 | /*
|
---|
62 | * (non-Javadoc)
|
---|
63 | *
|
---|
64 | * @see de.ugoe.cs.quest.eventcore.IReplayable#getReplay()
|
---|
65 | */
|
---|
66 | public String getReplay() {
|
---|
67 |
|
---|
68 | String actualFileTmp = StringTools.xmlEntityReplacement(actualFile);
|
---|
69 | String expectedFileTmp = StringTools.xmlEntityReplacement(expectedFile);
|
---|
70 |
|
---|
71 | StringBuilder currentMsgStr = new StringBuilder(800);
|
---|
72 | currentMsgStr.append(" <fileEquals ");
|
---|
73 | currentMsgStr.append("actualFile=\"" + actualFileTmp + "\" ");
|
---|
74 | currentMsgStr.append("expectedFile=\"" + expectedFileTmp + "\"/>");
|
---|
75 | currentMsgStr.append(StringTools.ENDLINE);
|
---|
76 | return currentMsgStr.toString();
|
---|
77 | }
|
---|
78 |
|
---|
79 | /*
|
---|
80 | * (non-Javadoc)
|
---|
81 | *
|
---|
82 | * @see de.ugoe.cs.quest.eventcore.IReplayable#getDecorator()
|
---|
83 | */
|
---|
84 | @Override
|
---|
85 | public IReplayDecorator getDecorator() {
|
---|
86 | return null;
|
---|
87 | }
|
---|
88 |
|
---|
89 | }
|
---|