@Test public void testGetStrategyInsertIntoHoveredDataType() { final Optional<DataType> hoverDataType = Optional.of(mock(DataType.class)); final String uuid = "0000-1111-2222-3333"; when(hoverElement.getAttribute(UUID_ATTR)).thenReturn(uuid); when(dataTypeStore.get(uuid)).thenReturn(hoverDataType.get()); loadReferenceContext(); final DNDDataTypesHandlerShiftStrategy actualShiftStrategy = context.getStrategy(); final DNDDataTypesHandlerShiftStrategy expectedShiftStrategy = INSERT_INTO_HOVERED_DATA_TYPE; assertEquals(expectedShiftStrategy, actualShiftStrategy); }
DNDDataTypesHandlerShiftStrategy getStrategy() { if (getHoveredDataType().isPresent() && hoveredDataTypeIsNotReadOnly()) { return INSERT_INTO_HOVERED_DATA_TYPE; } if (!getPreviousDataType().isPresent()) { return INSERT_TOP_LEVEL_DATA_TYPE_AT_THE_TOP; } final int currentElementLevel = DNDListDOMHelper.Position.getX(currentElement); final int previousElementLevel = DNDListDOMHelper.Position.getX(previousElement); if (currentElementLevel == 0) { return INSERT_TOP_LEVEL_DATA_TYPE; } else if (previousElementLevel < currentElementLevel && previousDataTypeIsNotReadOnly()) { return INSERT_NESTED_DATA_TYPE; } else { return INSERT_SIBLING_DATA_TYPE; } }
DNDDataTypesHandlerContext { DNDDataTypesHandlerShiftStrategy getStrategy() { if (getHoveredDataType().isPresent() && hoveredDataTypeIsNotReadOnly()) { return INSERT_INTO_HOVERED_DATA_TYPE; } if (!getPreviousDataType().isPresent()) { return INSERT_TOP_LEVEL_DATA_TYPE_AT_THE_TOP; } final int currentElementLevel = DNDListDOMHelper.Position.getX(currentElement); final int previousElementLevel = DNDListDOMHelper.Position.getX(previousElement); if (currentElementLevel == 0) { return INSERT_TOP_LEVEL_DATA_TYPE; } else if (previousElementLevel < currentElementLevel && previousDataTypeIsNotReadOnly()) { return INSERT_NESTED_DATA_TYPE; } else { return INSERT_SIBLING_DATA_TYPE; } } }
DNDDataTypesHandlerContext { DNDDataTypesHandlerShiftStrategy getStrategy() { if (getHoveredDataType().isPresent() && hoveredDataTypeIsNotReadOnly()) { return INSERT_INTO_HOVERED_DATA_TYPE; } if (!getPreviousDataType().isPresent()) { return INSERT_TOP_LEVEL_DATA_TYPE_AT_THE_TOP; } final int currentElementLevel = DNDListDOMHelper.Position.getX(currentElement); final int previousElementLevel = DNDListDOMHelper.Position.getX(previousElement); if (currentElementLevel == 0) { return INSERT_TOP_LEVEL_DATA_TYPE; } else if (previousElementLevel < currentElementLevel && previousDataTypeIsNotReadOnly()) { return INSERT_NESTED_DATA_TYPE; } else { return INSERT_SIBLING_DATA_TYPE; } } DNDDataTypesHandlerContext(final DNDDataTypesHandler dndDataTypesHandler,
                               final Element currentElement,
                               final Element hoverElement); }
DNDDataTypesHandlerContext { DNDDataTypesHandlerShiftStrategy getStrategy() { if (getHoveredDataType().isPresent() && hoveredDataTypeIsNotReadOnly()) { return INSERT_INTO_HOVERED_DATA_TYPE; } if (!getPreviousDataType().isPresent()) { return INSERT_TOP_LEVEL_DATA_TYPE_AT_THE_TOP; } final int currentElementLevel = DNDListDOMHelper.Position.getX(currentElement); final int previousElementLevel = DNDListDOMHelper.Position.getX(previousElement); if (currentElementLevel == 0) { return INSERT_TOP_LEVEL_DATA_TYPE; } else if (previousElementLevel < currentElementLevel && previousDataTypeIsNotReadOnly()) { return INSERT_NESTED_DATA_TYPE; } else { return INSERT_SIBLING_DATA_TYPE; } } DNDDataTypesHandlerContext(final DNDDataTypesHandler dndDataTypesHandler,
                               final Element currentElement,
                               final Element hoverElement);  }
DNDDataTypesHandlerContext { DNDDataTypesHandlerShiftStrategy getStrategy() { if (getHoveredDataType().isPresent() && hoveredDataTypeIsNotReadOnly()) { return INSERT_INTO_HOVERED_DATA_TYPE; } if (!getPreviousDataType().isPresent()) { return INSERT_TOP_LEVEL_DATA_TYPE_AT_THE_TOP; } final int currentElementLevel = DNDListDOMHelper.Position.getX(currentElement); final int previousElementLevel = DNDListDOMHelper.Position.getX(previousElement); if (currentElementLevel == 0) { return INSERT_TOP_LEVEL_DATA_TYPE; } else if (previousElementLevel < currentElementLevel && previousDataTypeIsNotReadOnly()) { return INSERT_NESTED_DATA_TYPE; } else { return INSERT_SIBLING_DATA_TYPE; } } DNDDataTypesHandlerContext(final DNDDataTypesHandler dndDataTypesHandler,
                               final Element currentElement,
                               final Element hoverElement);   }