@Test
public void testThatCompositeReturnsASumOfNativeModules() {

  // Given
  CompositeReactPackage composite = new CompositeReactPackage(packageNo1, packageNo2);
  NativeModule moduleNo1 = mock(NativeModule.class);
  when(moduleNo1.getName()).thenReturn("ModuleNo1");
  // module2 and module3 will share same name, composite should return only the latter one
  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}));
  // When
  List<NativeModule> compositeModules = composite.createNativeModules(reactContext);
  // Then
  // Wrapping lists into sets to be order-independent.
  // Note that there should be no module2 returned.
  Set<NativeModule> expected = new HashSet<>(
      Arrays.asList(new NativeModule[]{moduleNo1, moduleNo3, moduleNo4}));
  Set<NativeModule> actual = new HashSet<>(compositeModules);
  assertEquals(expected, actual);
}