@Test public void testGetItem() { Map<String, String> result = new ListItemGrabberAction().grabItemFromList(LIST, ",", "1"); assertEquals("success", result.get("response")); assertEquals("Ion", result.get("result")); }
@Action(name = "List Item Grabber", 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 = RESPONSE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true) }) public Map<String, String> grabItemFromList(@Param(value = LIST, required = true) String list, @Param(value = DELIMITER, required = true) String delimiter, @Param(value = INDEX, required = true) String index) { Map<String, String> result = new HashMap<>(); try { String[] table = ListProcessor.toArray(list, delimiter); int resolvedIndex; try { resolvedIndex = ListProcessor.getIndex(index, table.length); } catch (NumberFormatException e) { throw new NumberFormatException(e.getMessage() + WHILE_PARSING_INDEX); } String value = table[resolvedIndex]; 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; }
ListItemGrabberAction { @Action(name = "List Item Grabber", 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 = RESPONSE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true) }) public Map<String, String> grabItemFromList(@Param(value = LIST, required = true) String list, @Param(value = DELIMITER, required = true) String delimiter, @Param(value = INDEX, required = true) String index) { Map<String, String> result = new HashMap<>(); try { String[] table = ListProcessor.toArray(list, delimiter); int resolvedIndex; try { resolvedIndex = ListProcessor.getIndex(index, table.length); } catch (NumberFormatException e) { throw new NumberFormatException(e.getMessage() + WHILE_PARSING_INDEX); } String value = table[resolvedIndex]; 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; } }
ListItemGrabberAction { @Action(name = "List Item Grabber", 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 = RESPONSE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true) }) public Map<String, String> grabItemFromList(@Param(value = LIST, required = true) String list, @Param(value = DELIMITER, required = true) String delimiter, @Param(value = INDEX, required = true) String index) { Map<String, String> result = new HashMap<>(); try { String[] table = ListProcessor.toArray(list, delimiter); int resolvedIndex; try { resolvedIndex = ListProcessor.getIndex(index, table.length); } catch (NumberFormatException e) { throw new NumberFormatException(e.getMessage() + WHILE_PARSING_INDEX); } String value = table[resolvedIndex]; 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; }  }
ListItemGrabberAction { @Action(name = "List Item Grabber", 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 = RESPONSE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true) }) public Map<String, String> grabItemFromList(@Param(value = LIST, required = true) String list, @Param(value = DELIMITER, required = true) String delimiter, @Param(value = INDEX, required = true) String index) { Map<String, String> result = new HashMap<>(); try { String[] table = ListProcessor.toArray(list, delimiter); int resolvedIndex; try { resolvedIndex = ListProcessor.getIndex(index, table.length); } catch (NumberFormatException e) { throw new NumberFormatException(e.getMessage() + WHILE_PARSING_INDEX); } String value = table[resolvedIndex]; 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 = "List Item Grabber", 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 = RESPONSE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true) }) Map<String, String> grabItemFromList(@Param(value = LIST, required = true) String list,
                                                @Param(value = DELIMITER, required = true) String delimiter,
                                                @Param(value = INDEX, required = true) String index); }
ListItemGrabberAction { @Action(name = "List Item Grabber", 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 = RESPONSE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true) }) public Map<String, String> grabItemFromList(@Param(value = LIST, required = true) String list, @Param(value = DELIMITER, required = true) String delimiter, @Param(value = INDEX, required = true) String index) { Map<String, String> result = new HashMap<>(); try { String[] table = ListProcessor.toArray(list, delimiter); int resolvedIndex; try { resolvedIndex = ListProcessor.getIndex(index, table.length); } catch (NumberFormatException e) { throw new NumberFormatException(e.getMessage() + WHILE_PARSING_INDEX); } String value = table[resolvedIndex]; 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 = "List Item Grabber", 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 = RESPONSE, value = RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, isOnFail = true, isDefault = true) }) Map<String, String> grabItemFromList(@Param(value = LIST, required = true) String list,
                                                @Param(value = DELIMITER, required = true) String delimiter,
                                                @Param(value = INDEX, required = true) String index);  }