### Question:
CaseManagementShapeView extends SVGShapeViewImpl implements HasSize<SVGShapeViewImpl> { public void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement) { if (original == null || replacement == null || replacement.getParent() == this) { return; } int index = getIndex(original); if (index < 0) { return; } getChildShapes().set(index, replacement); getContainer().getChildNodes().set(getNodeIndex(original.getGroup()), replacement.getGroup()); original.setParent(null); replacement.setParent(this); getLayoutHandler().requestLayout(this); } CaseManagementShapeView(final String name,
                                   final SVGPrimitiveShape svgPrimitive,
                                   final double width,
                                   final double height,
                                   final boolean resizable);  CaseManagementShapeView(final String name,
                                   final SVGPrimitiveShape svgPrimitive,
                                   final double width,
                                   final double height,
                                   final boolean resizable,
                                   final Optional<MultiPath> optDropZone); void setLabel(String shapeLabel); double getWidth(); double getHeight(); void logicallyReplace(final CaseManagementShapeView original, final CaseManagementShapeView replacement); void addShape(final WiresShape shape, final int targetIndex); int getIndex(final WiresShape shape); Optional<MultiPath> getDropZone(); CaseManagementShapeView getGhost(); void setCanvas(CaseManagementCanvas canvas);  }### Answer:
@Test public void checkLogicalReplacementWithOneChild() { final CaseManagementShapeView child = createShapeView("child"); final CaseManagementShapeView replacement = createShapeView("replacement"); shape.add(child); verify(layoutHandler, times(1)).requestLayout(shape); assertEquals(1, shape.getChildShapes().size()); assertEquals(child, shape.getChildShapes().get(0)); assertEquals(shape, child.getParent()); shape.logicallyReplace(child, replacement); assertEquals(1, shape.getChildShapes().size()); assertEquals(replacement, shape.getChildShapes().get(0)); assertEquals(shape, replacement.getParent()); assertNull(child.getParent()); verify(layoutHandler, times(2)).requestLayout(shape); }
@Test public void checkLogicalReplacementWithMultipleChildren() { final CaseManagementShapeView child1 = createShapeView("child1"); final CaseManagementShapeView child2 = createShapeView("child2"); final CaseManagementShapeView replacement = createShapeView("replacement"); shape.add(child1); shape.add(child2); verify(layoutHandler, times(2)).requestLayout(shape); assertEquals(2, shape.getChildShapes().size()); assertEquals(child1, shape.getChildShapes().get(0)); assertEquals(child2, shape.getChildShapes().get(1)); assertEquals(shape, child1.getParent()); assertEquals(shape, child2.getParent()); shape.logicallyReplace(child1, replacement); assertEquals(2, shape.getChildShapes().size()); assertEquals(replacement, shape.getChildShapes().get(0)); assertEquals(child2, shape.getChildShapes().get(1)); assertEquals(shape, replacement.getParent()); assertNull(child1.getParent()); verify(layoutHandler, times(3)).requestLayout(shape); }