MappingRuleActions { public static MappingRuleAction createUpdateDefaultAction(String queue) { return new VariableUpdateAction(DEFAULT_QUEUE_VARIABLE, queue); } private  MappingRuleActions(); static MappingRuleAction createUpdateDefaultAction(String queue); static MappingRuleAction createPlaceToQueueAction(
      String queue, boolean allowCreate); static MappingRuleAction createPlaceToDefaultAction(); static MappingRuleAction createRejectAction(); static final String DEFAULT_QUEUE_VARIABLE; }
@Test public void testVariableUpdateAction() { VariableContext variables = new VariableContext(); variables.put("%default", "root.default"); variables.put("%immutable", "immutable"); variables.put("%empty", ""); variables.put("%null", null); variables.put("%sub", "xxx"); variables.setImmutables("%immutable"); MappingRuleAction updateDefaultManual = new MappingRuleActions.VariableUpdateAction("%default", "root.%sub"); MappingRuleAction updateDefaultHelper = MappingRuleActions.createUpdateDefaultAction("root.%sub%sub"); MappingRuleAction updateImmutable = new MappingRuleActions.VariableUpdateAction("%immutable", "changed"); MappingRuleAction updateEmpty = new MappingRuleActions.VariableUpdateAction("%empty", "something"); MappingRuleAction updateNull = new MappingRuleActions.VariableUpdateAction("%null", "non-null"); MappingRuleResult result; result = updateDefaultManual.execute(variables); assertSkipResult(result); assertEquals("root.xxx", variables.get("%default")); result = updateDefaultHelper.execute(variables); assertSkipResult(result); assertEquals("root.xxxxxx", variables.get("%default")); result = updateEmpty.execute(variables); assertSkipResult(result); assertEquals("something", variables.get("%empty")); result = updateNull.execute(variables); assertSkipResult(result); assertEquals("non-null", variables.get("%null")); try { updateImmutable.execute(variables); fail("Should've failed with exception"); } catch (Exception e){ assertTrue(e instanceof IllegalStateException); } }