NodeBeanLoader { public NodeBean load(final File flowFile) throws Exception { checkArgument(flowFile != null && flowFile.exists()); checkArgument(flowFile.getName().endsWith(Constants.FLOW_FILE_SUFFIX)); final NodeBean nodeBean = new Yaml().loadAs(new FileInputStream(flowFile), NodeBean.class); if (nodeBean == null) { throw new ProjectManagerException( "Failed to load flow file " + flowFile.getName() + ". Node bean is null ."); } nodeBean.setName(getFlowName(flowFile)); nodeBean.setType(Constants.FLOW_NODE_TYPE); return nodeBean; }  NodeBean load(final File flowFile); boolean validate(final NodeBean nodeBean); AzkabanNode toAzkabanNode(final NodeBean nodeBean); FlowTrigger toFlowTrigger(final FlowTriggerBean flowTriggerBean); String getFlowName(final File flowFile);  }
@Test public void testLoadNodeBeanForBasicFlow() throws Exception { final NodeBeanLoader loader = new NodeBeanLoader(); final NodeBean nodeBean = loader.load(ExecutionsTestUtil.getFlowFile( BASIC_FLOW_YML_TEST_DIR, BASIC_FLOW_YML_FILE)); validateNodeBean(nodeBean, BASIC_FLOW_NAME, Constants.FLOW_NODE_TYPE, FLOW_CONFIG_KEY, FLOW_CONFIG_VALUE, 4, null); validateNodeBean(nodeBean.getNodes().get(0), SHELL_END, TYPE_NOOP, null, null, 0, Arrays.asList(SHELL_PWD, SHELL_ECHO, SHELL_BASH)); validateNodeBean(nodeBean.getNodes().get(1), SHELL_ECHO, TYPE_COMMAND, TYPE_COMMAND, ECHO_COMMAND, 0, null); }
@Test public void testLoadNodeBeanForEmbeddedFlow() throws Exception { final NodeBeanLoader loader = new NodeBeanLoader(); final NodeBean nodeBean = loader.load(ExecutionsTestUtil.getFlowFile( EMBEDDED_FLOW_YML_TEST_DIR, EMBEDDED_FLOW_YML_FILE)); validateNodeBean(nodeBean, EMBEDDED_FLOW_NAME, Constants.FLOW_NODE_TYPE, FLOW_CONFIG_KEY, FLOW_CONFIG_VALUE, 4, null); validateNodeBean(nodeBean.getNodes().get(0), SHELL_END, TYPE_NOOP, null, null, 0, Arrays.asList(SHELL_PWD, SHELL_ECHO, EMBEDDED_FLOW1)); validateNodeBean(nodeBean.getNodes().get(1), SHELL_PWD, TYPE_COMMAND, TYPE_COMMAND, PWD_COMMAND, 0, null); validateNodeBean(nodeBean.getNodes().get(2), SHELL_ECHO, TYPE_COMMAND, TYPE_COMMAND, ECHO_COMMAND, 0, null); validateNodeBean(nodeBean.getNodes().get(3), EMBEDDED_FLOW1, Constants.FLOW_NODE_TYPE, FLOW_CONFIG_KEY, FLOW_CONFIG_VALUE, 4, null); final NodeBean embeddedNodeBean1 = nodeBean.getNodes().get(3); validateNodeBean(embeddedNodeBean1.getNodes().get(0), SHELL_END, TYPE_NOOP, null, null, 0, Arrays.asList(SHELL_ECHO, EMBEDDED_FLOW2)); validateNodeBean(embeddedNodeBean1.getNodes().get(1), SHELL_ECHO, TYPE_COMMAND, TYPE_COMMAND, ECHO_COMMAND_1, 0, null); validateNodeBean(embeddedNodeBean1.getNodes().get(2), EMBEDDED_FLOW2, Constants.FLOW_NODE_TYPE, FLOW_CONFIG_KEY, FLOW_CONFIG_VALUE, 2, Arrays.asList(SHELL_BASH)); validateNodeBean(embeddedNodeBean1.getNodes().get(3), SHELL_BASH, TYPE_COMMAND, TYPE_COMMAND, BASH_COMMAND, 0, null); validateNodeBean(embeddedNodeBean1.getNodes().get(2).getNodes().get(0), SHELL_END, TYPE_NOOP, null, null, 0, Arrays.asList(SHELL_PWD)); validateNodeBean(embeddedNodeBean1.getNodes().get(2).getNodes().get(1), SHELL_PWD, TYPE_COMMAND, TYPE_COMMAND, PWD_COMMAND, 0, null); }