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 testSetInputValue_NewValueForSetting() 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.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); actor.initialize(); Exception exception = null; try { actor.setInputValue("factor", 4); } catch (Exception e) { exception = e; } assertNotNull(exception); assertEquals( "org.restflow.exceptions.RestFlowException: " + "Attempt to reassign value of setting 'factor' on actor MultiplyActor", exception.toString()); }
public void testStep_SetInputValue_NullValue_NotNullable() 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.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); actor.initialize(); Exception exception = null; try { actor.setInputValue("originalValue", null); } catch (NullInputException e) { exception = e; } assertNotNull(exception); assertEquals( "org.restflow.exceptions.NullInputException: " + "Null data received on non-nullable input 'originalValue' " + "of actor 'MultiplyActor'", exception.toString()); }
public void testSetInputs() 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)); }
public void testClone_ExceptionInBeanClone() 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: 4" + EOL)); actor.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); actor.initialize(); MultiplyBean.throwExceptionInClone = true; Exception exception = null; try { actor.clone(); } catch (CloneNotSupportedException e) { exception = e; } assertEquals( "java.lang.CloneNotSupportedException: " + "Exception cloning class org.restflow.actors.TestJavaActor$MultiplyBean " + "wrapped by actor MultiplyActor", exception.toString()); }
public static JavaActor getConfiguredActor() throws Exception { JavaActor actor = new JavaActor(); actor.setName("BadWorkflowProcessingActor"); actor.setWrappedBean(new BadWorkflowProcessingBean()); Yaml yaml = new Yaml(); actor.setInputs((Map<String, Object>) yaml.load("workflow:" + EOL)); actor.setApplicationContext(new WorkflowContextBuilder().build()); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); return actor; }
public static JavaActor getConfiguredActor() 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: 2" + EOL)); actor.setApplicationContext(new WorkflowContextBuilder().build()); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); return actor; }
public void testStep_SetInputValue_NonNullValue() 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.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); actor.initialize(); actor.setInputValue("originalValue", 72); actor.step(); assertEquals(new Integer(72), bean.getOriginalValue()); }
public void testConfigure_CustomStep() throws Exception { JavaActor actor = new JavaActor(); MultiplyBean bean = new MultiplyBean(); actor.setStepMethod("customStep"); actor.setWrappedBean(bean); Yaml yaml = new Yaml(); actor.setInputs((Map<String, Object>) yaml.load("originalValue:" + EOL)); actor.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); actor.initialize(); actor.setInputValue("originalValue", 1); assertFalse(bean.stepped); actor.step(); assertTrue(bean.stepped); assertTrue(bean.customStep); }
public void testStep_SetInputValue_NullValue_Nullable() 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 + " nullable: true" + EOL)); actor.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); actor.initialize(); actor.setInputValue("originalValue", null); try { actor.step(); } catch (Exception e) { } assertNull(bean.getOriginalValue()); }
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_setStateVariablesInitialValues_Nulls() 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:" + EOL + "count:" + EOL)); actor.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); actor.initialize(); assertEquals(0, bean.getAccumulator()); assertEquals(new Integer(0), bean.getCount()); }
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")); }
public void testStep_SetStatus() 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.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); actor.initialize(); actor.setInputValue("originalValue", 4); assertEquals(0, bean.getAccumulator()); assertEquals((Integer) 0, bean.getCount()); bean.statusSet = false; bean.actorStatus = null; actor.step(); assertNotNull(bean.actorStatus); assertTrue(bean.statusSet); }
public void testStep_SetStatusException() 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.setApplicationContext(_context); actor.afterPropertiesSet(); actor.elaborate(); actor.configure(); actor.initialize(); actor.setInputValue("originalValue", 4); assertEquals(0, bean.getAccumulator()); assertEquals((Integer) 0, bean.getCount()); bean.statusSet = false; bean.actorStatus = null; MultiplyBean.throwExceptionInStatusSetter = true; Exception exception = null; try { actor.step(); } catch (RestFlowException e) { exception = e; } assertNotNull(exception); assertEquals( "org.restflow.exceptions.WorkflowRuntimeException: " + "Exception in setStatus() method of actor MultiplyActor", exception.toString()); assertNotNull(exception.getCause()); assertEquals( "java.lang.Exception: Exception in status setter", exception.getCause().toString()); }