@Test public void testGetPathForBranch() { State state = new State(); state.setProp(ConfigurationKeys.FORK_BRANCH_NAME_KEY + ".0", FORK_BRANCH_NAME_0); state.setProp(ConfigurationKeys.FORK_BRANCH_NAME_KEY + ".1", FORK_BRANCH_NAME_1); Assert.assertEquals(ForkOperatorUtils.getPathForBranch(state, PATH_FOO, 2, 0), PATH_FOO + "/" + FORK_BRANCH_NAME_0); Assert.assertEquals(ForkOperatorUtils.getPathForBranch(state, PATH_FOO, 2, 1), PATH_FOO + "/" + FORK_BRANCH_NAME_1); }
public static String getPathForBranch(State state, String path, int numBranches, int branchId) { Preconditions.checkNotNull(state); Preconditions.checkNotNull(path); Preconditions.checkArgument(numBranches >= 0, "The number of branches is expected to be non-negative"); Preconditions.checkArgument(branchId >= 0, "The branch id is expected to be non-negative"); return numBranches > 1 ? path + Path.SEPARATOR + state.getProp(ConfigurationKeys.FORK_BRANCH_NAME_KEY + "." + branchId, ConfigurationKeys.DEFAULT_FORK_BRANCH_NAME + branchId) : path; }
ForkOperatorUtils { public static String getPathForBranch(State state, String path, int numBranches, int branchId) { Preconditions.checkNotNull(state); Preconditions.checkNotNull(path); Preconditions.checkArgument(numBranches >= 0, "The number of branches is expected to be non-negative"); Preconditions.checkArgument(branchId >= 0, "The branch id is expected to be non-negative"); return numBranches > 1 ? path + Path.SEPARATOR + state.getProp(ConfigurationKeys.FORK_BRANCH_NAME_KEY + "." + branchId, ConfigurationKeys.DEFAULT_FORK_BRANCH_NAME + branchId) : path; } }
ForkOperatorUtils { public static String getPathForBranch(State state, String path, int numBranches, int branchId) { Preconditions.checkNotNull(state); Preconditions.checkNotNull(path); Preconditions.checkArgument(numBranches >= 0, "The number of branches is expected to be non-negative"); Preconditions.checkArgument(branchId >= 0, "The branch id is expected to be non-negative"); return numBranches > 1 ? path + Path.SEPARATOR + state.getProp(ConfigurationKeys.FORK_BRANCH_NAME_KEY + "." + branchId, ConfigurationKeys.DEFAULT_FORK_BRANCH_NAME + branchId) : path; }  }
ForkOperatorUtils { public static String getPathForBranch(State state, String path, int numBranches, int branchId) { Preconditions.checkNotNull(state); Preconditions.checkNotNull(path); Preconditions.checkArgument(numBranches >= 0, "The number of branches is expected to be non-negative"); Preconditions.checkArgument(branchId >= 0, "The branch id is expected to be non-negative"); return numBranches > 1 ? path + Path.SEPARATOR + state.getProp(ConfigurationKeys.FORK_BRANCH_NAME_KEY + "." + branchId, ConfigurationKeys.DEFAULT_FORK_BRANCH_NAME + branchId) : path; }  static String getPropertyNameForBranch(String key, int numBranches, int branchId); static String getPropertyNameForBranch(String key, int branch); static String getPropertyNameForBranch(WorkUnitState workUnitState, String key); static String getPathForBranch(State state, String path, int numBranches, int branchId); static String getForkId(String taskId, int index); }
ForkOperatorUtils { public static String getPathForBranch(State state, String path, int numBranches, int branchId) { Preconditions.checkNotNull(state); Preconditions.checkNotNull(path); Preconditions.checkArgument(numBranches >= 0, "The number of branches is expected to be non-negative"); Preconditions.checkArgument(branchId >= 0, "The branch id is expected to be non-negative"); return numBranches > 1 ? path + Path.SEPARATOR + state.getProp(ConfigurationKeys.FORK_BRANCH_NAME_KEY + "." + branchId, ConfigurationKeys.DEFAULT_FORK_BRANCH_NAME + branchId) : path; }  static String getPropertyNameForBranch(String key, int numBranches, int branchId); static String getPropertyNameForBranch(String key, int branch); static String getPropertyNameForBranch(WorkUnitState workUnitState, String key); static String getPathForBranch(State state, String path, int numBranches, int branchId); static String getForkId(String taskId, int index);  }