diff --git a/pdfsam-ui-components/src/test/java/org/pdfsam/ui/components/selection/multiple/MockFileExplorer.java b/pdfsam-ui-components/src/test/java/org/pdfsam/ui/components/selection/multiple/MockFileExplorer.java index c0f48ad4..d763594d 100644 --- a/pdfsam-ui-components/src/test/java/org/pdfsam/ui/components/selection/multiple/MockFileExplorer.java +++ b/pdfsam-ui-components/src/test/java/org/pdfsam/ui/components/selection/multiple/MockFileExplorer.java @@ -18,14 +18,22 @@ */ package org.pdfsam.ui.components.selection.multiple; -import java.io.*; -import java.net.*; -import java.nio.file.*; -import java.util.Collections; -import javafx.scene.control.*; -import javafx.scene.input.*; +import javafx.scene.control.ListCell; +import javafx.scene.control.ListView; +import javafx.scene.input.ClipboardContent; +import javafx.scene.input.DataFormat; +import javafx.scene.input.DragEvent; +import javafx.scene.input.MouseEvent; +import javafx.scene.input.TransferMode; import javafx.scene.layout.VBox; +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Collections; + class MockFileExplorer extends VBox { MockFileExplorer(Path tempFolder) throws URISyntaxException, IOException { @@ -36,10 +44,8 @@ class MockFileExplorer extends VBox { fileList.setOnDragDetected(event -> onDragDetected(event, fileList)); fileList.setOnDragOver(this::onDragOver); - var pdfs = new File[]{ - Files.createFile(tempFolder.resolve("1.pdf")).toFile(), - Files.createFile(tempFolder.resolve("2.pdf")).toFile() - }; + var pdfs = new File[] { Files.createFile(tempFolder.resolve("1.pdf")).toFile(), + Files.createFile(tempFolder.resolve("2.pdf")).toFile() }; fileList.getItems().addAll(pdfs); @@ -48,12 +54,12 @@ class MockFileExplorer extends VBox { private void onDragDetected(MouseEvent event, ListView fileList) { var selectedIndex = fileList.getSelectionModel().getSelectedIndex(); - + if (selectedIndex >= 0) { var file = fileList.getItems().get(selectedIndex); var dragboard = fileList.startDragAndDrop(TransferMode.COPY); var content = new ClipboardContent(); - + content.put(DataFormat.FILES, Collections.singletonList(file)); dragboard.setContent(content); @@ -63,7 +69,7 @@ private void onDragDetected(MouseEvent event, ListView fileList) { private void onDragOver(DragEvent event) { var dragboard = event.getDragboard(); - + if (dragboard.hasFiles()) { event.acceptTransferModes(TransferMode.COPY); } diff --git a/pdfsam-ui-components/src/test/java/org/pdfsam/ui/components/selection/multiple/SelectionTableTest.java b/pdfsam-ui-components/src/test/java/org/pdfsam/ui/components/selection/multiple/SelectionTableTest.java index 6ea23f46..e6c3be37 100644 --- a/pdfsam-ui-components/src/test/java/org/pdfsam/ui/components/selection/multiple/SelectionTableTest.java +++ b/pdfsam-ui-components/src/test/java/org/pdfsam/ui/components/selection/multiple/SelectionTableTest.java @@ -18,8 +18,11 @@ */ package org.pdfsam.ui.components.selection.multiple; +import javafx.application.Platform; import javafx.collections.FXCollections; import javafx.scene.Scene; +import javafx.scene.control.ListCell; +import javafx.scene.control.ListView; import javafx.scene.input.Clipboard; import javafx.scene.input.DataFormat; import javafx.scene.input.KeyCode; @@ -61,13 +64,12 @@ import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.*; -import javafx.application.Platform; -import javafx.scene.*; -import javafx.scene.control.*; -import org.pdfsam.model.ui.dnd.FilesDroppedEvent; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; -import static java.util.stream.Collectors.joining; import static org.apache.commons.lang3.StringUtils.isBlank; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -109,8 +111,8 @@ public static void setUp() { @Start public void start(Stage stage) throws Exception { victim = new SelectionTable(MODULE, true, true, - new SelectionTableColumn[]{new LoadingColumn(MODULE), FileColumn.NAME, LongColumn.SIZE, - IntColumn.PAGES, LongColumn.LAST_MODIFIED, new PageRangesColumn()}); + new SelectionTableColumn[] { new LoadingColumn(MODULE), FileColumn.NAME, LongColumn.SIZE, + IntColumn.PAGES, LongColumn.LAST_MODIFIED, new PageRangesColumn() }); victim.setId("victim"); firstItem = populate(); Scene scene = new Scene(victim); @@ -413,12 +415,8 @@ public void dropsOnFirstIndex() throws Exception { var listView = robot.lookup("#file-list").queryAs(ListView.class); var cells = listView.lookupAll(".list-cell"); - var cell = cells.stream() - .filter(ListCell.class::isInstance) - .map(ListCell.class::cast) - .filter(c -> Objects.nonNull(c.getItem())) - .findFirst() - .orElseThrow(); + var cell = cells.stream().filter(ListCell.class::isInstance).map(ListCell.class::cast) + .filter(c -> Objects.nonNull(c.getItem())).findFirst().orElseThrow(); robot.drag(cell).dropTo("temp.pdf"); @@ -434,10 +432,7 @@ public void dropsOnFirstIndex() throws Exception { WaitForAsyncUtils.waitForFxEvents(); - var actualDescriptor = victim.getItems() - .stream() - .map(SelectionTableRowData::descriptor) - .findFirst() + var actualDescriptor = victim.getItems().stream().map(SelectionTableRowData::descriptor).findFirst() .orElseThrow(); assertThat(actualDescriptor).isEqualTo(descriptor);