FlowLoaderFactory { public FlowLoader createFlowLoader(final File projectDir) throws ProjectManagerException { if (checkForValidProjectYamlFile(projectDir)) { return new DirectoryYamlFlowLoader(this.props); } else { return new DirectoryFlowLoader(this.props); } } @Inject  FlowLoaderFactory(final Props props); FlowLoader createFlowLoader(final File projectDir);  }
@Test public void testCreateDirectoryFlowLoader() { final FlowLoaderFactory loaderFactory = new FlowLoaderFactory(new Props(null)); final File projectDir = ExecutionsTestUtil.getFlowDir(FLOW_10_TEST_DIRECTORY); final FlowLoader loader = loaderFactory.createFlowLoader(projectDir); assertThat(loader instanceof DirectoryFlowLoader).isTrue(); }
@Test public void testCreateDirectoryYamlFlowLoader() { final FlowLoaderFactory loaderFactory = new FlowLoaderFactory(new Props(null)); final File projectDir = ExecutionsTestUtil.getFlowDir(FLOW_20_TEST_DIRECTORY); final FlowLoader loader = loaderFactory.createFlowLoader(projectDir); assertThat(loader instanceof DirectoryYamlFlowLoader).isTrue(); }
@Test public void testCreateDirectoryYamlFlowLoaderWithRecursiveDirectory() { final FlowLoaderFactory loaderFactory = new FlowLoaderFactory(new Props(null)); final File projectDir = ExecutionsTestUtil.getFlowDir(FLOW_20_TEST_RECURSIVE_DIRECTORY); final FlowLoader loader = loaderFactory.createFlowLoader(projectDir); assertThat(loader instanceof DirectoryYamlFlowLoader).isTrue(); }
@Test public void testDuplicateProjectYamlFilesException() { final FlowLoaderFactory loaderFactory = new FlowLoaderFactory(new Props(null)); final File projectDir = ExecutionsTestUtil.getFlowDir(DUPLICATE_PROJECT_DIRECTORY); assertThatThrownBy(() -> loaderFactory.createFlowLoader(projectDir)) .isInstanceOf(ProjectManagerException.class) .hasMessageContaining( "Duplicate project YAML files found in the project directory. Only one is allowed."); }
@Test public void testNoFlowVersionException() { final FlowLoaderFactory loaderFactory = new FlowLoaderFactory(new Props(null)); final File projectDir = ExecutionsTestUtil.getFlowDir(NO_FLOW_VERSION_DIRECTORY); assertThatThrownBy(() -> loaderFactory.createFlowLoader(projectDir)) .isInstanceOf(ProjectManagerException.class) .hasMessageContaining("azkaban-flow-version is not specified in the project YAML file."); }
@Test public void testInvalidFlowVersionException() { final FlowLoaderFactory loaderFactory = new FlowLoaderFactory(new Props(null)); final File projectDir = ExecutionsTestUtil.getFlowDir(INVALID_FLOW_VERSION_DIRECTORY); assertThatThrownBy(() -> loaderFactory.createFlowLoader(projectDir)) .isInstanceOf(ProjectManagerException.class) .hasMessageContaining("Invalid azkaban-flow-version in the project YAML file."); }