Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare classes, not classnames in tests #9014

Merged
merged 8 commits into from
Jul 12, 2024
2 changes: 1 addition & 1 deletion src/test/java/edu/harvard/iq/dataverse/api/SwordIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ public void testCreateAndDeleteDatasetInRoot() {
assertNull(attemptToGetFileId);
} catch (Exception ex) {
System.out.println("We expect an exception here because we can no longer find the file because deleted it: " + ex);
assertTrue(ex.getClass().getName().equals(ArrayIndexOutOfBoundsException.class.getName()));
assertTrue(ex instanceof ArrayIndexOutOfBoundsException);
}

String newTitle = "A New Hope";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ public class FileDataProviderFactoryTest {
public void should_return_FolderDataProvider_when_parameter_is_path() {
FileDataProvider result = target.getFileDataProvider(Path.of(UUID.randomUUID().toString()));

MatcherAssert.assertThat(result.getClass().getName(), Matchers.is(FolderDataProvider.class.getName()));
MatcherAssert.assertThat("should return FolderDataProvider when parameter is path", result instanceof FolderDataProvider);
}

@Test
public void should_return_ZipFileDataProvider_when_parameter_is_file() throws IOException {
FileDataProvider result = target.getFileDataProvider(Path.of(FIXTURE_DIRECTORY, "FileDataProviderFactoryTest.zip").toFile());

MatcherAssert.assertThat(result.getClass().getName(), Matchers.is(ZipFileDataProvider.class.getName()));
MatcherAssert.assertThat("should return ZipFileDataProvider when parameter is file", result instanceof ZipFileDataProvider);
}

@Test
public void should_return_DataFileDataProvider_when_parameter_is_datafiles() {
FileDataProvider result = target.getFileDataProvider("test-name", Collections.emptyList());

MatcherAssert.assertThat(result.getClass().getName(), Matchers.is(DataFileDataProvider.class.getName()));
MatcherAssert.assertThat("should return DataFileDataProvider when parameter is datafiles", result instanceof DataFileDataProvider);
}

}
Loading