-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig.java
49 lines (41 loc) · 1.49 KB
/
Config.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package ch.ocram.demo.trywithresources;
import java.util.BitSet;
/**
* Represents one test scenario.
*/
// tag::Config[]
public class Config {
public static final int NUMBER_OF_CASES = 64;
public final boolean failOnGetResource;
public final boolean failOnClose;
public final boolean failOnBusinessLogic;
public final boolean failOnExceptionHandling;
public final boolean failOnFinally;
public final boolean returnInFinally;
// end::Config[]
private Config(boolean failOnGetResource, boolean failOnClose, boolean failOnBusinessLogic, boolean failOnExceptionHandling,
boolean failOnFinally, boolean returnInFinally) {
this.failOnGetResource = failOnGetResource;
this.failOnClose = failOnClose;
this.failOnBusinessLogic = failOnBusinessLogic;
this.failOnExceptionHandling = failOnExceptionHandling;
this.failOnFinally = failOnFinally;
this.returnInFinally = returnInFinally;
}
public static Config from(int value) {
BitSet bits = BitSet.valueOf(new long[] {value});
return new Config(bits.get(0), bits.get(1), bits.get(2), bits.get(3), bits.get(4), bits.get(5));
}
public static String flag(boolean flag) {
return flag ? "[x]" : "[_]";
}
public String toDisplayName() {
return
"gr=" + flag(failOnGetResource) +
" cl=" + flag(failOnClose) +
" bl=" + flag(failOnBusinessLogic) +
" eh=" + flag(failOnExceptionHandling) +
" fn=" + flag(failOnFinally) +
" rf=" + flag(returnInFinally);
}
}