StepUtils { public static Set<Step> getDependencies(Step step, Set<Step> steps) { Set<Step> dependencies = Sets.newHashSet(); Set<String> dependencyNames = step.getDependencyNames(); for (Step candidate : steps) { String candidateName = candidate.getName(); if (dependencyNames.contains(candidateName)) { dependencies.add(candidate); } } return dependencies; }  static boolean allStepsSubmitted(Set<Step> steps); static boolean allStepsFinished(Set<Step> steps); static Set<Step> getDependencies(Step step, Set<Step> steps); static boolean hasStreamingStep(Set<Step> steps); static Set<StreamingStep> getStreamingSteps(Set<Step> steps); static Set<Step> getAllDependentSteps(Step rootStep, Set<Step> steps); static Set<Step> getImmediateDependentSteps(Step step, Set<Step> steps); static Set<Step> getIndependentNonStreamingSteps(Set<Step> steps); static String stepNamesAsString(Set<? extends Step> steps); static void resetSteps(Set<Step> steps); static void resetRepeatingSteps(Set<Step> allSteps); static Set<DataStep> getDataSteps(Set<Step> steps); static Optional<Step> getStepForName(String name, Set<Step> steps); static Set<Step> copySteps(Set<Step> steps); static Map<String, Dataset<Row>> getStepDataFrames(Set<Step> steps); static Set<Step> extractSteps(Config config, boolean configure, boolean notify); static Set<Step> mergeLoadedSteps(Set<Step> baseSteps, Step parentStep, Config baseConfig); static Map<String, StepState> getStepStates(Set<Step> steps); static Set<Step> getStepsMatchingState(Set<Step> steps, StepState matching);  }
@Test public void testGetDependencies() { Set<Step> steps = Sets.newHashSet(); BatchStep step1 = new BatchStep("step1"); BatchStep step2 = new BatchStep("step2"); BatchStep step3 = new BatchStep("step3"); step1.configure(ConfigFactory.empty()); step2.configure(ConfigFactory.empty()); step3.configure(ConfigFactory.empty()); steps.add(step1); steps.add(step2); steps.add(step3); step2.setDependencyNames(Sets.newHashSet("step1")); step3.setDependencyNames(Sets.newHashSet("step1", "step2")); Set<Step> step1Dependencies = StepUtils.getDependencies(step1, steps); Set<Step> step2Dependencies = StepUtils.getDependencies(step2, steps); Set<Step> step3Dependencies = StepUtils.getDependencies(step3, steps); assertEquals(step1Dependencies.size(), 0); assertEquals(step2Dependencies.size(), 1); assertEquals(step3Dependencies.size(), 2); assertEquals(step1Dependencies, Sets.newHashSet()); assertEquals(step2Dependencies, Sets.newHashSet(step1)); assertEquals(step3Dependencies, Sets.newHashSet(step1, step2)); }