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