CarpaccioHelper { public static Object removeTag(View view, String actionName) { if (view.getTag() != null && view.getTag() instanceof List && actionName!= null) { List<CarpaccioAction> actions = (List<CarpaccioAction>) view.getTag(); List<CarpaccioAction> newActions = new ArrayList<>(); for (int i = 0, count = actions.size(); i < count; ++i) if (!actions.get(i).getCompleteCall().equals(actionName)) newActions.add(actions.get(i)); return newActions; } return view.getTag(); }  static Object construct(String name); static Class[] getClassesWithHeaderClass(Object[] args, Class headerClass); static Class[] getClasses(Object[] args); static Object[] getArgumentsWithView(View view, Class[] parametersType, Object[] args); static String getFunctionName(String tag); static String[] getAttributes(String tag); static Object removeTag(View view, String actionName); static String[] trim(String[] strings); static ObjectAndMethod findObjectWithThisMethod(List<Object> objects, String function, int numberOfParams); static Method callFunction(Object object, String name, View view, Object[] args); static Method callMethod(Object object, Method method, String name, View view, Object[] args); static T callFunction(Object object, String name); static T callFunction(Object object, String name, Object[] args); static Integer stringToInt(String s); static Double stringToDouble(String s); static Long stringToLong(String s); static Float stringToFloat(String s); static boolean isNumber(Class destinationClass); static Object stringToNumber(String s, Class destinationClass); static T findParentOfClass(View view, Class<T> theClass); static Carpaccio findParentCarpaccio(View view); static Carpaccio registerToParentCarpaccio(View view); static String TAG; static boolean LOG_FAILURES; }
@Test public void testRemoveTag() throws Exception { List<CarpaccioAction> carpaccioActions = new ArrayList<>(); View view = mock(View.class); doReturn(carpaccioActions).when(view).getTag(); carpaccioActions.add(new CarpaccioAction("setColor(red)")); carpaccioActions.add(new CarpaccioAction("setText(florent)")); carpaccioActions.add(new CarpaccioAction("setBackground(blue)")); List<CarpaccioAction> expected = new ArrayList<>(); expected.add(new CarpaccioAction("setColor(red)")); expected.add(new CarpaccioAction("setBackground(blue)")); assertEquals(expected, CarpaccioHelper.removeTag(view, "setText(florent)")); }
@Test public void testRemoveTag_null() throws Exception { View view = mock(View.class); doReturn(null).when(view).getTag(); assertNull(CarpaccioHelper.removeTag(view, "setText")); }