Add another test

MYC-Refactor
Hammy 3 years ago
parent 3f95739795
commit 25aff3178a

@ -137,6 +137,20 @@ class ClipboardUtilsTest {
verifyNoInteractions(logger);
}
@ParameterizedTest
@MethodSource("provideArgumentsForOldClipboardContentsWhenContentIsTransferable")
void successfullyMarshallClipboardContentsIntoOldClipboardContentWhenContentIsTransferable(Object expectedContent, DataFlavor dataFlavor, String expectedString, BufferedImage expectedImage, List<File> 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<File> expectedFiles) {
@ -148,6 +162,18 @@ class ClipboardUtilsTest {
verifyNoInteractions(logger);
}
static Stream<Arguments> provideArgumentsForOldClipboardContentsWhenContentIsTransferable() {
String string = "testString";
BufferedImage bufferedImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
List<File> 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<Arguments> provideArgumentsForOldClipboardContents() {
String string = "testString";
BufferedImage bufferedImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);

Loading…
Cancel
Save