CarpaccioManager implements MappingManager.MappingManagerCallback { public void registerControllers(Context context, String registerString) { String[] registers = registerString.split(";"); for (String s : registers) { String reg = s.trim().replace(";", ""); if (!reg.isEmpty()) { Object controller = CarpaccioHelper.construct(reg); if (controller == null) controller = CarpaccioHelper.construct("com.github.florent37.carpaccio.controllers." + reg); if (controller == null && context != null) controller = CarpaccioHelper.construct(context.getPackageName() +"." + reg); if (controller != null) registerController(controller); else { CarpaccioLogger.d(TAG, "cannot find controller " + reg); if(displayErrors) throw new CarpaccioException("cannot find controller " + reg); } } } CarpaccioLogger.d(TAG, "registered controllers = " + savedControllers.toString()); } CarpaccioManager(MappingManager mappingManager); void addView(View view); boolean isCarpaccioControlledView(View view); void registerController(Object controller); void registerControllers(Context context, String registerString); void executeActionsOnViews(); void executeActionsOnViews(List<View> views, Object mappedObject); void executeActionsOnView(View view); void executeActionsOnView(View view, Object mappedObject); void callActionOnView(CarpaccioAction action, View view); void mapObject(String name, Object object); Object getMappedObject(String name); void mapList(String mappedName, List list); void appendList(String mappedName, List list); List getMappedList(String name); Object registerAdapter(String mapName, Object adapter); T getAdapter(String mappedName); void addChildViews(View view); Object bindView(View view, String mapName, int position); Object bindView(View view, String mapName); void notifyAdapterDataSetChanded(Object adapter); void findCarpaccioControlledViews(View view); void findCarpaccioControlledViews(View view, List<View> listAddTo);  }
@Test public void testRegisterControllers_multiple() throws Exception { assertTrue(carpaccioManager.registerControllers.isEmpty()); carpaccioManager.registerControllers(null,"java.util.ArrayList;java.util.HashMap;"); assertFalse(carpaccioManager.registerControllers.isEmpty()); assertTrue(carpaccioManager.registerControllers.get(0) instanceof java.util.ArrayList); assertTrue(carpaccioManager.registerControllers.get(1) instanceof java.util.HashMap); }
@Test public void testRegisterControllers_fail() throws Exception { assertTrue(carpaccioManager.registerControllers.isEmpty()); carpaccioManager.registerControllers(null,"java.ttttttiiillll.ArrayList"); assertTrue(carpaccioManager.registerControllers.isEmpty()); }
@Test public void testRegisterControllers_fail_multiple() throws Exception { assertTrue(carpaccioManager.registerControllers.isEmpty()); carpaccioManager.registerControllers(null,"java.ttttttiiillll.ArrayList;java.util.HashMap;"); assertFalse(carpaccioManager.registerControllers.isEmpty()); assertTrue(carpaccioManager.registerControllers.get(0) instanceof java.util.HashMap); }
@Test public void testRegisterControllers_multiple_whiteSpace() throws Exception { assertTrue(carpaccioManager.registerControllers.isEmpty()); carpaccioManager.registerControllers(null," java.util.ArrayList; \n java.util.HashMap; \n "); assertFalse(carpaccioManager.registerControllers.isEmpty()); assertTrue(carpaccioManager.registerControllers.get(0) instanceof java.util.ArrayList); assertTrue(carpaccioManager.registerControllers.get(1) instanceof java.util.HashMap); }
@Test public void testRegisterControllers_multiple_commaSeparator() throws Exception { assertTrue(carpaccioManager.registerControllers.isEmpty()); carpaccioManager.registerControllers(null,"java.util.ArrayList;java.util.HashMap"); assertFalse(carpaccioManager.registerControllers.isEmpty()); assertTrue(carpaccioManager.registerControllers.get(0) instanceof java.util.ArrayList); assertTrue(carpaccioManager.registerControllers.get(1) instanceof java.util.HashMap); }
@Test public void testRegisterControllers() throws Exception { assertTrue(carpaccioManager.registerControllers.isEmpty()); carpaccioManager.registerControllers(null,"java.util.ArrayList"); assertFalse(carpaccioManager.registerControllers.isEmpty()); assertTrue(carpaccioManager.registerControllers.get(0) instanceof java.util.ArrayList); }