StepUtils { public static Set<Step> getImmediateDependentSteps(Step step, Set<Step> steps) { Set<Step> dependencies = Sets.newHashSet(); for (Step candidateStep : steps) { if (candidateStep.getDependencyNames().contains(step.getName())) { dependencies.add(candidateStep); } } 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 testGetImmediateDependentSteps() { Step step1 = new BatchStep("step1"); Step step2 = new BatchStep("step2"); Step step3 = new BatchStep("step3"); step1.configure(ConfigFactory.empty().withValue("dependencies", ConfigValueFactory.fromIterable(Sets.newHashSet()))); step2.configure(ConfigFactory.empty().withValue("dependencies", ConfigValueFactory.fromIterable(Sets.newHashSet("step1")))); step3.configure(ConfigFactory.empty().withValue("dependencies", ConfigValueFactory.fromIterable(Sets.newHashSet("step2")))); Set<Step> steps = Sets.newHashSet(step1, step2, step3); Set<Step> step1ImmediateDependents = StepUtils.getImmediateDependentSteps(step1, steps); Set<Step> step2ImmediateDependents = StepUtils.getImmediateDependentSteps(step2, steps); Set<Step> step3ImmediateDependents = StepUtils.getImmediateDependentSteps(step3, steps); assertEquals(step1ImmediateDependents.size(), 1); assertEquals(step2ImmediateDependents.size(), 1); assertEquals(step3ImmediateDependents.size(), 0); assertEquals(step1ImmediateDependents, Sets.newHashSet(step2)); assertEquals(step2ImmediateDependents, Sets.newHashSet(step3)); assertEquals(step3ImmediateDependents, Sets.newHashSet()); }