@Test public void testTrimList() throws IOException { String listString = "1A,2B,3C,4D,5E,6F,7G,8H,9I,10J"; String listInteger = "1,2,3,4,5,6,7,8,9,10"; Map<String, String> result = new ListTrimAction().trimList(listString, ",", "20"); assertEquals("success", result.get("response")); assertEquals("1A,2B,3C,4D,5E,6F,7G,8H", result.get("result")); Map<String, String> result2 = new ListTrimAction().trimList(listInteger, ",", "20"); assertEquals("success", result2.get("response")); assertEquals("2,3,4,5,6,7,8,9", result2.get("result")); }
@Action(name = "Trim List", outputs = { @Output(RESULT_TEXT), @Output(RESPONSE), @Output(RETURN_RESULT), @Output(RETURN_CODE) }, responses = {@Response(text = SUCCESS, field = RETURN_CODE, value = RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL), @Response(text = FAILURE, field = RETURN_CODE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true)}) public Map<String, String> trimList(@Param(value = LIST, required = true) String list, @Param(value = DELIMITER, required = true) String delimiter, @Param(value = PERCENTAGE, required = true) String percentage) { Map<String, String> result = new HashMap<>(); try { int intPct; try { intPct = Integer.parseInt(percentage); } catch (NumberFormatException e) { throw new NumberFormatException(e.getMessage() + PARSING_PERCENT_EXCEPTION_MSG); } String value; try { value = trimIntList(list, delimiter, intPct); } catch (Exception e) { try { value = trimDoubleList(list, delimiter, intPct); } catch (Exception f) { value = trimStringList(list, delimiter, intPct); } } result.put(RESULT_TEXT, value); result.put(RESPONSE, SUCCESS); result.put(RETURN_RESULT, value); result.put(RETURN_CODE, RETURN_CODE_SUCCESS); } catch (Exception e) { result.put(RESULT_TEXT, e.getMessage()); result.put(RESPONSE, FAILURE); result.put(RETURN_RESULT, e.getMessage()); result.put(RETURN_CODE, RETURN_CODE_FAILURE); } return result; }
ListTrimAction { @Action(name = "Trim List", outputs = { @Output(RESULT_TEXT), @Output(RESPONSE), @Output(RETURN_RESULT), @Output(RETURN_CODE) }, responses = {@Response(text = SUCCESS, field = RETURN_CODE, value = RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL), @Response(text = FAILURE, field = RETURN_CODE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true)}) public Map<String, String> trimList(@Param(value = LIST, required = true) String list, @Param(value = DELIMITER, required = true) String delimiter, @Param(value = PERCENTAGE, required = true) String percentage) { Map<String, String> result = new HashMap<>(); try { int intPct; try { intPct = Integer.parseInt(percentage); } catch (NumberFormatException e) { throw new NumberFormatException(e.getMessage() + PARSING_PERCENT_EXCEPTION_MSG); } String value; try { value = trimIntList(list, delimiter, intPct); } catch (Exception e) { try { value = trimDoubleList(list, delimiter, intPct); } catch (Exception f) { value = trimStringList(list, delimiter, intPct); } } result.put(RESULT_TEXT, value); result.put(RESPONSE, SUCCESS); result.put(RETURN_RESULT, value); result.put(RETURN_CODE, RETURN_CODE_SUCCESS); } catch (Exception e) { result.put(RESULT_TEXT, e.getMessage()); result.put(RESPONSE, FAILURE); result.put(RETURN_RESULT, e.getMessage()); result.put(RETURN_CODE, RETURN_CODE_FAILURE); } return result; } }
ListTrimAction { @Action(name = "Trim List", outputs = { @Output(RESULT_TEXT), @Output(RESPONSE), @Output(RETURN_RESULT), @Output(RETURN_CODE) }, responses = {@Response(text = SUCCESS, field = RETURN_CODE, value = RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL), @Response(text = FAILURE, field = RETURN_CODE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true)}) public Map<String, String> trimList(@Param(value = LIST, required = true) String list, @Param(value = DELIMITER, required = true) String delimiter, @Param(value = PERCENTAGE, required = true) String percentage) { Map<String, String> result = new HashMap<>(); try { int intPct; try { intPct = Integer.parseInt(percentage); } catch (NumberFormatException e) { throw new NumberFormatException(e.getMessage() + PARSING_PERCENT_EXCEPTION_MSG); } String value; try { value = trimIntList(list, delimiter, intPct); } catch (Exception e) { try { value = trimDoubleList(list, delimiter, intPct); } catch (Exception f) { value = trimStringList(list, delimiter, intPct); } } result.put(RESULT_TEXT, value); result.put(RESPONSE, SUCCESS); result.put(RETURN_RESULT, value); result.put(RETURN_CODE, RETURN_CODE_SUCCESS); } catch (Exception e) { result.put(RESULT_TEXT, e.getMessage()); result.put(RESPONSE, FAILURE); result.put(RETURN_RESULT, e.getMessage()); result.put(RETURN_CODE, RETURN_CODE_FAILURE); } return result; }  }
ListTrimAction { @Action(name = "Trim List", outputs = { @Output(RESULT_TEXT), @Output(RESPONSE), @Output(RETURN_RESULT), @Output(RETURN_CODE) }, responses = {@Response(text = SUCCESS, field = RETURN_CODE, value = RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL), @Response(text = FAILURE, field = RETURN_CODE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true)}) public Map<String, String> trimList(@Param(value = LIST, required = true) String list, @Param(value = DELIMITER, required = true) String delimiter, @Param(value = PERCENTAGE, required = true) String percentage) { Map<String, String> result = new HashMap<>(); try { int intPct; try { intPct = Integer.parseInt(percentage); } catch (NumberFormatException e) { throw new NumberFormatException(e.getMessage() + PARSING_PERCENT_EXCEPTION_MSG); } String value; try { value = trimIntList(list, delimiter, intPct); } catch (Exception e) { try { value = trimDoubleList(list, delimiter, intPct); } catch (Exception f) { value = trimStringList(list, delimiter, intPct); } } result.put(RESULT_TEXT, value); result.put(RESPONSE, SUCCESS); result.put(RETURN_RESULT, value); result.put(RETURN_CODE, RETURN_CODE_SUCCESS); } catch (Exception e) { result.put(RESULT_TEXT, e.getMessage()); result.put(RESPONSE, FAILURE); result.put(RETURN_RESULT, e.getMessage()); result.put(RETURN_CODE, RETURN_CODE_FAILURE); } return result; }  @Action(name = "Trim List", outputs = { @Output(RESULT_TEXT), @Output(RESPONSE), @Output(RETURN_RESULT), @Output(RETURN_CODE) }, responses = {@Response(text = SUCCESS, field = RETURN_CODE, value = RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL), @Response(text = FAILURE, field = RETURN_CODE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true)}) Map<String, String> trimList(@Param(value = LIST, required = true) String list,
                                        @Param(value = DELIMITER, required = true) String delimiter,
                                        @Param(value = PERCENTAGE, required = true) String percentage); String trimIntList(String str_list, String delimiter, int percent); String trimDoubleList(String str_list, String delimiter, int percent); String trimStringList(String str_list, String delimiter, int percent); }
ListTrimAction { @Action(name = "Trim List", outputs = { @Output(RESULT_TEXT), @Output(RESPONSE), @Output(RETURN_RESULT), @Output(RETURN_CODE) }, responses = {@Response(text = SUCCESS, field = RETURN_CODE, value = RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL), @Response(text = FAILURE, field = RETURN_CODE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true)}) public Map<String, String> trimList(@Param(value = LIST, required = true) String list, @Param(value = DELIMITER, required = true) String delimiter, @Param(value = PERCENTAGE, required = true) String percentage) { Map<String, String> result = new HashMap<>(); try { int intPct; try { intPct = Integer.parseInt(percentage); } catch (NumberFormatException e) { throw new NumberFormatException(e.getMessage() + PARSING_PERCENT_EXCEPTION_MSG); } String value; try { value = trimIntList(list, delimiter, intPct); } catch (Exception e) { try { value = trimDoubleList(list, delimiter, intPct); } catch (Exception f) { value = trimStringList(list, delimiter, intPct); } } result.put(RESULT_TEXT, value); result.put(RESPONSE, SUCCESS); result.put(RETURN_RESULT, value); result.put(RETURN_CODE, RETURN_CODE_SUCCESS); } catch (Exception e) { result.put(RESULT_TEXT, e.getMessage()); result.put(RESPONSE, FAILURE); result.put(RETURN_RESULT, e.getMessage()); result.put(RETURN_CODE, RETURN_CODE_FAILURE); } return result; }  @Action(name = "Trim List", outputs = { @Output(RESULT_TEXT), @Output(RESPONSE), @Output(RETURN_RESULT), @Output(RETURN_CODE) }, responses = {@Response(text = SUCCESS, field = RETURN_CODE, value = RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL), @Response(text = FAILURE, field = RETURN_CODE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true)}) Map<String, String> trimList(@Param(value = LIST, required = true) String list,
                                        @Param(value = DELIMITER, required = true) String delimiter,
                                        @Param(value = PERCENTAGE, required = true) String percentage); String trimIntList(String str_list, String delimiter, int percent); String trimDoubleList(String str_list, String delimiter, int percent); String trimStringList(String str_list, String delimiter, int percent);  }