public void testStep_SetAndUpdateStateVariablesWithNulls() throws Exception { JavaActor actor = new JavaActor(); actor.setName("MultiplyActor"); MultiplyBean bean = new MultiplyBean(); actor.setWrappedBean(bean); Yaml yaml = new Yaml(); actor.setInputs((Map<String, Object>) yaml.load("originalValue:" + EOL)); actor.setOutputs((Map<String, Object>) yaml.load("multipliedValue:" + EOL)); actor.setSettings((Map<String, Object>) yaml.load("factor: 3" + EOL)); actor.setState((Map<String, Object>) yaml.load("accumulator: 0" + EOL + "count: 0" + EOL)); actor.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); actor.initialize(); actor.setInputValue("originalValue", 4); assertEquals(0, bean.getAccumulator()); assertEquals((Integer) 0, bean.getCount()); MultiplyBean.setCountToNullInStep = true; actor.step(); assertEquals(12, actor.getOutputValue("multipliedValue")); assertNull(bean.getCount()); assertEquals(12, bean.getAccumulator()); actor.setInputValue("originalValue", 6); bean.setCount(17); actor.step(); assertEquals(18, actor.getOutputValue("multipliedValue")); assertNull(bean.getCount()); assertEquals(30, bean.getAccumulator()); }
public void testStep_Success() throws Exception { JavaActor actor = MultiplyBean.getConfiguredActor(); actor.initialize(); actor.setInputValue("originalValue", 1); actor.step(); assertEquals(2, actor.getOutputValue("multipliedValue")); }
public void testClone_UncloneableBean() throws Exception { JavaActor actor = new JavaActor(); actor.setName("MultiplyActor"); UncloneableMultiplyBean bean = new UncloneableMultiplyBean(); actor.setWrappedBean(bean); Yaml yaml = new Yaml(); actor.setInputs((Map<String, Object>) yaml.load("originalValue:" + EOL)); actor.setOutputs((Map<String, Object>) yaml.load("multipliedValue:" + EOL)); actor.setSettings((Map<String, Object>) yaml.load("factor: 4" + EOL)); actor.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); actor.initialize(); JavaActor clone = (JavaActor) actor.clone(); assertNotSame(bean, clone.getWrappedBean()); clone.setInputValue("originalValue", 5); clone.step(); assertEquals(20, clone.getOutputValue("multipliedValue")); }
public void testInitialize_setSettings() throws Exception { JavaActor actor = new JavaActor(); actor.setName("MultiplyActor"); actor.setWrappedBean(new MultiplyBean()); Yaml yaml = new Yaml(); actor.setInputs((Map<String, Object>) yaml.load("originalValue:" + EOL)); actor.setOutputs((Map<String, Object>) yaml.load("multipliedValue:" + EOL)); actor.setSettings((Map<String, Object>) yaml.load("factor: 3" + EOL)); actor.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); actor.initialize(); actor.setInputValue("originalValue", 4); actor.step(); assertEquals(12, actor.getOutputValue("multipliedValue")); }