private void clearState() { state.getGhost().ifPresent(WiresShapeViewExt::destroy); state.setGhost(Optional.empty()); state.setOriginalIndex(OptionalInt.empty()); state.setOriginalParent(Optional.empty()); }
@Test public void testReset() { control.reset(); verify(ghost, times(1)).removeFromParent(); verify(parent, times(1)).addShape(eq(shape), eq(0)); verify(state, times(1)).setGhost(Optional.empty()); verify(state, times(1)).setOriginalParent(Optional.empty()); verify(state, times(1)).setOriginalIndex(OptionalInt.empty()); }
@Test public void testClear() { control.clear(); verify(ghost, times(1)).destroy(); verify(state, times(1)).setGhost(Optional.empty()); verify(state, times(1)).setOriginalParent(Optional.empty()); verify(state, times(1)).setOriginalIndex(OptionalInt.empty()); }
@Test public void testOnMoveStart() { final double x = 15.5d; final double y = 21.63d; control.onMoveStart(x, y); verify(containmentControl, times(1)).onMoveStart(eq(x), eq(y)); verify(state, times(1)).setGhost(eq(Optional.of(ghost))); verify(state, times(1)).setOriginalIndex(eq(OptionalInt.of(0))); verify(state, times(1)).setOriginalParent(eq(Optional.of(parent))); verify(parent, times(1)).logicallyReplace(eq(shape), eq(ghost)); }
@Test public void testExecuteAndRestoreGhost() { control.execute(); verify(parent, never()).logicallyReplace(eq(ghost), eq(shape)); verify(ghost, times(1)).destroy(); verify(state, times(1)).setGhost(Optional.empty()); verify(state, times(1)).setOriginalParent(Optional.empty()); verify(state, times(1)).setOriginalIndex(OptionalInt.empty()); verify(layer, times(1)).batch(); }
@Test public void testOnMoveStartButNoCMShape() { final WiresShape aShape = mock(WiresShape.class); when(containmentControl.getShape()).thenReturn(aShape); final double x = 15.5d; final double y = 21.63d; control.onMoveStart(x, y); verify(containmentControl, times(1)).onMoveStart(eq(x), eq(y)); verify(state, times(1)).setGhost(eq(Optional.empty())); verify(state, times(1)).setOriginalIndex(eq(OptionalInt.empty())); verify(state, times(1)).setOriginalParent(eq(Optional.empty())); verify(parent, never()).logicallyReplace(any(CaseManagementShapeView.class), any(CaseManagementShapeView.class)); }
@Override public void onMoveStart(double x, double y) { containmentControl.onMoveStart(x, y); if (!(getShape() instanceof CaseManagementShapeView)) { state.setGhost(Optional.empty()); state.setOriginalIndex(OptionalInt.empty()); state.setOriginalParent(Optional.empty()); return; } state.setOriginalParent(Optional.ofNullable(getParent())); state.setOriginalIndex(getShapeIndex()); state.setGhost(Optional.ofNullable(((CaseManagementShapeView) getShape()).getGhost())); final WiresParentPickerControl.Index index = containmentControl.getParentPickerControl().getIndex(); index.clear(); if (state.getGhost().isPresent()) { index.exclude(state.getGhost().get()); } if ((getParent() instanceof CaseManagementShapeView)) { ((CaseManagementShapeView) getParent()).logicallyReplace((CaseManagementShapeView) getShape(), state.getGhost().get()); } }