ExecutionRampDao { public Map<String, String> doRampActions(List<Map<String, Object>> rampActionsMap) { Map<String, String> result = new HashMap<>(); for(int i = 0; i < rampActionsMap.size(); i++) { result.put(Integer.toString(i), doRampAction(rampActionsMap.get(i))); } return result; } @Inject  ExecutionRampDao(final DatabaseOperator dbOperator); ExecutableRampMap fetchExecutableRampMap(); ExecutableRampItemsMap fetchExecutableRampItemsMap(); ExecutableRampDependencyMap fetchExecutableRampDependencyMap(); ExecutableRampExceptionalFlowItemsMap fetchExecutableRampExceptionalFlowItemsMap(); ExecutableRampExceptionalJobItemsMap fetchExecutableRampExceptionalJobItemsMap(); void insertAction(final String tableName, Map<String, Object> actionData); void deleteAction(final String tableName, Map<String, Object> constraints); void updateAction(final String tableName, Map<String, Object> actionData, Map<String, Object> constraints); Map<String, String> doRampActions(List<Map<String, Object>> rampActionsMap); void updateExecutableRamp(ExecutableRamp executableRamp); void updateExecutedRampFlows(final String ramp, ExecutableRampExceptionalItems executableRampExceptionalItems);  }
@Test public void testDoRampActions() throws ExecutorManagerException { List<Map<String, Object>> actions = ImmutableList.<Map<String, Object>>builder() .add(ImmutableMap.<String, Object>builder() .put("action", "insert") .put("table", "ramp") .put("values", ImmutableMap.<String, Object>builder() .put("rampId", "dali") .put("rampPolicy", "SimpleAutoRampPolicy") .build()) .build()) .add(ImmutableMap.<String, Object>builder() .put("action", "insert") .put("table", "ramp_items") .put("values", ImmutableMap.<String, Object>builder() .put("rampId", "dali") .put("dependency", "jar:dali-data-pig") .put("rampValue", "/export/apps/dali/pig/dali-data-pig-9.2.10.jar") .build()) .build()) .build(); Map<String, String> results = this.executionRampDao.doRampActions(actions); results.forEach((k, v) -> assertThat(v.startsWith("[SUCCESS]")).isTrue()); final ExecutableRampMap ramps = this.executionRampDao.fetchExecutableRampMap(); assertThat(ramps.get("dali").isActive()).isFalse(); assertThat(ramps.get("dali").getPolicy()).isEqualTo("SimpleAutoRampPolicy"); assertThat(ramps.get("dali").getMaxFailureToRampDown()).isZero(); assertThat(ramps.get("dali").getMaxFailureToPause()).isZero(); assertThat(ramps.get("dali").isPercentageScaleForMaxFailure()).isFalse(); assertThat(ramps.get("dali").getStage()).isZero(); assertThat(ramps.get("dali").getStartTime()).isNotZero(); assertThat(ramps.get("dali").getEndTime()).isZero(); assertThat(ramps.get("dali").getLastUpdatedTime()).isZero(); assertThat(ramps.get("dali").getCount(ExecutableRamp.CountType.FAILURE)).isZero(); assertThat(ramps.get("dali").getCount(ExecutableRamp.CountType.SUCCESS)).isZero(); assertThat(ramps.get("dali").getCount(ExecutableRamp.CountType.TRAIL)).isZero(); assertThat(ramps.get("dali").isPaused()).isFalse(); assertThat(ramps.size()).isEqualTo(1); final ExecutableRampItemsMap rampItems = this.executionRampDao.fetchExecutableRampItemsMap(); assertThat(rampItems.getRampItems("dali").get("jar:dali-data-pig")) .isEqualToIgnoringWhitespace("/export/apps/dali/pig/dali-data-pig-9.2.10.jar"); assertThat(rampItems.size()).isEqualTo(1); }