diff --git a/src/test/java/me/goudham/ClipboardUtilsTest.java b/src/test/java/me/goudham/ClipboardUtilsTest.java index cde87fa..4101b04 100644 --- a/src/test/java/me/goudham/ClipboardUtilsTest.java +++ b/src/test/java/me/goudham/ClipboardUtilsTest.java @@ -137,6 +137,20 @@ class ClipboardUtilsTest { verifyNoInteractions(logger); } + @ParameterizedTest + @MethodSource("provideArgumentsForOldClipboardContentsWhenContentIsTransferable") + void successfullyMarshallClipboardContentsIntoOldClipboardContentWhenContentIsTransferable(Object expectedContent, DataFlavor dataFlavor, String expectedString, BufferedImage expectedImage, List expectedFiles) throws IOException, UnsupportedFlavorException { + when(transferableMock.isDataFlavorSupported(dataFlavor)).thenReturn(true); + when(transferableMock.getTransferData(dataFlavor)).thenReturn(expectedContent); + + OldClipboardContent actualOldClipboardContent = sut.getOldClipboardContent(transferableMock); + + assertThat(actualOldClipboardContent.getOldText(), is(expectedString)); + assertThat(actualOldClipboardContent.getOldFiles(), is(expectedFiles)); + assertThat(actualOldClipboardContent.getOldImage(), is(new BufferedImageMatcher(expectedImage))); + verifyNoInteractions(logger); + } + @ParameterizedTest @MethodSource("provideArgumentsForOldClipboardContents") void successfullyMarshallClipboardContentsIntoOldClipboardContent(Object expectedOldContent, String expectedString, BufferedImage expectedImage, List expectedFiles) { @@ -148,6 +162,18 @@ class ClipboardUtilsTest { verifyNoInteractions(logger); } + static Stream provideArgumentsForOldClipboardContentsWhenContentIsTransferable() { + String string = "testString"; + BufferedImage bufferedImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); + List files = List.of(new File("testFile")); + + return Stream.of( + Arguments.of(string, TEXT.getDataFlavor(), string, null, null), + Arguments.of(bufferedImage, IMAGE.getDataFlavor(), null, bufferedImage, null), + Arguments.of(files, FILELIST.getDataFlavor(), null, null, files) + ); + } + static Stream provideArgumentsForOldClipboardContents() { String string = "testString"; BufferedImage bufferedImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);