1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.slc.core.execution.tasks;
17
18 import org.argeo.slc.SlcException;
19 import org.argeo.slc.core.test.context.SimpleContextAware;
20 import org.argeo.slc.test.context.ContextAware;
21
22
23
24
25
26
27
28 public class OverrideContextAware implements Runnable {
29
30 private ContextAware source;
31
32 private SimpleContextAware target;
33
34
35
36
37
38
39 private Boolean failIfUndefinedInSource = true;
40
41 public void run() {
42
43 if(source.getValues() != null)
44 for(String key : source.getValues().keySet()) {
45 if(failIfUndefinedInSource && !target.getValues().containsKey(key)) {
46 throw new SlcException("No entry in target values for key '" + key + "'");
47 }
48 target.getValues().put(key, source.getValues().get(key));
49 }
50
51
52 if(source.getExpectedValues() != null)
53 for(String key : source.getExpectedValues().keySet()) {
54 if(failIfUndefinedInSource && !target.getExpectedValues().containsKey(key)) {
55 throw new SlcException("No entry in target expected values for key '" + key + "'");
56 }
57 target.getExpectedValues().put(key, source.getExpectedValues().get(key));
58 }
59 }
60
61 public void setSource(ContextAware source) {
62 this.source = source;
63 }
64
65 public void setTarget(SimpleContextAware target) {
66 this.target = target;
67 }
68
69 public void setFailIfUndefinedInSource(Boolean failIfUndefinedInSource) {
70 this.failIfUndefinedInSource = failIfUndefinedInSource;
71 }
72 }