@Test public void testThatCompositeReturnsASumOfNativeModules() { CompositeReactPackage composite = new CompositeReactPackage(packageNo1, packageNo2); NativeModule moduleNo1 = mock(NativeModule.class); when(moduleNo1.getName()).thenReturn("ModuleNo1"); final String sameModuleName = "SameModuleName"; NativeModule moduleNo2 = mock(NativeModule.class); when(moduleNo2.getName()).thenReturn(sameModuleName); NativeModule moduleNo3 = mock(NativeModule.class); when(moduleNo3.getName()).thenReturn(sameModuleName); NativeModule moduleNo4 = mock(NativeModule.class); when(moduleNo4.getName()).thenReturn("ModuleNo4"); when(packageNo1.createNativeModules(reactContext)).thenReturn( Arrays.asList(new NativeModule[]{moduleNo1, moduleNo2})); when(packageNo2.createNativeModules(reactContext)).thenReturn( Arrays.asList(new NativeModule[]{moduleNo3, moduleNo4})); List<NativeModule> compositeModules = composite.createNativeModules(reactContext); Set<NativeModule> expected = new HashSet<>( Arrays.asList(new NativeModule[]{moduleNo1, moduleNo3, moduleNo4})); Set<NativeModule> actual = new HashSet<>(compositeModules); assertEquals(expected, actual); }
@Override public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { final Map<String, NativeModule> moduleMap = new HashMap<>(); for (ReactPackage reactPackage: mChildReactPackages) { for (NativeModule nativeModule: reactPackage.createNativeModules(reactContext)) { moduleMap.put(nativeModule.getName(), nativeModule); } } return new ArrayList(moduleMap.values()); }
CompositeReactPackage extends ReactInstancePackage { @Override public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { final Map<String, NativeModule> moduleMap = new HashMap<>(); for (ReactPackage reactPackage: mChildReactPackages) { for (NativeModule nativeModule: reactPackage.createNativeModules(reactContext)) { moduleMap.put(nativeModule.getName(), nativeModule); } } return new ArrayList(moduleMap.values()); } }
CompositeReactPackage extends ReactInstancePackage { @Override public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { final Map<String, NativeModule> moduleMap = new HashMap<>(); for (ReactPackage reactPackage: mChildReactPackages) { for (NativeModule nativeModule: reactPackage.createNativeModules(reactContext)) { moduleMap.put(nativeModule.getName(), nativeModule); } } return new ArrayList(moduleMap.values()); } CompositeReactPackage(ReactPackage arg1, ReactPackage arg2, ReactPackage... args); }
CompositeReactPackage extends ReactInstancePackage { @Override public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { final Map<String, NativeModule> moduleMap = new HashMap<>(); for (ReactPackage reactPackage: mChildReactPackages) { for (NativeModule nativeModule: reactPackage.createNativeModules(reactContext)) { moduleMap.put(nativeModule.getName(), nativeModule); } } return new ArrayList(moduleMap.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<NativeModule> createNativeModules(ReactApplicationContext reactContext) { final Map<String, NativeModule> moduleMap = new HashMap<>(); for (ReactPackage reactPackage: mChildReactPackages) { for (NativeModule nativeModule: reactPackage.createNativeModules(reactContext)) { moduleMap.put(nativeModule.getName(), nativeModule); } } return new ArrayList(moduleMap.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);  }