1 package org
.argeo
.slc
.core
.execution
.tasks
;
3 import org
.argeo
.slc
.SlcException
;
4 import org
.argeo
.slc
.core
.test
.context
.SimpleContextAware
;
5 import org
.argeo
.slc
.test
.context
.ContextAware
;
8 * Overrides Values and Expected values of a target
9 * <code>SimpleContextAware</code> with the corresponding
10 * values and expected values of a source <code>ContextAware</code>
13 public class OverrideContextAware
implements Runnable
{
15 private ContextAware source
;
17 private SimpleContextAware target
;
20 * Whether an exception shall be thrown if a value
21 * or expected value of the source is not defined
24 private Boolean failIfUndefinedInSource
= true;
28 if(source
.getValues() != null)
29 for(String key
: source
.getValues().keySet()) {
30 if(failIfUndefinedInSource
&& !target
.getValues().containsKey(key
)) {
31 throw new SlcException("No entry in target values for key '" + key
+ "'");
33 target
.getValues().put(key
, source
.getValues().get(key
));
36 // override expected values
37 if(source
.getExpectedValues() != null)
38 for(String key
: source
.getExpectedValues().keySet()) {
39 if(failIfUndefinedInSource
&& !target
.getExpectedValues().containsKey(key
)) {
40 throw new SlcException("No entry in target expected values for key '" + key
+ "'");
42 target
.getExpectedValues().put(key
, source
.getExpectedValues().get(key
));
46 public void setSource(ContextAware source
) {
50 public void setTarget(SimpleContextAware target
) {
54 public void setFailIfUndefinedInSource(Boolean failIfUndefinedInSource
) {
55 this.failIfUndefinedInSource
= failIfUndefinedInSource
;