@Test
public void testReplaceExistingNonRootView() {

  UIManagerModule uiManager = getUIManagerModule();
  TestMoveDeleteHierarchy hierarchy = createMoveDeleteHierarchy(uiManager);
  int newViewTag = 1234;
  uiManager.createView(
      newViewTag,
      ReactViewManager.REACT_CLASS,
      hierarchy.rootView,
      JavaOnlyMap.of("backgroundColor", Color.RED));
  uiManager.replaceExistingNonRootView(hierarchy.view2, newViewTag);
  uiManager.onBatchComplete();
  executePendingFrameCallbacks();
  assertThat(hierarchy.nativeRootView.getChildCount()).isEqualTo(4);
  assertThat(hierarchy.nativeRootView.getChildAt(2)).isInstanceOf(ReactViewGroup.class);
  ReactViewGroup view = (ReactViewGroup) hierarchy.nativeRootView.getChildAt(2);
  assertThat(view.getBackgroundColor()).isEqualTo(Color.RED);
}