1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.enforcer;
20
21 import org.apache.maven.enforcer.rule.api.EnforcerRule;
22 import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
23 import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
24
25
26
27
28 public class MockEnforcerRule implements EnforcerRule {
29
30 public boolean failRule = false;
31
32 public String cacheId = "";
33
34 public boolean isCacheable = false;
35
36 public boolean isResultValid = false;
37
38 public boolean executed = false;
39
40 public MockEnforcerRule(boolean fail) {
41 this.failRule = fail;
42 }
43
44 public MockEnforcerRule(boolean fail, String cacheId, boolean isCacheable, boolean isResultValid) {
45 this.failRule = fail;
46 this.isCacheable = isCacheable;
47 this.isResultValid = isResultValid;
48 this.cacheId = cacheId;
49 }
50
51 public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException {
52 executed = true;
53 if (isFailRule()) {
54 throw new EnforcerRuleException(" this condition is not allowed.");
55 }
56 }
57
58
59
60
61 public boolean isFailRule() {
62 return this.failRule;
63 }
64
65
66
67
68 public void setFailRule(boolean theFailRule) {
69 this.failRule = theFailRule;
70 }
71
72
73
74
75 public boolean isResultValid() {
76 return this.isResultValid;
77 }
78
79
80
81
82 public void setResultValid(boolean theIsResultValid) {
83 this.isResultValid = theIsResultValid;
84 }
85
86
87
88
89 public void setCacheId(String theCacheId) {
90 this.cacheId = theCacheId;
91 }
92
93
94
95
96 public void setCacheable(boolean theIsCacheable) {
97 this.isCacheable = theIsCacheable;
98 }
99
100
101
102
103
104 public String getCacheId() {
105 return cacheId;
106 }
107
108
109
110
111
112 public boolean isCacheable() {
113 return isCacheable;
114 }
115
116
117
118
119
120
121 public boolean isResultValid(EnforcerRule theCachedRule) {
122 return isResultValid;
123 }
124 }