|
1 |
| -package com.yanimetaxas.realitycheck.asserter; |
| 1 | +package com.yanimetaxas.realitycheck; |
2 | 2 |
|
3 |
| -import com.yanimetaxas.realitycheck.strategy.validation.FileValidationStrategy; |
4 |
| -import com.yanimetaxas.realitycheck.strategy.validation.FilepathValidationStrategy; |
5 |
| -import com.yanimetaxas.realitycheck.strategy.validation.ValidationStrategy; |
| 3 | +import com.yanimetaxas.realitycheck.strategy.FileValidationStrategy; |
| 4 | +import com.yanimetaxas.realitycheck.strategy.FilepathValidationStrategy; |
| 5 | +import com.yanimetaxas.realitycheck.strategy.ValidationStrategy; |
6 | 6 | import com.yanimetaxas.realitycheck.util.IoUtil;
|
7 | 7 | import java.io.ByteArrayInputStream;
|
8 | 8 | import java.io.File;
|
9 | 9 |
|
10 | 10 | /**
|
11 | 11 | * @author yanimetaxas
|
12 | 12 | */
|
13 |
| -public class FileAssert extends AbstractReadableAssert<FileAssert, File, FileValidationStrategy> { |
| 13 | +public class FileCheck extends AbstractReadableCheck<FileCheck, File, FileValidationStrategy> { |
14 | 14 |
|
15 |
| - |
16 |
| - public FileAssert(String filepath, String message) throws AssertionError { |
| 15 | + FileCheck(String filepath, String message) throws AssertionError { |
17 | 16 | super(IoUtil.toFile(filepath), message, new FilepathValidationStrategy(filepath));
|
18 | 17 | }
|
19 | 18 |
|
20 |
| - public FileAssert(File file, String message) throws AssertionError { |
| 19 | + FileCheck(File file, String message) throws AssertionError { |
21 | 20 | super(file, message);
|
22 | 21 | }
|
23 | 22 |
|
24 |
| - public FileAssert(File file, String message, ValidationStrategy strategy) throws AssertionError { |
| 23 | + FileCheck(File file, String message, ValidationStrategy strategy) throws AssertionError { |
25 | 24 | super(file, message, strategy);
|
26 | 25 | }
|
27 | 26 |
|
28 |
| - public FileAssert exists() { |
| 27 | + public FileCheck exists() { |
29 | 28 | if (!getActual().exists()) {
|
30 | 29 | throw new AssertionError("File " + actual.getName() + " doesn't exist");
|
31 | 30 | }
|
32 | 31 | return self;
|
33 | 32 | }
|
34 | 33 |
|
35 |
| - public FileAssert doesNotExist() { |
| 34 | + public FileCheck doesNotExist() { |
36 | 35 | if (getActual().exists()) {
|
37 | 36 | throw new AssertionError("File " + actual.getName() + " exists");
|
38 | 37 | }
|
39 | 38 | return self;
|
40 | 39 | }
|
41 | 40 |
|
42 |
| - public FileAssert isDirectory() { |
| 41 | + public FileCheck isDirectory() { |
43 | 42 | if (!getActual().isDirectory()) {
|
44 | 43 | throw new AssertionError("File " + actual.getName() + " is NOT directory");
|
45 | 44 | }
|
46 | 45 | return self;
|
47 | 46 | }
|
48 | 47 |
|
49 |
| - public FileAssert isNotDirectory() { |
| 48 | + public FileCheck isNotDirectory() { |
50 | 49 | if (getActual().isDirectory()) {
|
51 | 50 | throw new AssertionError("File " + actual.getName() + " is directory");
|
52 | 51 | }
|
53 | 52 | return self;
|
54 | 53 | }
|
55 | 54 |
|
56 |
| - public FileAssert isHidden() { |
| 55 | + public FileCheck isHidden() { |
57 | 56 | if (!getActual().isHidden()) {
|
58 | 57 | throw new AssertionError("File " + actual.getName() + " is NOT hidden");
|
59 | 58 | }
|
60 | 59 | return self;
|
61 | 60 | }
|
62 | 61 |
|
63 |
| - public FileAssert isNotHidden() { |
| 62 | + public FileCheck isNotHidden() { |
64 | 63 | if (getActual().isHidden()) {
|
65 | 64 | throw new AssertionError("File " + actual.getName() + " is hidden");
|
66 | 65 | }
|
67 | 66 | return self;
|
68 | 67 | }
|
69 | 68 |
|
70 |
| - public FileAssert hasSameContentAs(String filepath) throws AssertionError { |
| 69 | + public FileCheck hasSameContentAs(String filepath) throws AssertionError { |
71 | 70 | return hasSameContentAs(IoUtil.toFile(filepath));
|
72 | 71 | }
|
73 | 72 |
|
74 |
| - public FileAssert hasSameContentAs(File file) throws AssertionError { |
75 |
| - return (FileAssert) super |
| 73 | + public FileCheck hasSameContentAs(File file) throws AssertionError { |
| 74 | + return (FileCheck) super |
76 | 75 | .hasSameContentAs(new ByteArrayInputStream(IoUtil.readFile(file.getAbsolutePath())));
|
77 | 76 | }
|
78 | 77 |
|
79 |
| - public FileAssert hasNotSameContentAs(File file) throws AssertionError { |
80 |
| - return (FileAssert) super |
| 78 | + public FileCheck hasNotSameContentAs(File file) throws AssertionError { |
| 79 | + return (FileCheck) super |
81 | 80 | .hasNotSameContentAs(new ByteArrayInputStream(IoUtil.readFile(file.getAbsolutePath())));
|
82 | 81 | }
|
83 | 82 |
|
84 |
| - public FileAssert hasNotSameContentAs(String filepath) throws AssertionError { |
| 83 | + public FileCheck hasNotSameContentAs(String filepath) throws AssertionError { |
85 | 84 | return hasNotSameContentAs(IoUtil.toFile(filepath));
|
86 | 85 | }
|
87 | 86 | }
|
0 commit comments