@Test public void testThatCompositeReturnsASumOfViewManagers() { CompositeReactPackage composite = new CompositeReactPackage(packageNo1, packageNo2); ViewManager managerNo1 = mock(ViewManager.class); when(managerNo1.getName()).thenReturn("ManagerNo1"); final String sameModuleName = "SameModuleName"; ViewManager managerNo2 = mock(ViewManager.class); when(managerNo2.getName()).thenReturn(sameModuleName); ViewManager managerNo3 = mock(ViewManager.class); when(managerNo3.getName()).thenReturn(sameModuleName); ViewManager managerNo4 = mock(ViewManager.class); when(managerNo4.getName()).thenReturn("ManagerNo4"); when(packageNo1.createViewManagers(reactContext)).thenReturn( Arrays.asList(new ViewManager[]{managerNo1, managerNo2})); when(packageNo2.createViewManagers(reactContext)).thenReturn( Arrays.asList(new ViewManager[]{managerNo3, managerNo4})); List<ViewManager> compositeModules = composite.createViewManagers(reactContext); Set<ViewManager> expected = new HashSet<>( Arrays.asList(new ViewManager[]{managerNo1, managerNo3, managerNo4}) ); Set<ViewManager> actual = new HashSet<>(compositeModules); assertEquals(expected, actual); }
@Override public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { final Map<String, ViewManager> viewManagerMap = new HashMap<>(); for (ReactPackage reactPackage: mChildReactPackages) { for (ViewManager viewManager: reactPackage.createViewManagers(reactContext)) { viewManagerMap.put(viewManager.getName(), viewManager); } } return new ArrayList(viewManagerMap.values()); }
CompositeReactPackage extends ReactInstancePackage { @Override public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { final Map<String, ViewManager> viewManagerMap = new HashMap<>(); for (ReactPackage reactPackage: mChildReactPackages) { for (ViewManager viewManager: reactPackage.createViewManagers(reactContext)) { viewManagerMap.put(viewManager.getName(), viewManager); } } return new ArrayList(viewManagerMap.values()); } }
CompositeReactPackage extends ReactInstancePackage { @Override public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { final Map<String, ViewManager> viewManagerMap = new HashMap<>(); for (ReactPackage reactPackage: mChildReactPackages) { for (ViewManager viewManager: reactPackage.createViewManagers(reactContext)) { viewManagerMap.put(viewManager.getName(), viewManager); } } return new ArrayList(viewManagerMap.values()); } CompositeReactPackage(ReactPackage arg1, ReactPackage arg2, ReactPackage... args); }
CompositeReactPackage extends ReactInstancePackage { @Override public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { final Map<String, ViewManager> viewManagerMap = new HashMap<>(); for (ReactPackage reactPackage: mChildReactPackages) { for (ViewManager viewManager: reactPackage.createViewManagers(reactContext)) { viewManagerMap.put(viewManager.getName(), viewManager); } } return new ArrayList(viewManagerMap.values()); } CompositeReactPackage(ReactPackage arg1, ReactPackage arg2, ReactPackage... args); @Override List<NativeModule> createNativeModules(ReactApplicationContext reactContext); @Override List<NativeModule> createNativeModules(
      ReactApplicationContext reactContext,
      ReactInstanceManager reactInstanceManager); @Override List<ViewManager> createViewManagers(ReactApplicationContext reactContext); }
CompositeReactPackage extends ReactInstancePackage { @Override public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { final Map<String, ViewManager> viewManagerMap = new HashMap<>(); for (ReactPackage reactPackage: mChildReactPackages) { for (ViewManager viewManager: reactPackage.createViewManagers(reactContext)) { viewManagerMap.put(viewManager.getName(), viewManager); } } return new ArrayList(viewManagerMap.values()); } CompositeReactPackage(ReactPackage arg1, ReactPackage arg2, ReactPackage... args); @Override List<NativeModule> createNativeModules(ReactApplicationContext reactContext); @Override List<NativeModule> createNativeModules(
      ReactApplicationContext reactContext,
      ReactInstanceManager reactInstanceManager); @Override List<ViewManager> createViewManagers(ReactApplicationContext reactContext);  }