From 245248c6f8c91a2cf66a4c7c62204a1bcaba3329 Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Fri, 18 Aug 2023 16:15:56 +0200 Subject: [PATCH 01/17] build(test): remove JUnit 4 from POM, upgrade to JUnit 5.10 --- modules/dataverse-parent/pom.xml | 6 ++---- pom.xml | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/modules/dataverse-parent/pom.xml b/modules/dataverse-parent/pom.xml index 7c83ac39736..eaa79b76355 100644 --- a/modules/dataverse-parent/pom.xml +++ b/modules/dataverse-parent/pom.xml @@ -170,10 +170,8 @@ 1.15.0 2.10.1 - - 4.13.1 - 5.7.0 - ${junit.jupiter.version} + + 5.10.0 2.28.2 9.3 diff --git a/pom.xml b/pom.xml index df8daa7e019..eee3d956f38 100644 --- a/pom.xml +++ b/pom.xml @@ -377,6 +377,12 @@ ezid 1.0.0 jar + + + junit + junit + + org.jsoup @@ -542,18 +548,6 @@ ${junit.jupiter.version} test - - junit - junit - ${junit.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit.vintage.version} - test - org.hamcrest hamcrest-library @@ -594,6 +588,12 @@ org.testcontainers testcontainers test + + + junit + junit + + org.testcontainers From 2ca734eeabb6761b18c4542a45bca62d666da6c7 Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Fri, 18 Aug 2023 16:40:02 +0200 Subject: [PATCH 02/17] build(test): migrate all imports from JUnit 4 to JUnit 5 #9782 --- .../AuxiliaryFileServiceBeanTest.java | 7 +- .../edu/harvard/iq/dataverse/CartTest.java | 14 +- .../DataFileCategoryServiceBeanTest.java | 8 +- .../iq/dataverse/DataFileServiceBeanTest.java | 7 +- .../iq/dataverse/DatasetAuthorTest.java | 12 +- .../iq/dataverse/DatasetFieldTypeTest.java | 14 +- .../dataverse/DatasetFieldValidatorTest.java | 13 +- .../edu/harvard/iq/dataverse/DatasetTest.java | 9 +- .../DatasetVersionServiceBeanTest.java | 8 +- .../DataverseMetadataBlockFacetTest.java | 2 +- .../harvard/iq/dataverse/DataverseTest.java | 4 +- .../EditDataFilesPageHelperTest.java | 6 +- .../iq/dataverse/ExternalIdentifierTest.java | 8 +- .../FileDirectoryNameValidatorTest.java | 13 +- .../harvard/iq/dataverse/GlobalIdTest.java | 13 +- .../iq/dataverse/MetadataBlockTest.java | 2 +- .../iq/dataverse/PermissionsWrapperTest.java | 8 +- .../PersistentIdentifierServiceBeanTest.java | 11 +- .../iq/dataverse/RoleAssignmentTest.java | 10 +- .../actionlogging/ActionLogRecordTest.java | 10 +- .../iq/dataverse/api/AbstractApiBeanTest.java | 11 +- .../harvard/iq/dataverse/api/AccessIT.java | 17 +- .../edu/harvard/iq/dataverse/api/AdminIT.java | 11 +- .../iq/dataverse/api/AuxiliaryFilesIT.java | 8 +- .../edu/harvard/iq/dataverse/api/BagIT.java | 6 +- .../iq/dataverse/api/BatchImportIT.java | 4 +- .../iq/dataverse/api/BuiltinUsersIT.java | 8 +- .../iq/dataverse/api/ConfirmEmailIT.java | 6 +- .../harvard/iq/dataverse/api/DataCiteIT.java | 4 +- .../iq/dataverse/api/DataRetrieverApiIT.java | 4 +- .../api/DatasetFieldServiceApiTest.java | 4 +- .../harvard/iq/dataverse/api/DatasetsIT.java | 21 +- .../iq/dataverse/api/DatasetsTest.java | 6 +- .../iq/dataverse/api/DataversesIT.java | 15 +- .../iq/dataverse/api/DataversesTest.java | 9 +- .../iq/dataverse/api/DeactivateUsersIT.java | 4 +- .../iq/dataverse/api/DeleteUsersIT.java | 6 +- .../iq/dataverse/api/DownloadFilesIT.java | 8 +- .../api/DownloadInstanceWriterTest.java | 8 +- .../iq/dataverse/api/DuplicateFilesIT.java | 4 +- .../harvard/iq/dataverse/api/EditDDIIT.java | 13 +- .../iq/dataverse/api/ExternalToolsIT.java | 8 +- .../iq/dataverse/api/FeedbackApiIT.java | 4 +- .../iq/dataverse/api/FileMetadataIT.java | 15 +- .../iq/dataverse/api/FileTypeDetectionIT.java | 4 +- .../edu/harvard/iq/dataverse/api/FilesIT.java | 12 +- .../edu/harvard/iq/dataverse/api/FitsIT.java | 6 +- .../iq/dataverse/api/HarvestingClientsIT.java | 10 +- .../iq/dataverse/api/HarvestingServerIT.java | 17 +- .../iq/dataverse/api/InReviewWorkflowIT.java | 7 +- .../edu/harvard/iq/dataverse/api/IndexIT.java | 10 +- .../edu/harvard/iq/dataverse/api/InfoIT.java | 3 +- .../iq/dataverse/api/InvalidCharactersIT.java | 4 +- .../harvard/iq/dataverse/api/IpGroupsIT.java | 6 +- .../harvard/iq/dataverse/api/LazyRefTest.java | 3 +- .../harvard/iq/dataverse/api/LicensesIT.java | 13 +- .../edu/harvard/iq/dataverse/api/LinkIT.java | 4 +- .../harvard/iq/dataverse/api/LogoutIT.java | 2 +- .../iq/dataverse/api/MakeDataCountApiIT.java | 6 +- .../harvard/iq/dataverse/api/MetricsIT.java | 11 +- .../edu/harvard/iq/dataverse/api/MoveIT.java | 7 +- .../harvard/iq/dataverse/api/NetcdfIT.java | 4 +- .../iq/dataverse/api/NotificationsIT.java | 4 +- .../edu/harvard/iq/dataverse/api/PidsIT.java | 6 +- .../edu/harvard/iq/dataverse/api/ProvIT.java | 6 +- .../iq/dataverse/api/RemoteStoreIT.java | 4 +- .../edu/harvard/iq/dataverse/api/RolesIT.java | 8 +- .../harvard/iq/dataverse/api/S3AccessIT.java | 9 +- .../harvard/iq/dataverse/api/SearchIT.java | 17 +- .../api/SignedUrlAuthMechanismIT.java | 2 +- .../iq/dataverse/api/SignpostingIT.java | 6 +- .../harvard/iq/dataverse/api/SiteMapIT.java | 4 +- .../iq/dataverse/api/StorageSitesIT.java | 4 +- .../edu/harvard/iq/dataverse/api/SwordIT.java | 19 +- .../harvard/iq/dataverse/api/TabularIT.java | 10 +- .../iq/dataverse/api/ThumbnailsIT.java | 2 +- .../edu/harvard/iq/dataverse/api/UsersIT.java | 8 +- .../edu/harvard/iq/dataverse/api/UtilIT.java | 12 +- .../iq/dataverse/api/dto/FieldDTOTest.java | 12 +- .../api/filesystem/FileRecordJobIT.java | 19 +- .../imports/ImportGenericServiceBeanTest.java | 9 +- .../dataverse/authorization/AuthUtilTest.java | 14 +- .../AuthenticatedUserDisplayInfoTest.java | 4 +- .../groups/GroupServiceBeanTest.java | 5 +- .../authorization/groups/GroupUtilTest.java | 4 +- .../impl/explicit/ExplicitGroupTest.java | 8 +- .../groups/impl/ipaddress/IpGroupTest.java | 5 +- .../impl/ipaddress/ip/IPv4AddressTest.java | 6 +- .../impl/ipaddress/ip/IPv6AddressTest.java | 9 +- .../impl/ipaddress/ip/IpAddressRangeTest.java | 4 +- .../impl/ipaddress/ip/IpAddressTest.java | 5 +- .../BuiltinAuthenticationProviderTest.java | 6 +- .../builtin/DataverseUserPageTest.java | 2 +- ...uth2AuthenticationProviderFactoryTest.java | 4 +- .../oauth2/impl/GitHubOAuth2APTest.java | 4 +- .../oauth2/impl/GoogleOAuth2APTest.java | 4 +- .../providers/shib/ShibUtilTest.java | 13 +- .../users/AuthenticatedUserTest.java | 11 +- .../confirmemail/ConfirmEmailDataTest.java | 10 +- .../confirmemail/ConfirmEmailUtilTest.java | 17 +- .../dataaccess/FileAccessIOTest.java | 8 +- .../dataverse/dataaccess/StorageIOTest.java | 5 +- .../dataaccess/SwiftAccessIOTest.java | 9 +- .../DataCaptureModuleServiceBeanIT.java | 8 +- .../DataCaptureModuleUtilTest.java | 6 +- .../iq/dataverse/dataset/DatasetUtilTest.java | 5 +- .../DuplicateFileCheckerTest.java | 10 +- .../OptionalFileParamsTest.java | 13 +- .../VariableMetadataDDIParserTest.java | 4 +- .../dataverse/DataverseUtilTest.java | 8 +- .../iq/dataverse/engine/PermissionTest.java | 5 +- .../impl/AbstractDatasetCommandTest.java | 6 +- .../impl/CreateDatasetVersionCommandTest.java | 8 +- .../impl/CreateDataverseCommandTest.java | 11 +- .../impl/CreatePrivateUrlCommandTest.java | 13 +- .../command/impl/CreateRoleCommandTest.java | 8 +- .../impl/DRSSubmitToArchiveCommandTest.java | 5 +- .../impl/DeletePrivateUrlCommandTest.java | 9 +- ...estPublishedDatasetVersionCommandTest.java | 5 +- .../impl/GetPrivateUrlCommandTest.java | 13 +- .../impl/ListMetadataBlocksCommandTest.java | 4 +- .../command/impl/MoveDatasetCommandTest.java | 14 +- .../impl/MoveDataverseCommandTest.java | 12 +- .../impl/RequestRsyncScriptCommandTest.java | 13 +- .../command/impl/RestrictFileCommandTest.java | 16 +- .../ReturnDatasetToAuthorCommandTest.java | 10 +- .../SubmitDatasetForReviewCommandTest.java | 8 +- .../UpdateDatasetThumbnailCommandTest.java | 13 +- ...dateMetadataBlockFacetRootCommandTest.java | 4 +- .../UpdateMetadataBlockFacetsCommandTest.java | 5 +- .../impl/UpdatePermissionRootCommandTest.java | 9 +- .../export/OpenAireExporterTest.java | 4 +- .../export/SchemaDotOrgExporterTest.java | 4 +- .../ExternalToolServiceBeanTest.java | 7 +- .../externaltools/ExternalToolTest.java | 5 +- .../dataverse/feedback/FeedbackUtilTest.java | 8 +- .../dataverse/ingest/IngestFrequencyTest.java | 6 +- .../iq/dataverse/ingest/IngestUtilTest.java | 8 +- .../ingest/IngestableDataCheckerTest.java | 21 +- .../NetcdfFileMetadataExtractorTest.java | 3 +- .../impl/plugins/csv/CSVFileReaderTest.java | 5 +- .../impl/plugins/dta/DTAFileReaderTest.java | 5 +- .../impl/plugins/dta/DataReaderTest.java | 4 +- .../plugins/dta/NewDTAFileReaderTest.java | 11 +- .../locality/StorageSiteUtilTest.java | 5 +- .../MakeDataCountLoggingServiceBeanTest.java | 8 +- .../makedatacount/MakeDataCountUtilTest.java | 5 +- .../iq/dataverse/metrics/MetricsUtilTest.java | 16 +- .../iq/dataverse/mydata/MyDataUtilTest.java | 27 +- .../mydata/SolrQueryFormatterTest.java | 16 +- .../passwordreset/PasswordResetDataTest.java | 13 +- .../passwordreset/PasswordValidatorTest.java | 12 +- .../dataverse/pidproviders/PidUtilTest.java | 12 +- .../privateurl/PrivateUrlUtilTest.java | 2 +- .../provenance/ProvInvestigatorTest.java | 11 +- ...sitoryStorageAbstractionLayerUtilTest.java | 4 +- .../iq/dataverse/search/IndexUtilTest.java | 14 +- .../search/SearchFilesServiceBeanTest.java | 4 +- .../search/SearchIncludeFragmentTest.java | 2 +- .../search/SolrSearchResultTest.java | 10 +- .../iq/dataverse/search/SortByTest.java | 12 +- .../iq/dataverse/sitemap/SiteMapUtilTest.java | 8 +- .../dataverse/userdata/UserListMakerTest.java | 2 +- .../harvard/iq/dataverse/util/BitSetTest.java | 13 +- .../iq/dataverse/util/BundleUtilTest.java | 10 +- .../util/FileSortFieldAndOrderTest.java | 4 +- .../iq/dataverse/util/FileUtilTest.java | 35 +-- .../iq/dataverse/util/FirstNameTest.java | 6 +- .../iq/dataverse/util/JhoveFileTypeTest.java | 8 +- .../iq/dataverse/util/JsfHelperTest.java | 20 +- .../iq/dataverse/util/LruCacheTest.java | 9 +- .../iq/dataverse/util/MailUtilTest.java | 4 +- .../iq/dataverse/util/OrganizationsTest.java | 6 +- .../dataverse/util/PersonOrOrgUtilTest.java | 6 +- .../iq/dataverse/util/StringUtilTest.java | 260 +++++------------- .../iq/dataverse/util/UrlSignerUtilTest.java | 6 +- .../util/bagit/BagChecksumTypeTest.java | 2 +- .../util/bagit/BagValidationTest.java | 2 +- .../util/bagit/BagValidatorTest.java | 4 +- .../bagit/FileChecksumValidationJobTest.java | 2 +- .../util/bagit/ManifestReaderTest.java | 2 +- .../bagit/data/DataFileDataProviderTest.java | 2 +- .../data/FileDataProviderFactoryTest.java | 2 +- .../bagit/data/FolderDataProviderTest.java | 2 +- .../bagit/data/ZipFileDataProviderTest.java | 2 +- .../file/BagItFileHandlerFactoryTest.java | 6 +- .../BagItFileHandlerPostProcessorTest.java | 2 +- .../util/file/BagItFileHandlerTest.java | 4 +- .../util/file/CreateDataFileResultTest.java | 2 +- .../util/json/DatasetVersionDTOTest.java | 12 +- .../dataverse/util/json/JsonParserTest.java | 15 +- .../dataverse/util/json/JsonPrinterTest.java | 9 +- .../iq/dataverse/util/json/JsonUtilTest.java | 4 +- .../util/shapefile/ShapefileHandlerTest.java | 12 +- .../iq/dataverse/util/xml/XmlPrinterTest.java | 4 +- .../dataverse/util/xml/XmlValidatorTest.java | 13 +- .../validation/PasswordValidatorUtilTest.java | 24 +- 197 files changed, 870 insertions(+), 993 deletions(-) diff --git a/src/test/java/edu/harvard/iq/dataverse/AuxiliaryFileServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/AuxiliaryFileServiceBeanTest.java index f04a9e50352..31d7793eac9 100644 --- a/src/test/java/edu/harvard/iq/dataverse/AuxiliaryFileServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/AuxiliaryFileServiceBeanTest.java @@ -3,12 +3,11 @@ import java.util.Arrays; import java.util.List; import jakarta.persistence.EntityManager; -import jakarta.persistence.Query; import jakarta.persistence.TypedQuery; -import static org.junit.Assert.assertEquals; -import org.junit.Test; -import org.junit.Before; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentMatchers; diff --git a/src/test/java/edu/harvard/iq/dataverse/CartTest.java b/src/test/java/edu/harvard/iq/dataverse/CartTest.java index 7b7ea3331a9..6b44c830ca6 100644 --- a/src/test/java/edu/harvard/iq/dataverse/CartTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/CartTest.java @@ -1,15 +1,15 @@ package edu.harvard.iq.dataverse; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.util.List; import java.util.Map.Entry; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class CartTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/DataFileCategoryServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/DataFileCategoryServiceBeanTest.java index edeeea288bf..6e6d176194b 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DataFileCategoryServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DataFileCategoryServiceBeanTest.java @@ -4,12 +4,14 @@ import edu.harvard.iq.dataverse.util.BundleUtil; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Test; -import org.junit.runner.RunWith; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import java.util.Arrays; import java.util.List; diff --git a/src/test/java/edu/harvard/iq/dataverse/DataFileServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/DataFileServiceBeanTest.java index 136916cf449..269668b19d7 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DataFileServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DataFileServiceBeanTest.java @@ -1,8 +1,9 @@ package edu.harvard.iq.dataverse; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** * Test that the DataFileServiceBean classifies DataFiles correctly. diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetAuthorTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetAuthorTest.java index fddb95eda9e..78dacf08166 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DatasetAuthorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DatasetAuthorTest.java @@ -1,16 +1,10 @@ package edu.harvard.iq.dataverse; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; -import java.util.Arrays; -import java.util.Collection; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; - -@RunWith(Parameterized.class) public class DatasetAuthorTest { public String idType; diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetFieldTypeTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetFieldTypeTest.java index 5538ad9c11f..ca734eb8635 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DatasetFieldTypeTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DatasetFieldTypeTest.java @@ -6,13 +6,13 @@ package edu.harvard.iq.dataverse; import edu.harvard.iq.dataverse.search.SolrField; -import jakarta.faces.model.SelectItem; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetFieldValidatorTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetFieldValidatorTest.java index a59eaa7fa74..db60e9b1edd 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DatasetFieldValidatorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DatasetFieldValidatorTest.java @@ -6,12 +6,13 @@ package edu.harvard.iq.dataverse; import jakarta.validation.ConstraintValidatorContext; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + import org.mockito.Mockito; /** diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetTest.java index 45e47460ffe..30d8d0867a0 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DatasetTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DatasetTest.java @@ -3,10 +3,11 @@ import edu.harvard.iq.dataverse.DatasetVersion.VersionState; import edu.harvard.iq.dataverse.mocks.MocksFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; import java.util.ArrayList; import java.util.List; diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetVersionServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetVersionServiceBeanTest.java index 7c608888b7b..ef15372c408 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DatasetVersionServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DatasetVersionServiceBeanTest.java @@ -1,13 +1,13 @@ package edu.harvard.iq.dataverse; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import java.util.Arrays; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import edu.harvard.iq.dataverse.authorization.AuthenticatedUserDisplayInfo; diff --git a/src/test/java/edu/harvard/iq/dataverse/DataverseMetadataBlockFacetTest.java b/src/test/java/edu/harvard/iq/dataverse/DataverseMetadataBlockFacetTest.java index 7ae2d26a113..e0bcfb2369d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DataverseMetadataBlockFacetTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DataverseMetadataBlockFacetTest.java @@ -3,7 +3,7 @@ import edu.harvard.iq.dataverse.mocks.MocksFactory; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/DataverseTest.java b/src/test/java/edu/harvard/iq/dataverse/DataverseTest.java index cb0561dd0f4..35db6c29e89 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DataverseTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DataverseTest.java @@ -3,8 +3,8 @@ import edu.harvard.iq.dataverse.mocks.MocksFactory; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; diff --git a/src/test/java/edu/harvard/iq/dataverse/EditDataFilesPageHelperTest.java b/src/test/java/edu/harvard/iq/dataverse/EditDataFilesPageHelperTest.java index c95f7f105fa..621c05937f5 100644 --- a/src/test/java/edu/harvard/iq/dataverse/EditDataFilesPageHelperTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/EditDataFilesPageHelperTest.java @@ -3,12 +3,12 @@ import edu.harvard.iq.dataverse.util.file.CreateDataFileResult; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import java.util.Arrays; import java.util.Collections; diff --git a/src/test/java/edu/harvard/iq/dataverse/ExternalIdentifierTest.java b/src/test/java/edu/harvard/iq/dataverse/ExternalIdentifierTest.java index c14d2e4086e..dbd732d2e55 100644 --- a/src/test/java/edu/harvard/iq/dataverse/ExternalIdentifierTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/ExternalIdentifierTest.java @@ -1,11 +1,9 @@ package edu.harvard.iq.dataverse; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import java.util.regex.Pattern; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ExternalIdentifierTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/FileDirectoryNameValidatorTest.java b/src/test/java/edu/harvard/iq/dataverse/FileDirectoryNameValidatorTest.java index 9d49dcdb070..c8d6a8cd747 100644 --- a/src/test/java/edu/harvard/iq/dataverse/FileDirectoryNameValidatorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/FileDirectoryNameValidatorTest.java @@ -1,13 +1,10 @@ package edu.harvard.iq.dataverse; -import java.util.Arrays; -import java.util.Collection; -import org.junit.Test; -import static org.junit.Assert.*; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(Parameterized.class) +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; + public class FileDirectoryNameValidatorTest { public boolean isValid; diff --git a/src/test/java/edu/harvard/iq/dataverse/GlobalIdTest.java b/src/test/java/edu/harvard/iq/dataverse/GlobalIdTest.java index 2b60f2a2864..3c3993d110d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/GlobalIdTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/GlobalIdTest.java @@ -1,14 +1,15 @@ package edu.harvard.iq.dataverse; -import org.junit.Test; -import static org.junit.Assert.*; - -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import edu.harvard.iq.dataverse.pidproviders.PidUtil; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * * @author rmp553 diff --git a/src/test/java/edu/harvard/iq/dataverse/MetadataBlockTest.java b/src/test/java/edu/harvard/iq/dataverse/MetadataBlockTest.java index 85aaa37bb30..8644de89709 100644 --- a/src/test/java/edu/harvard/iq/dataverse/MetadataBlockTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/MetadataBlockTest.java @@ -3,7 +3,7 @@ import edu.harvard.iq.dataverse.mocks.MocksFactory; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.UUID; diff --git a/src/test/java/edu/harvard/iq/dataverse/PermissionsWrapperTest.java b/src/test/java/edu/harvard/iq/dataverse/PermissionsWrapperTest.java index 7ebc7e3c807..0acd7a8dca9 100644 --- a/src/test/java/edu/harvard/iq/dataverse/PermissionsWrapperTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/PermissionsWrapperTest.java @@ -1,12 +1,12 @@ package edu.harvard.iq.dataverse; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import edu.harvard.iq.dataverse.authorization.users.GuestUser; diff --git a/src/test/java/edu/harvard/iq/dataverse/PersistentIdentifierServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/PersistentIdentifierServiceBeanTest.java index 2318ebc8f2f..2e943bc7647 100644 --- a/src/test/java/edu/harvard/iq/dataverse/PersistentIdentifierServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/PersistentIdentifierServiceBeanTest.java @@ -10,16 +10,17 @@ import edu.harvard.iq.dataverse.pidproviders.FakePidProviderServiceBean; import edu.harvard.iq.dataverse.pidproviders.PermaLinkPidProviderServiceBean; import edu.harvard.iq.dataverse.settings.SettingsServiceBean; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; -import static org.junit.Assert.*; + +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/RoleAssignmentTest.java b/src/test/java/edu/harvard/iq/dataverse/RoleAssignmentTest.java index e4b33b83930..6ed5e8c55bc 100644 --- a/src/test/java/edu/harvard/iq/dataverse/RoleAssignmentTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/RoleAssignmentTest.java @@ -1,18 +1,18 @@ package edu.harvard.iq.dataverse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import edu.harvard.iq.dataverse.authorization.DataverseRole; import edu.harvard.iq.dataverse.authorization.RoleAssignee; import edu.harvard.iq.dataverse.authorization.users.GuestUser; import edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertFalse; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; public class RoleAssignmentTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/actionlogging/ActionLogRecordTest.java b/src/test/java/edu/harvard/iq/dataverse/actionlogging/ActionLogRecordTest.java index 1726ea70114..9641fe57fb6 100644 --- a/src/test/java/edu/harvard/iq/dataverse/actionlogging/ActionLogRecordTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/actionlogging/ActionLogRecordTest.java @@ -1,13 +1,13 @@ package edu.harvard.iq.dataverse.actionlogging; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Date; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import edu.harvard.iq.dataverse.actionlogging.ActionLogRecord.ActionType; import edu.harvard.iq.dataverse.actionlogging.ActionLogRecord.Result; diff --git a/src/test/java/edu/harvard/iq/dataverse/api/AbstractApiBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/api/AbstractApiBeanTest.java index d16d218d54b..89f2ade1e72 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/AbstractApiBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/AbstractApiBeanTest.java @@ -7,17 +7,16 @@ import java.util.logging.Logger; import jakarta.json.Json; import jakarta.json.JsonObject; -import jakarta.json.JsonObjectBuilder; import jakarta.json.JsonReader; import jakarta.json.JsonWriter; import jakarta.json.JsonWriterFactory; import jakarta.json.stream.JsonGenerator; import jakarta.ws.rs.core.Response; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class AbstractApiBeanTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java b/src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java index b7bdb17ec83..0f83e1a6de8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java @@ -13,19 +13,22 @@ import edu.harvard.iq.dataverse.util.FileUtil; import java.io.IOException; import java.util.zip.ZipInputStream; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; + +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.util.zip.ZipEntry; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.util.HashMap; import static jakarta.ws.rs.core.Response.Status.OK; import org.hamcrest.collection.IsMapContaining; -import static junit.framework.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; + +import static org.hamcrest.MatcherAssert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; diff --git a/src/test/java/edu/harvard/iq/dataverse/api/AdminIT.java b/src/test/java/edu/harvard/iq/dataverse/api/AdminIT.java index c9d262f6437..cf7e43268ba 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/AdminIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/AdminIT.java @@ -17,8 +17,10 @@ import java.util.List; import static jakarta.ws.rs.core.Response.Status.FORBIDDEN; import static jakarta.ws.rs.core.Response.Status.BAD_REQUEST; -import org.junit.Test; -import org.junit.BeforeClass; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeAll; import java.util.Map; import java.util.UUID; @@ -28,11 +30,10 @@ import static jakarta.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; import static jakarta.ws.rs.core.Response.Status.OK; import static jakarta.ws.rs.core.Response.Status.UNAUTHORIZED; -import static junit.framework.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertTrue; -import org.junit.Ignore; +import static org.junit.jupiter.api.Assertions.assertTrue; public class AdminIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/AuxiliaryFilesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/AuxiliaryFilesIT.java index 08643b2f018..a5251de43f4 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/AuxiliaryFilesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/AuxiliaryFilesIT.java @@ -13,10 +13,10 @@ import static jakarta.ws.rs.core.Response.Status.NOT_FOUND; import static jakarta.ws.rs.core.Response.Status.OK; import static org.hamcrest.CoreMatchers.equalTo; -import org.junit.Assert; -import static org.junit.Assert.assertTrue; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class AuxiliaryFilesIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/BagIT.java b/src/test/java/edu/harvard/iq/dataverse/api/BagIT.java index d3ca498e447..2fbd1ef8049 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/BagIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/BagIT.java @@ -6,9 +6,9 @@ import edu.harvard.iq.dataverse.settings.SettingsServiceBean; import static jakarta.ws.rs.core.Response.Status.CREATED; import static jakarta.ws.rs.core.Response.Status.OK; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class BagIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/BatchImportIT.java b/src/test/java/edu/harvard/iq/dataverse/api/BatchImportIT.java index aa0fb0d4a1e..db13aace0e1 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/BatchImportIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/BatchImportIT.java @@ -5,8 +5,8 @@ import java.io.File; import com.jayway.restassured.response.Response; import java.util.logging.Logger; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import static jakarta.ws.rs.core.Response.Status.ACCEPTED; import static jakarta.ws.rs.core.Response.Status.OK; import static jakarta.ws.rs.core.Response.Status.CREATED; diff --git a/src/test/java/edu/harvard/iq/dataverse/api/BuiltinUsersIT.java b/src/test/java/edu/harvard/iq/dataverse/api/BuiltinUsersIT.java index 36a56950ec3..5bc7be3d299 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/BuiltinUsersIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/BuiltinUsersIT.java @@ -20,12 +20,12 @@ import static jakarta.ws.rs.core.Response.Status.OK; import static jakarta.ws.rs.core.Response.Status.FORBIDDEN; import static jakarta.ws.rs.core.Response.Status.UNAUTHORIZED; -import static junit.framework.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.Matchers.startsWith; -import static org.junit.Assert.assertTrue; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class BuiltinUsersIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/ConfirmEmailIT.java b/src/test/java/edu/harvard/iq/dataverse/api/ConfirmEmailIT.java index e00dba2263b..3db1f6d2d22 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/ConfirmEmailIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/ConfirmEmailIT.java @@ -5,9 +5,9 @@ import com.jayway.restassured.path.json.JsonPath; import com.jayway.restassured.response.Response; import java.util.logging.Logger; -import static junit.framework.Assert.assertEquals; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.Matchers.startsWith; diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DataCiteIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DataCiteIT.java index 86c3eed4297..a610b7e4fbf 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DataCiteIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DataCiteIT.java @@ -2,9 +2,9 @@ import com.jayway.restassured.path.json.JsonPath; import com.jayway.restassured.response.Response; -import static junit.framework.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.hamcrest.CoreMatchers.equalTo; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * These tests will only work if you are using "DataCite" rather than "EZID" for diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DataRetrieverApiIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DataRetrieverApiIT.java index 69d9c78d602..f15a1b8e7ee 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DataRetrieverApiIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DataRetrieverApiIT.java @@ -3,8 +3,8 @@ import com.jayway.restassured.RestAssured; import com.jayway.restassured.response.Response; import edu.harvard.iq.dataverse.api.auth.ApiKeyAuthMechanism; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.util.ArrayList; diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApiTest.java b/src/test/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApiTest.java index 559e5a7dfba..ca99960f240 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApiTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DatasetFieldServiceApiTest.java @@ -1,12 +1,12 @@ package edu.harvard.iq.dataverse.api; import edu.harvard.iq.dataverse.util.BundleUtil; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class DatasetFieldServiceApiTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java index 4929175b89c..1419784d5fd 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java @@ -9,10 +9,11 @@ import java.util.logging.Logger; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import com.jayway.restassured.path.json.JsonPath; import java.util.List; @@ -75,7 +76,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.hamcrest.CoreMatchers; @@ -86,14 +87,10 @@ import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.Matchers.contains; -import org.junit.AfterClass; -import org.junit.Assert; - -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class DatasetsIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DatasetsTest.java b/src/test/java/edu/harvard/iq/dataverse/api/DatasetsTest.java index fded590d9db..58aa366c9e5 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DatasetsTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DatasetsTest.java @@ -1,13 +1,13 @@ package edu.harvard.iq.dataverse.api; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.HashSet; import java.util.Set; import java.util.function.Predicate; import java.util.stream.Collectors; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DatasetsTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java index eb8511f8ffe..0a5a773853e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java @@ -22,14 +22,15 @@ import jakarta.ws.rs.core.Response.Status; import static jakarta.ws.rs.core.Response.Status.BAD_REQUEST; import static jakarta.ws.rs.core.Response.Status.OK; -import static junit.framework.Assert.assertEquals; -import org.junit.BeforeClass; -import org.junit.Test; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import org.junit.AfterClass; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.nio.file.Files; import com.jayway.restassured.path.json.JsonPath; import org.hamcrest.CoreMatchers; diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DataversesTest.java b/src/test/java/edu/harvard/iq/dataverse/api/DataversesTest.java index 75d1259e45d..3733f87255c 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DataversesTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DataversesTest.java @@ -22,18 +22,19 @@ import edu.harvard.iq.dataverse.settings.SettingsServiceBean; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; import jakarta.servlet.http.HttpServletRequest; import jakarta.ws.rs.container.ContainerRequestContext; import jakarta.ws.rs.core.Response; +import org.mockito.junit.jupiter.MockitoExtension; + import java.util.Arrays; import java.util.Collections; import java.util.List; diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DeactivateUsersIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DeactivateUsersIT.java index 3ffca21d5e6..2af2335b9c7 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DeactivateUsersIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DeactivateUsersIT.java @@ -14,8 +14,8 @@ import static jakarta.ws.rs.core.Response.Status.UNAUTHORIZED; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.startsWith; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class DeactivateUsersIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DeleteUsersIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DeleteUsersIT.java index e4c72cf4e1d..926ae5d5d8d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DeleteUsersIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DeleteUsersIT.java @@ -17,10 +17,10 @@ import static jakarta.ws.rs.core.Response.Status.CREATED; import static jakarta.ws.rs.core.Response.Status.OK; import static jakarta.ws.rs.core.Response.Status.UNAUTHORIZED; -import static junit.framework.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.hamcrest.CoreMatchers.equalTo; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * The following query has been helpful in discovering places where user ids diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DownloadFilesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DownloadFilesIT.java index dc30c53c8e5..44910d7be29 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DownloadFilesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DownloadFilesIT.java @@ -22,10 +22,10 @@ import static jakarta.ws.rs.core.Response.Status.UNAUTHORIZED; import static jakarta.ws.rs.core.Response.Status.BAD_REQUEST; import static org.hamcrest.CoreMatchers.equalTo; -import org.junit.Assert; -import static org.junit.Assert.assertTrue; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class DownloadFilesIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DownloadInstanceWriterTest.java b/src/test/java/edu/harvard/iq/dataverse/api/DownloadInstanceWriterTest.java index 6de52951077..229c7166835 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DownloadInstanceWriterTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DownloadInstanceWriterTest.java @@ -2,10 +2,10 @@ import edu.harvard.iq.dataverse.dataaccess.Range; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class DownloadInstanceWriterTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DuplicateFilesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DuplicateFilesIT.java index 19adb7ba98f..1516c0c7fc0 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DuplicateFilesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DuplicateFilesIT.java @@ -16,8 +16,8 @@ import static jakarta.ws.rs.core.Response.Status.OK; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.nullValue; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * Make assertions about duplicate file names (and maybe in the future, diff --git a/src/test/java/edu/harvard/iq/dataverse/api/EditDDIIT.java b/src/test/java/edu/harvard/iq/dataverse/api/EditDDIIT.java index 5295637dd4f..8dfe36099c6 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/EditDDIIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/EditDDIIT.java @@ -9,8 +9,8 @@ import edu.harvard.iq.dataverse.datavariable.VariableMetadata; import edu.harvard.iq.dataverse.datavariable.VariableMetadataDDIParser; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.nio.file.Paths; @@ -27,12 +27,13 @@ import static jakarta.ws.rs.core.Response.Status.OK; -import static junit.framework.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; import java.nio.file.Files; -import static org.junit.Assert.assertTrue; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class EditDDIIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/ExternalToolsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/ExternalToolsIT.java index 4d78e535a9b..ddd1f059fac 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/ExternalToolsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/ExternalToolsIT.java @@ -18,10 +18,10 @@ import static jakarta.ws.rs.core.Response.Status.OK; import org.hamcrest.CoreMatchers; import org.hamcrest.Matchers; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.assertTrue; -import org.junit.Ignore; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Disabled; public class ExternalToolsIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/FeedbackApiIT.java b/src/test/java/edu/harvard/iq/dataverse/api/FeedbackApiIT.java index f61468e28ef..5e21abc6b09 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/FeedbackApiIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/FeedbackApiIT.java @@ -8,8 +8,8 @@ import static jakarta.ws.rs.core.Response.Status.CREATED; import static jakarta.ws.rs.core.Response.Status.OK; import org.hamcrest.CoreMatchers; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class FeedbackApiIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/FileMetadataIT.java b/src/test/java/edu/harvard/iq/dataverse/api/FileMetadataIT.java index b05c81abf6a..ebc24d0b23f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/FileMetadataIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/FileMetadataIT.java @@ -4,19 +4,20 @@ import com.jayway.restassured.http.ContentType; import com.jayway.restassured.response.Response; import org.apache.commons.io.IOUtils; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.util.UUID; import static com.jayway.restassured.RestAssured.given; import static jakarta.ws.rs.core.Response.Status.OK; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class FileMetadataIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/FileTypeDetectionIT.java b/src/test/java/edu/harvard/iq/dataverse/api/FileTypeDetectionIT.java index aeab3c00777..dcb0c19eab3 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/FileTypeDetectionIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/FileTypeDetectionIT.java @@ -10,8 +10,8 @@ import static jakarta.ws.rs.core.Response.Status.UNAUTHORIZED; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.nullValue; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class FileTypeDetectionIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java index cb13c49083d..ca4597a3680 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java @@ -5,8 +5,8 @@ import java.util.logging.Logger; import edu.harvard.iq.dataverse.api.auth.ApiKeyAuthMechanism; -import org.junit.Test; -import org.junit.BeforeClass; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeAll; import com.jayway.restassured.path.json.JsonPath; import static com.jayway.restassured.path.json.JsonPath.with; import com.jayway.restassured.path.xml.XmlPath; @@ -29,16 +29,16 @@ import jakarta.json.JsonObjectBuilder; import static jakarta.ws.rs.core.Response.Status.*; -import static junit.framework.Assert.assertEquals; import org.hamcrest.CoreMatchers; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.startsWith; import static org.hamcrest.CoreMatchers.nullValue; import org.hamcrest.Matchers; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class FilesIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/FitsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/FitsIT.java index 66c81898090..da9b5b5ccc5 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/FitsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/FitsIT.java @@ -11,9 +11,9 @@ import static jakarta.ws.rs.core.Response.Status.CREATED; import static jakarta.ws.rs.core.Response.Status.OK; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertTrue; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class FitsIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/HarvestingClientsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/HarvestingClientsIT.java index 3e36da415f3..bb5b833f6b9 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/HarvestingClientsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/HarvestingClientsIT.java @@ -5,17 +5,17 @@ import com.jayway.restassured.RestAssured; import static com.jayway.restassured.RestAssured.given; import com.jayway.restassured.path.json.JsonPath; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.jayway.restassured.response.Response; import static jakarta.ws.rs.core.Response.Status.CREATED; import static jakarta.ws.rs.core.Response.Status.UNAUTHORIZED; import static jakarta.ws.rs.core.Response.Status.ACCEPTED; import static jakarta.ws.rs.core.Response.Status.OK; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import org.junit.BeforeClass; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; /** * This class tests Harvesting Client functionality. diff --git a/src/test/java/edu/harvard/iq/dataverse/api/HarvestingServerIT.java b/src/test/java/edu/harvard/iq/dataverse/api/HarvestingServerIT.java index 65f35f76cb1..3004d0ef1d2 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/HarvestingServerIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/HarvestingServerIT.java @@ -4,13 +4,15 @@ import java.util.logging.Logger; import com.jayway.restassured.RestAssured; import static com.jayway.restassured.RestAssured.given; -import org.junit.BeforeClass; -import org.junit.AfterClass; -import org.junit.Test; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import edu.harvard.iq.dataverse.settings.SettingsServiceBean; import com.jayway.restassured.response.Response; import com.jayway.restassured.path.xml.XmlPath; import com.jayway.restassured.path.xml.element.Node; + import java.util.ArrayList; import java.util.Collections; import static jakarta.ws.rs.core.Response.Status.OK; @@ -18,10 +20,11 @@ import java.util.List; import java.util.Set; import java.util.HashSet; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for the Harvesting Server functionality diff --git a/src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java b/src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java index ca082c5ce95..f88bddb5159 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java @@ -15,10 +15,9 @@ import static jakarta.ws.rs.core.Response.Status.UNAUTHORIZED; import static jakarta.ws.rs.core.Response.Status.NO_CONTENT; import static org.hamcrest.CoreMatchers.equalTo; -import org.junit.Assert; -import static org.junit.Assert.assertTrue; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class InReviewWorkflowIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/IndexIT.java b/src/test/java/edu/harvard/iq/dataverse/api/IndexIT.java index 72d834786a9..91260f61e69 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/IndexIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/IndexIT.java @@ -10,14 +10,14 @@ import java.util.logging.Logger; import static jakarta.ws.rs.core.Response.Status.CREATED; import static jakarta.ws.rs.core.Response.Status.NO_CONTENT; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import static jakarta.ws.rs.core.Response.Status.OK; -import static junit.framework.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.hamcrest.CoreMatchers; import static org.hamcrest.CoreMatchers.equalTo; -import org.junit.After; +import org.junit.jupiter.api.AfterEach; public class IndexIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/InfoIT.java b/src/test/java/edu/harvard/iq/dataverse/api/InfoIT.java index 73a1171bf1b..2accf035e2a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/InfoIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/InfoIT.java @@ -3,7 +3,8 @@ import static com.jayway.restassured.RestAssured.given; import com.jayway.restassured.response.Response; import edu.harvard.iq.dataverse.settings.SettingsServiceBean; -import org.junit.Test; +import org.junit.jupiter.api.Test; + import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; diff --git a/src/test/java/edu/harvard/iq/dataverse/api/InvalidCharactersIT.java b/src/test/java/edu/harvard/iq/dataverse/api/InvalidCharactersIT.java index 63af8ea13e1..3d58ecdd739 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/InvalidCharactersIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/InvalidCharactersIT.java @@ -11,8 +11,8 @@ import static jakarta.ws.rs.core.Response.Status.CREATED; import static jakarta.ws.rs.core.Response.Status.OK; import org.hamcrest.Matchers; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class InvalidCharactersIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/IpGroupsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/IpGroupsIT.java index d73f07bd530..40f342af987 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/IpGroupsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/IpGroupsIT.java @@ -12,10 +12,10 @@ import static jakarta.ws.rs.core.Response.Status.CREATED; import static jakarta.ws.rs.core.Response.Status.FORBIDDEN; import static jakarta.ws.rs.core.Response.Status.OK; -import static junit.framework.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.hamcrest.CoreMatchers.equalTo; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class IpGroupsIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/LazyRefTest.java b/src/test/java/edu/harvard/iq/dataverse/api/LazyRefTest.java index 72cf6fae875..382a80a3493 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/LazyRefTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/LazyRefTest.java @@ -3,8 +3,7 @@ */ package edu.harvard.iq.dataverse.api; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java index 4e2e5e117fc..b29e6472fcf 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java @@ -4,20 +4,15 @@ import com.jayway.restassured.path.json.JsonPath; import com.jayway.restassured.response.Response; -import static jakarta.ws.rs.core.Response.Status.FORBIDDEN; -import static jakarta.ws.rs.core.Response.Status.BAD_REQUEST; -import org.junit.Test; -import org.junit.BeforeClass; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeAll; import java.util.logging.Logger; -import static jakarta.ws.rs.core.Response.Status.CREATED; -import static jakarta.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; import static jakarta.ws.rs.core.Response.Status.OK; -import static jakarta.ws.rs.core.Response.Status.UNAUTHORIZED; -import static org.junit.Assert.*; import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class LicensesIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/LinkIT.java b/src/test/java/edu/harvard/iq/dataverse/api/LinkIT.java index 5b0c8e56467..8a440da2ace 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/LinkIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/LinkIT.java @@ -9,8 +9,8 @@ import static jakarta.ws.rs.core.Response.Status.FORBIDDEN; import static jakarta.ws.rs.core.Response.Status.OK; import static org.hamcrest.CoreMatchers.equalTo; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class LinkIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/LogoutIT.java b/src/test/java/edu/harvard/iq/dataverse/api/LogoutIT.java index eaa6fc5270f..f4b60369443 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/LogoutIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/LogoutIT.java @@ -2,7 +2,7 @@ import com.jayway.restassured.RestAssured; import com.jayway.restassured.response.Response; -import org.junit.BeforeClass; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static jakarta.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; diff --git a/src/test/java/edu/harvard/iq/dataverse/api/MakeDataCountApiIT.java b/src/test/java/edu/harvard/iq/dataverse/api/MakeDataCountApiIT.java index c85920807fd..107ecece1d7 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/MakeDataCountApiIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/MakeDataCountApiIT.java @@ -9,9 +9,9 @@ import static jakarta.ws.rs.core.Response.Status.BAD_REQUEST; import org.apache.commons.io.FileUtils; import static org.hamcrest.CoreMatchers.equalTo; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class MakeDataCountApiIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/MetricsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/MetricsIT.java index cdbf2251ea3..72e73547979 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/MetricsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/MetricsIT.java @@ -5,11 +5,12 @@ import edu.harvard.iq.dataverse.metrics.MetricsUtil; import static jakarta.ws.rs.core.Response.Status.BAD_REQUEST; import static jakarta.ws.rs.core.Response.Status.OK; -import org.junit.AfterClass; -import static org.junit.Assert.assertEquals; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.AfterAll; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; //TODO: These tests are fairly flawed as they don't actually add data to compare on. //To improve these tests we should try adding data and see if the number DOESN'T diff --git a/src/test/java/edu/harvard/iq/dataverse/api/MoveIT.java b/src/test/java/edu/harvard/iq/dataverse/api/MoveIT.java index 537fe09317c..5f9d2f7374b 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/MoveIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/MoveIT.java @@ -17,10 +17,9 @@ import static jakarta.ws.rs.core.Response.Status.UNAUTHORIZED; import org.hamcrest.CoreMatchers; import static org.hamcrest.CoreMatchers.equalTo; -import org.junit.Assert; -import static org.junit.Assert.assertEquals; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class MoveIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/NetcdfIT.java b/src/test/java/edu/harvard/iq/dataverse/api/NetcdfIT.java index 0b1862ad687..dd39cc3549d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/NetcdfIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/NetcdfIT.java @@ -14,8 +14,8 @@ import static jakarta.ws.rs.core.Response.Status.OK; import org.hamcrest.CoreMatchers; import static org.hamcrest.CoreMatchers.equalTo; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class NetcdfIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/NotificationsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/NotificationsIT.java index f7955726b88..683acf7c541 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/NotificationsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/NotificationsIT.java @@ -7,8 +7,8 @@ import static jakarta.ws.rs.core.Response.Status.CREATED; import static jakarta.ws.rs.core.Response.Status.OK; import static org.hamcrest.CoreMatchers.equalTo; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class NotificationsIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/PidsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/PidsIT.java index 7983bf3708e..cc9fe2dd4b3 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/PidsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/PidsIT.java @@ -6,9 +6,9 @@ import static jakarta.ws.rs.core.Response.Status.CREATED; import static jakarta.ws.rs.core.Response.Status.FORBIDDEN; import static jakarta.ws.rs.core.Response.Status.OK; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; /** * In order to execute this test code you must be configured with DataCite diff --git a/src/test/java/edu/harvard/iq/dataverse/api/ProvIT.java b/src/test/java/edu/harvard/iq/dataverse/api/ProvIT.java index dc3c01099e3..ddd523bf553 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/ProvIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/ProvIT.java @@ -10,12 +10,12 @@ import static jakarta.ws.rs.core.Response.Status.OK; import static jakarta.ws.rs.core.Response.Status.BAD_REQUEST; import static jakarta.ws.rs.core.Response.Status.FORBIDDEN; -import static junit.framework.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class ProvIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/RemoteStoreIT.java b/src/test/java/edu/harvard/iq/dataverse/api/RemoteStoreIT.java index 286013f7727..48b52d1c892 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/RemoteStoreIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/RemoteStoreIT.java @@ -6,8 +6,8 @@ import jakarta.json.JsonObjectBuilder; import static jakarta.ws.rs.core.Response.Status.CREATED; import static jakarta.ws.rs.core.Response.Status.OK; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class RemoteStoreIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/RolesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/RolesIT.java index d1e2ffb2426..6168ff27c4d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/RolesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/RolesIT.java @@ -5,10 +5,12 @@ import com.jayway.restassured.path.json.JsonPath; import com.jayway.restassured.response.Response; import java.util.logging.Logger; -import static junit.framework.Assert.assertEquals; import static org.hamcrest.CoreMatchers.equalTo; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/api/S3AccessIT.java b/src/test/java/edu/harvard/iq/dataverse/api/S3AccessIT.java index e39172b4c73..acc47db360a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/S3AccessIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/S3AccessIT.java @@ -1,16 +1,13 @@ package edu.harvard.iq.dataverse.api; import com.jayway.restassured.RestAssured; -import static com.jayway.restassured.RestAssured.given; import com.jayway.restassured.path.json.JsonPath; import com.jayway.restassured.response.Response; import java.util.logging.Logger; -import static jakarta.ws.rs.core.Response.Status.OK; -import static junit.framework.Assert.assertEquals; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.hamcrest.CoreMatchers.nullValue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + import static org.hamcrest.Matchers.startsWith; /** diff --git a/src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java b/src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java index b6823ddbea4..2f67f07d2dc 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java @@ -8,9 +8,10 @@ import java.util.logging.Logger; import jakarta.json.Json; import jakarta.json.JsonObject; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.AfterEach; import edu.harvard.iq.dataverse.util.FileUtil; import java.io.File; import java.io.InputStream; @@ -21,23 +22,23 @@ import static jakarta.ws.rs.core.Response.Status.OK; import static jakarta.ws.rs.core.Response.Status.FORBIDDEN; import org.hamcrest.CoreMatchers; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import edu.harvard.iq.dataverse.dataaccess.ImageThumbConverter; import java.awt.image.BufferedImage; import java.io.IOException; -import static junit.framework.Assert.assertEquals; import static java.lang.Thread.sleep; import javax.imageio.ImageIO; import static jakarta.ws.rs.core.Response.Status.CREATED; import static jakarta.ws.rs.core.Response.Status.NOT_FOUND; import static jakarta.ws.rs.core.Response.Status.UNAUTHORIZED; import org.hamcrest.Matchers; -import org.junit.After; -import static org.junit.Assert.assertNotEquals; import jakarta.json.JsonObjectBuilder; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class SearchIT { private static final Logger logger = Logger.getLogger(SearchIT.class.getCanonicalName()); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/SignedUrlAuthMechanismIT.java b/src/test/java/edu/harvard/iq/dataverse/api/SignedUrlAuthMechanismIT.java index 729b4f85e9f..ab153ad59bb 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/SignedUrlAuthMechanismIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/SignedUrlAuthMechanismIT.java @@ -2,7 +2,7 @@ import com.jayway.restassured.RestAssured; import com.jayway.restassured.response.Response; -import org.junit.BeforeClass; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import static com.jayway.restassured.RestAssured.get; diff --git a/src/test/java/edu/harvard/iq/dataverse/api/SignpostingIT.java b/src/test/java/edu/harvard/iq/dataverse/api/SignpostingIT.java index 585eac91d18..6e24bad0e01 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/SignpostingIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/SignpostingIT.java @@ -10,15 +10,15 @@ import static jakarta.ws.rs.core.Response.Status.CREATED; import static jakarta.ws.rs.core.Response.Status.OK; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.regex.Matcher; import java.util.regex.Pattern; import jakarta.json.JsonObject; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class SignpostingIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/SiteMapIT.java b/src/test/java/edu/harvard/iq/dataverse/api/SiteMapIT.java index 723f05d3802..048bc1c2df5 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/SiteMapIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/SiteMapIT.java @@ -1,8 +1,8 @@ package edu.harvard.iq.dataverse.api; import com.jayway.restassured.RestAssured; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import com.jayway.restassured.response.Response; public class SiteMapIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/StorageSitesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/StorageSitesIT.java index b2f6e6151a1..13b1f36d59a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/StorageSitesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/StorageSitesIT.java @@ -6,8 +6,8 @@ import edu.harvard.iq.dataverse.util.SystemConfig; import jakarta.json.Json; import jakarta.json.JsonObjectBuilder; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class StorageSitesIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/SwordIT.java b/src/test/java/edu/harvard/iq/dataverse/api/SwordIT.java index 95d9525f6db..812fa7897f7 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/SwordIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/SwordIT.java @@ -24,15 +24,16 @@ import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.startsWith; -import org.junit.AfterClass; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeTrue; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * In all these tests you should never see something like "[long string exposing diff --git a/src/test/java/edu/harvard/iq/dataverse/api/TabularIT.java b/src/test/java/edu/harvard/iq/dataverse/api/TabularIT.java index 70267d70f5b..4afd5058a3a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/TabularIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/TabularIT.java @@ -10,11 +10,11 @@ import static jakarta.ws.rs.core.Response.Status.CREATED; import static jakarta.ws.rs.core.Response.Status.OK; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class TabularIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/ThumbnailsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/ThumbnailsIT.java index ffa432de63b..7ec3ee10ecb 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/ThumbnailsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/ThumbnailsIT.java @@ -2,7 +2,7 @@ import com.jayway.restassured.response.Response; import org.hamcrest.CoreMatchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ThumbnailsIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/UsersIT.java b/src/test/java/edu/harvard/iq/dataverse/api/UsersIT.java index 76f153721c0..1dd1199ebd6 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/UsersIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/UsersIT.java @@ -17,13 +17,13 @@ import static jakarta.ws.rs.core.Response.Status.NOT_FOUND; import static jakarta.ws.rs.core.Response.Status.OK; import static jakarta.ws.rs.core.Response.Status.UNAUTHORIZED; -import static junit.framework.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.Matchers.contains; -import static org.junit.Assert.assertTrue; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class UsersIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java b/src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java index 5f61ab3f2c7..50ce81b4f67 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java @@ -9,8 +9,7 @@ import jakarta.json.JsonObjectBuilder; import jakarta.json.JsonArrayBuilder; import jakarta.json.JsonObject; -import jakarta.ws.rs.client.Client; -import jakarta.ws.rs.client.ClientBuilder; + import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -22,7 +21,7 @@ import com.jayway.restassured.path.xml.XmlPath; import edu.harvard.iq.dataverse.mydata.MyDataFilterParams; import org.apache.commons.lang3.StringUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import edu.harvard.iq.dataverse.settings.SettingsServiceBean; import com.jayway.restassured.specification.RequestSpecification; import java.util.List; @@ -47,11 +46,12 @@ import edu.harvard.iq.dataverse.DatasetFieldType; import edu.harvard.iq.dataverse.DatasetFieldValue; import edu.harvard.iq.dataverse.util.StringUtil; + import java.io.StringReader; import java.util.Collections; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; public class UtilIT { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/dto/FieldDTOTest.java b/src/test/java/edu/harvard/iq/dataverse/api/dto/FieldDTOTest.java index 45f0ef52b33..21e37625543 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/dto/FieldDTOTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/dto/FieldDTOTest.java @@ -11,12 +11,12 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import junit.framework.Assert; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/api/filesystem/FileRecordJobIT.java b/src/test/java/edu/harvard/iq/dataverse/api/filesystem/FileRecordJobIT.java index 5cfce389ed6..25b6ec7371d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/filesystem/FileRecordJobIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/filesystem/FileRecordJobIT.java @@ -30,14 +30,15 @@ import edu.harvard.iq.dataverse.batch.entities.StepExecutionEntity; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.Ignore; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import jakarta.batch.runtime.BatchStatus; + import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; @@ -56,10 +57,10 @@ import java.util.UUID; import static com.jayway.restassured.RestAssured.given; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; -import static junit.framework.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.hamcrest.Matchers.equalTo; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Batch File System Import Job Integration Tests diff --git a/src/test/java/edu/harvard/iq/dataverse/api/imports/ImportGenericServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/api/imports/ImportGenericServiceBeanTest.java index 70c53c8c9b9..b2ef3f24ff7 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/imports/ImportGenericServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/imports/ImportGenericServiceBeanTest.java @@ -1,11 +1,12 @@ package edu.harvard.iq.dataverse.api.imports; import edu.harvard.iq.dataverse.api.dto.DatasetDTO; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; @RunWith(MockitoJUnitRunner.class) public class ImportGenericServiceBeanTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/AuthUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/AuthUtilTest.java index a7a33d0c1bd..7e659d03a5d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/AuthUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/AuthUtilTest.java @@ -5,18 +5,16 @@ import edu.harvard.iq.dataverse.authorization.providers.oauth2.impl.GoogleOAuth2AP; import edu.harvard.iq.dataverse.authorization.providers.oauth2.impl.OrcidOAuth2AP; import edu.harvard.iq.dataverse.authorization.providers.shib.ShibAuthenticationProvider; -import java.util.Arrays; import java.util.Collection; import java.util.HashSet; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; @RunWith(Enclosed.class) public class AuthUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/AuthenticatedUserDisplayInfoTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/AuthenticatedUserDisplayInfoTest.java index c22536e7616..4f04228df71 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/AuthenticatedUserDisplayInfoTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/AuthenticatedUserDisplayInfoTest.java @@ -1,7 +1,7 @@ package edu.harvard.iq.dataverse.authorization; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/GroupServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/GroupServiceBeanTest.java index ea9f851f9ed..7c0c09d6f39 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/GroupServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/GroupServiceBeanTest.java @@ -13,8 +13,9 @@ import java.util.Set; import static java.util.stream.Collectors.toList; import java.util.stream.Stream; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; + import static edu.harvard.iq.dataverse.util.CollectionLiterals.*; /** diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/GroupUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/GroupUtilTest.java index fdfd8d4370c..41a494d5e55 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/GroupUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/GroupUtilTest.java @@ -5,8 +5,8 @@ import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser; import java.util.LinkedHashSet; import java.util.Set; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; public class GroupUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/explicit/ExplicitGroupTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/explicit/ExplicitGroupTest.java index 543d3ab1eeb..d95a95a8d3a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/explicit/ExplicitGroupTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/explicit/ExplicitGroupTest.java @@ -16,10 +16,10 @@ import edu.harvard.iq.dataverse.engine.command.DataverseRequest; import edu.harvard.iq.dataverse.mocks.MockRoleAssigneeServiceBean; import static edu.harvard.iq.dataverse.mocks.MocksFactory.*; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/IpGroupTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/IpGroupTest.java index b6a3b862435..aeea93ad29e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/IpGroupTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/IpGroupTest.java @@ -5,8 +5,9 @@ import edu.harvard.iq.dataverse.authorization.users.GuestUser; import edu.harvard.iq.dataverse.engine.command.DataverseRequest; import edu.harvard.iq.dataverse.mocks.MocksFactory; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv4AddressTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv4AddressTest.java index d03846a97b4..4bab4546ca4 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv4AddressTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv4AddressTest.java @@ -1,10 +1,10 @@ package edu.harvard.iq.dataverse.authorization.groups.impl.ipaddress.ip; -import java.math.BigDecimal; import java.math.BigInteger; import java.util.Arrays; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv6AddressTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv6AddressTest.java index 2070dc347e7..a6ca37e975c 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv6AddressTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv6AddressTest.java @@ -1,10 +1,11 @@ package edu.harvard.iq.dataverse.authorization.groups.impl.ipaddress.ip; import java.util.Arrays; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IpAddressRangeTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IpAddressRangeTest.java index f232b713640..fe2bde06482 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IpAddressRangeTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IpAddressRangeTest.java @@ -1,7 +1,7 @@ package edu.harvard.iq.dataverse.authorization.groups.impl.ipaddress.ip; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IpAddressTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IpAddressTest.java index ce6ff29f1c1..e757472e316 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IpAddressTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IpAddressTest.java @@ -1,8 +1,9 @@ package edu.harvard.iq.dataverse.authorization.groups.impl.ipaddress.ip; import java.util.Arrays; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/builtin/BuiltinAuthenticationProviderTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/builtin/BuiltinAuthenticationProviderTest.java index ebf22f9dcb4..aceedd970b7 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/builtin/BuiltinAuthenticationProviderTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/builtin/BuiltinAuthenticationProviderTest.java @@ -7,9 +7,9 @@ import edu.harvard.iq.dataverse.mocks.MockBuiltinUserServiceBean; import edu.harvard.iq.dataverse.mocks.MockPasswordValidatorServiceBean; import edu.harvard.iq.dataverse.validation.PasswordValidatorServiceBean; -import org.junit.Test; -import static org.junit.Assert.*; -import org.junit.Before; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeEach; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPageTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPageTest.java index defbc4416b5..c81edd6d102 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPageTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPageTest.java @@ -1,6 +1,6 @@ package edu.harvard.iq.dataverse.authorization.providers.builtin; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import java.sql.Timestamp; diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/oauth2/OAuth2AuthenticationProviderFactoryTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/oauth2/OAuth2AuthenticationProviderFactoryTest.java index 5838fdee42c..ae73c505a4b 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/oauth2/OAuth2AuthenticationProviderFactoryTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/oauth2/OAuth2AuthenticationProviderFactoryTest.java @@ -2,8 +2,8 @@ import java.util.HashMap; import java.util.Map; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/oauth2/impl/GitHubOAuth2APTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/oauth2/impl/GitHubOAuth2APTest.java index 786c30fb2d7..ed6b9789848 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/oauth2/impl/GitHubOAuth2APTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/oauth2/impl/GitHubOAuth2APTest.java @@ -2,10 +2,10 @@ import edu.harvard.iq.dataverse.authorization.AuthenticatedUserDisplayInfo; import edu.harvard.iq.dataverse.authorization.providers.oauth2.AbstractOAuth2AuthenticationProvider; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import edu.harvard.iq.dataverse.authorization.providers.oauth2.OAuth2UserRecord; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class GitHubOAuth2APTest extends GitHubOAuth2AP { diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/oauth2/impl/GoogleOAuth2APTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/oauth2/impl/GoogleOAuth2APTest.java index d97b0f77daf..cfba755d2a1 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/oauth2/impl/GoogleOAuth2APTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/oauth2/impl/GoogleOAuth2APTest.java @@ -3,8 +3,8 @@ import edu.harvard.iq.dataverse.authorization.AuthenticatedUserDisplayInfo; import edu.harvard.iq.dataverse.authorization.providers.oauth2.AbstractOAuth2AuthenticationProvider; import jakarta.json.Json; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; public class GoogleOAuth2APTest extends GoogleOAuth2AP { diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/shib/ShibUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/shib/ShibUtilTest.java index 99a307eebc3..4c444c3e75d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/shib/ShibUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/shib/ShibUtilTest.java @@ -3,21 +3,16 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collection; import java.util.Map; import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; import jakarta.servlet.http.HttpServletRequest; -import static org.junit.Assert.*; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; @RunWith(Enclosed.class) diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/users/AuthenticatedUserTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/users/AuthenticatedUserTest.java index 0c535653c35..12e48216f49 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/users/AuthenticatedUserTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/users/AuthenticatedUserTest.java @@ -18,16 +18,17 @@ import java.util.HashSet; import java.util.Set; -import org.junit.Test; -import static org.junit.Assert.*; -import org.junit.Before; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; import jakarta.json.JsonObject; import jakarta.json.JsonString; -import org.junit.runner.RunWith; + import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; /** * Tested class: AuthenticatedUser.java diff --git a/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailDataTest.java b/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailDataTest.java index 45c4162188a..d807d8b9efe 100644 --- a/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailDataTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailDataTest.java @@ -1,11 +1,11 @@ package edu.harvard.iq.dataverse.confirmemail; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser; diff --git a/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailUtilTest.java index 8fdc7dc38d5..cf4759fe9f5 100644 --- a/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailUtilTest.java @@ -1,15 +1,14 @@ package edu.harvard.iq.dataverse.confirmemail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + import java.sql.Timestamp; -import java.util.Collection; -import java.util.Arrays; - -import static org.junit.Assert.assertEquals; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.experimental.runners.Enclosed; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import java.util.stream.Stream; + +import static org.junit.jupiter.api.Assertions.assertEquals; @RunWith(Enclosed.class) public class ConfirmEmailUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/dataaccess/FileAccessIOTest.java b/src/test/java/edu/harvard/iq/dataverse/dataaccess/FileAccessIOTest.java index 95621dd8750..d8a94585b38 100644 --- a/src/test/java/edu/harvard/iq/dataverse/dataaccess/FileAccessIOTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/dataaccess/FileAccessIOTest.java @@ -23,13 +23,13 @@ import java.util.ArrayList; import java.util.List; import org.apache.commons.io.FileUtils; -import org.junit.After; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/dataaccess/StorageIOTest.java b/src/test/java/edu/harvard/iq/dataverse/dataaccess/StorageIOTest.java index 83cb0c72786..2ed9d18036d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/dataaccess/StorageIOTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/dataaccess/StorageIOTest.java @@ -21,8 +21,9 @@ import java.util.List; //import org.apache.commons.httpclient.Header; //import org.apache.commons.httpclient.methods.GetMethod; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/dataaccess/SwiftAccessIOTest.java b/src/test/java/edu/harvard/iq/dataverse/dataaccess/SwiftAccessIOTest.java index c1aa6b5fca3..115103450b8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/dataaccess/SwiftAccessIOTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/dataaccess/SwiftAccessIOTest.java @@ -12,11 +12,10 @@ import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.SignatureException; -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; -import org.junit.Test; -import static org.junit.Assert.*; -import org.junit.Before; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeEach; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/datacapturemodule/DataCaptureModuleServiceBeanIT.java b/src/test/java/edu/harvard/iq/dataverse/datacapturemodule/DataCaptureModuleServiceBeanIT.java index 1c033e08af2..a37f8b724fe 100644 --- a/src/test/java/edu/harvard/iq/dataverse/datacapturemodule/DataCaptureModuleServiceBeanIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/datacapturemodule/DataCaptureModuleServiceBeanIT.java @@ -11,10 +11,10 @@ import java.util.Calendar; import java.util.TimeZone; import java.util.logging.Logger; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertTrue; import jakarta.json.JsonObject; import static java.lang.Thread.sleep; import jakarta.json.Json; diff --git a/src/test/java/edu/harvard/iq/dataverse/datacapturemodule/DataCaptureModuleUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/datacapturemodule/DataCaptureModuleUtilTest.java index afb1f0ec851..eb19f22df63 100644 --- a/src/test/java/edu/harvard/iq/dataverse/datacapturemodule/DataCaptureModuleUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/datacapturemodule/DataCaptureModuleUtilTest.java @@ -16,9 +16,9 @@ import org.apache.http.entity.StringEntity; import org.apache.http.impl.DefaultHttpResponseFactory; import org.apache.http.message.BasicStatusLine; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; public class DataCaptureModuleUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/dataset/DatasetUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/dataset/DatasetUtilTest.java index 46bce999c60..8eed2a33c5a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/dataset/DatasetUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/dataset/DatasetUtilTest.java @@ -11,8 +11,9 @@ import edu.harvard.iq.dataverse.mocks.MocksFactory; import java.util.ArrayList; import java.util.List; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class DatasetUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/datasetutility/DuplicateFileCheckerTest.java b/src/test/java/edu/harvard/iq/dataverse/datasetutility/DuplicateFileCheckerTest.java index f7fe81b16e3..1fb05becfc8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/datasetutility/DuplicateFileCheckerTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/datasetutility/DuplicateFileCheckerTest.java @@ -1,12 +1,12 @@ package edu.harvard.iq.dataverse.datasetutility; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.mock; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import edu.harvard.iq.dataverse.DataFile; diff --git a/src/test/java/edu/harvard/iq/dataverse/datasetutility/OptionalFileParamsTest.java b/src/test/java/edu/harvard/iq/dataverse/datasetutility/OptionalFileParamsTest.java index f8c790a566b..c9f251f7e77 100644 --- a/src/test/java/edu/harvard/iq/dataverse/datasetutility/OptionalFileParamsTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/datasetutility/OptionalFileParamsTest.java @@ -10,19 +10,14 @@ import edu.harvard.iq.dataverse.DataFileCategory; import edu.harvard.iq.dataverse.DataFileTag; import edu.harvard.iq.dataverse.FileMetadata; -import java.util.ArrayList; + import java.util.Arrays; import java.util.List; -import java.util.ResourceBundle; import edu.harvard.iq.dataverse.util.BundleUtil; -import org.hamcrest.Matchers; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/datavariable/VariableMetadataDDIParserTest.java b/src/test/java/edu/harvard/iq/dataverse/datavariable/VariableMetadataDDIParserTest.java index 470338d0462..bfb9134cfca 100644 --- a/src/test/java/edu/harvard/iq/dataverse/datavariable/VariableMetadataDDIParserTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/datavariable/VariableMetadataDDIParserTest.java @@ -1,6 +1,6 @@ package edu.harvard.iq.dataverse.datavariable; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; @@ -12,7 +12,7 @@ import java.util.HashSet; import java.util.Collection; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class VariableMetadataDDIParserTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/dataverse/DataverseUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/dataverse/DataverseUtilTest.java index cae61afda30..dacebac9117 100644 --- a/src/test/java/edu/harvard/iq/dataverse/dataverse/DataverseUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/dataverse/DataverseUtilTest.java @@ -4,15 +4,17 @@ import edu.harvard.iq.dataverse.Dataverse; import edu.harvard.iq.dataverse.DvObjectContainer; import edu.harvard.iq.dataverse.mocks.MocksFactory; -import static org.junit.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.HashMap; import java.util.Map; import jakarta.ws.rs.BadRequestException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class DataverseUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/PermissionTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/PermissionTest.java index ec300a25db7..4b98d3d9850 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/PermissionTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/PermissionTest.java @@ -5,8 +5,9 @@ import edu.harvard.iq.dataverse.Dataset; import edu.harvard.iq.dataverse.Dataverse; import edu.harvard.iq.dataverse.DvObject; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/AbstractDatasetCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/AbstractDatasetCommandTest.java index a87de12cfe0..388483bfefc 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/AbstractDatasetCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/AbstractDatasetCommandTest.java @@ -5,10 +5,12 @@ import edu.harvard.iq.dataverse.engine.command.CommandContext; import edu.harvard.iq.dataverse.engine.command.DataverseRequest; import edu.harvard.iq.dataverse.engine.command.exception.CommandException; +import edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException; import edu.harvard.iq.dataverse.mocks.MocksFactory; import static edu.harvard.iq.dataverse.mocks.MocksFactory.*; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDatasetVersionCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDatasetVersionCommandTest.java index dd8901a05dc..ca266d5208f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDatasetVersionCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDatasetVersionCommandTest.java @@ -16,9 +16,11 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDataverseCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDataverseCommandTest.java index bcbc12d5d4e..985c70f834e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDataverseCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDataverseCommandTest.java @@ -15,14 +15,15 @@ import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser; import edu.harvard.iq.dataverse.authorization.users.GuestUser; import edu.harvard.iq.dataverse.search.IndexServiceBean; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static edu.harvard.iq.dataverse.mocks.MocksFactory.*; import edu.harvard.iq.dataverse.engine.TestCommandContext; import edu.harvard.iq.dataverse.engine.TestDataverseEngine; import edu.harvard.iq.dataverse.engine.command.DataverseRequest; import edu.harvard.iq.dataverse.engine.command.exception.CommandException; import edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException; + import java.sql.Timestamp; import java.util.ArrayList; import java.util.Arrays; @@ -31,9 +32,9 @@ import java.util.List; import java.util.Map; import java.util.concurrent.Future; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreatePrivateUrlCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreatePrivateUrlCommandTest.java index aafad58654e..104a4f595a8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreatePrivateUrlCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreatePrivateUrlCommandTest.java @@ -14,12 +14,13 @@ import edu.harvard.iq.dataverse.util.SystemConfig; import java.util.ArrayList; import java.util.List; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CreatePrivateUrlCommandTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateRoleCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateRoleCommandTest.java index 10981fb8d0e..bd42a5469b3 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateRoleCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateRoleCommandTest.java @@ -16,9 +16,11 @@ import edu.harvard.iq.dataverse.mocks.MocksFactory; import jakarta.persistence.EntityManager; import jakarta.persistence.TypedQuery; -import static org.junit.Assert.assertTrue; -import org.junit.Before; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Matchers; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/DRSSubmitToArchiveCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/DRSSubmitToArchiveCommandTest.java index a0e79268e3d..d91384557fb 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/DRSSubmitToArchiveCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/DRSSubmitToArchiveCommandTest.java @@ -1,19 +1,20 @@ package edu.harvard.iq.dataverse.engine.command.impl; import org.erdtman.jcs.JsonCanonicalizer; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.auth0.jwt.JWT; import com.auth0.jwt.algorithms.Algorithm; import com.auth0.jwt.interfaces.DecodedJWT; import edu.harvard.iq.dataverse.engine.command.exception.CommandException; + import java.security.KeyFactory; import java.security.interfaces.RSAPrivateKey; //import java.security.interfaces.RSAPublicKey; import java.security.spec.PKCS8EncodedKeySpec; import java.util.Base64; +import static org.junit.jupiter.api.Assertions.fail; public class DRSSubmitToArchiveCommandTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/DeletePrivateUrlCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/DeletePrivateUrlCommandTest.java index 74c8c269b4b..73b160e620d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/DeletePrivateUrlCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/DeletePrivateUrlCommandTest.java @@ -13,10 +13,11 @@ import edu.harvard.iq.dataverse.privateurl.PrivateUrlServiceBean; import java.util.ArrayList; import java.util.List; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; public class DeletePrivateUrlCommandTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/GetLatestPublishedDatasetVersionCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/GetLatestPublishedDatasetVersionCommandTest.java index 24c48fd257b..935da493c35 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/GetLatestPublishedDatasetVersionCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/GetLatestPublishedDatasetVersionCommandTest.java @@ -9,8 +9,9 @@ import edu.harvard.iq.dataverse.engine.command.exception.CommandException; import java.util.ArrayList; import java.util.List; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; import static edu.harvard.iq.dataverse.mocks.MocksFactory.makeRequest; /** diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/GetPrivateUrlCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/GetPrivateUrlCommandTest.java index b5019807ac1..d15162e4053 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/GetPrivateUrlCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/GetPrivateUrlCommandTest.java @@ -5,13 +5,12 @@ import edu.harvard.iq.dataverse.engine.TestDataverseEngine; import edu.harvard.iq.dataverse.privateurl.PrivateUrl; import edu.harvard.iq.dataverse.privateurl.PrivateUrlServiceBean; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import static org.junit.Assert.assertNull; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import static org.junit.jupiter.api.Assertions.assertNull; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class GetPrivateUrlCommandTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ListMetadataBlocksCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ListMetadataBlocksCommandTest.java index 520c91f47ff..83780552639 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ListMetadataBlocksCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ListMetadataBlocksCommandTest.java @@ -9,8 +9,8 @@ import edu.harvard.iq.dataverse.mocks.MocksFactory; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.Arrays; diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDatasetCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDatasetCommandTest.java index 2d0f52779c3..7c883b18cb5 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDatasetCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDatasetCommandTest.java @@ -48,13 +48,13 @@ import jakarta.persistence.metamodel.Metamodel; import jakarta.servlet.http.HttpServletRequest; import jakarta.ws.rs.core.Context; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDataverseCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDataverseCommandTest.java index 9568d58aafb..ce56a732267 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDataverseCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDataverseCommandTest.java @@ -27,12 +27,12 @@ import java.util.concurrent.Future; import jakarta.persistence.EntityManager; import jakarta.servlet.http.HttpServletRequest; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/RequestRsyncScriptCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/RequestRsyncScriptCommandTest.java index 6eeaa34bf4e..fef4b03b9a3 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/RequestRsyncScriptCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/RequestRsyncScriptCommandTest.java @@ -10,12 +10,13 @@ import edu.harvard.iq.dataverse.mocks.MocksFactory; import edu.harvard.iq.dataverse.settings.SettingsServiceBean; import jakarta.servlet.http.HttpServletRequest; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class RequestRsyncScriptCommandTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/RestrictFileCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/RestrictFileCommandTest.java index 7b663389a3a..2e1abefb4d8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/RestrictFileCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/RestrictFileCommandTest.java @@ -18,13 +18,15 @@ import edu.harvard.iq.dataverse.settings.SettingsServiceBean; import java.sql.Timestamp; import java.util.Date; -import org.junit.After; -import org.junit.AfterClass; -import static org.junit.Assert.assertEquals; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; /** diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ReturnDatasetToAuthorCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ReturnDatasetToAuthorCommandTest.java index 7f776fb894c..e70771a3348 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ReturnDatasetToAuthorCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ReturnDatasetToAuthorCommandTest.java @@ -27,11 +27,11 @@ import jakarta.persistence.EntityManager; import jakarta.servlet.http.HttpServletRequest; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class ReturnDatasetToAuthorCommandTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/SubmitDatasetForReviewCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/SubmitDatasetForReviewCommandTest.java index f3d59455ac0..74a632e510a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/SubmitDatasetForReviewCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/SubmitDatasetForReviewCommandTest.java @@ -27,10 +27,10 @@ import jakarta.persistence.EntityManager; import jakarta.servlet.http.HttpServletRequest; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SubmitDatasetForReviewCommandTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateDatasetThumbnailCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateDatasetThumbnailCommandTest.java index f55e9a2d085..45ecd1e03dd 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateDatasetThumbnailCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateDatasetThumbnailCommandTest.java @@ -9,12 +9,13 @@ import edu.harvard.iq.dataverse.engine.TestDataverseEngine; import edu.harvard.iq.dataverse.engine.command.exception.CommandException; import edu.harvard.iq.dataverse.util.SystemConfig; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class UpdateDatasetThumbnailCommandTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetRootCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetRootCommandTest.java index 711e7881af5..492344ea072 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetRootCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetRootCommandTest.java @@ -8,8 +8,8 @@ import edu.harvard.iq.dataverse.engine.command.exception.CommandException; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetsCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetsCommandTest.java index 2d64de80f3d..e2a08a6add4 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetsCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetsCommandTest.java @@ -9,8 +9,9 @@ import edu.harvard.iq.dataverse.mocks.MocksFactory; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.Arrays; diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdatePermissionRootCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdatePermissionRootCommandTest.java index 3dced0aaf05..d2e64b3292d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdatePermissionRootCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdatePermissionRootCommandTest.java @@ -7,10 +7,11 @@ import edu.harvard.iq.dataverse.engine.TestCommandContext; import edu.harvard.iq.dataverse.engine.TestDataverseEngine; import edu.harvard.iq.dataverse.engine.command.exception.CommandException; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/export/OpenAireExporterTest.java b/src/test/java/edu/harvard/iq/dataverse/export/OpenAireExporterTest.java index aa1668201ba..18f548b7f48 100644 --- a/src/test/java/edu/harvard/iq/dataverse/export/OpenAireExporterTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/export/OpenAireExporterTest.java @@ -5,7 +5,7 @@ import io.gdcc.spi.export.ExportDataProvider; import io.gdcc.spi.export.XMLExporter; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -19,7 +19,7 @@ import jakarta.json.JsonReader; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.xml.sax.ErrorHandler; import org.xml.sax.InputSource; diff --git a/src/test/java/edu/harvard/iq/dataverse/export/SchemaDotOrgExporterTest.java b/src/test/java/edu/harvard/iq/dataverse/export/SchemaDotOrgExporterTest.java index 47333e5c1d9..7183f5bd497 100644 --- a/src/test/java/edu/harvard/iq/dataverse/export/SchemaDotOrgExporterTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/export/SchemaDotOrgExporterTest.java @@ -40,9 +40,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import static org.junit.Assert.assertFalse; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; /** * For docs see {@link SchemaDotOrgExporter}. diff --git a/src/test/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBeanTest.java index 5e39e5fc4cb..9337949f605 100644 --- a/src/test/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/externaltools/ExternalToolServiceBeanTest.java @@ -13,10 +13,9 @@ import java.util.List; import jakarta.json.Json; import jakarta.json.JsonObjectBuilder; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class ExternalToolServiceBeanTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/externaltools/ExternalToolTest.java b/src/test/java/edu/harvard/iq/dataverse/externaltools/ExternalToolTest.java index e236ab5ff16..4cec93581c2 100644 --- a/src/test/java/edu/harvard/iq/dataverse/externaltools/ExternalToolTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/externaltools/ExternalToolTest.java @@ -1,10 +1,11 @@ package edu.harvard.iq.dataverse.externaltools; import jakarta.json.JsonObject; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import edu.harvard.iq.dataverse.DataFileServiceBean; + import java.util.ArrayList; import java.util.List; diff --git a/src/test/java/edu/harvard/iq/dataverse/feedback/FeedbackUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/feedback/FeedbackUtilTest.java index ab624a69dad..ecb7014af7d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/feedback/FeedbackUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/feedback/FeedbackUtilTest.java @@ -34,10 +34,10 @@ import jakarta.json.JsonReader; import jakarta.mail.internet.AddressException; import jakarta.mail.internet.InternetAddress; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import org.junit.BeforeClass; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeAll; import org.mockito.Mockito; public class FeedbackUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/ingest/IngestFrequencyTest.java b/src/test/java/edu/harvard/iq/dataverse/ingest/IngestFrequencyTest.java index e9191fab559..96e314324ab 100644 --- a/src/test/java/edu/harvard/iq/dataverse/ingest/IngestFrequencyTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/ingest/IngestFrequencyTest.java @@ -6,7 +6,7 @@ import edu.harvard.iq.dataverse.ingest.tabulardata.TabularDataFileReader; import edu.harvard.iq.dataverse.ingest.tabulardata.TabularDataIngest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import jakarta.ejb.EJB; import java.io.File; @@ -16,8 +16,8 @@ import java.io.BufferedInputStream; import java.util.Collection; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; public class IngestFrequencyTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/ingest/IngestUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/ingest/IngestUtilTest.java index b5160a72166..4dfedf5aa17 100644 --- a/src/test/java/edu/harvard/iq/dataverse/ingest/IngestUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/ingest/IngestUtilTest.java @@ -17,13 +17,13 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; -import jakarta.json.Json; -import jakarta.json.JsonArray; + import jakarta.validation.ConstraintViolation; import org.dataverse.unf.UNFUtil; import org.dataverse.unf.UnfException; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class IngestUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/ingest/IngestableDataCheckerTest.java b/src/test/java/edu/harvard/iq/dataverse/ingest/IngestableDataCheckerTest.java index ea9e378739b..305dcf82260 100644 --- a/src/test/java/edu/harvard/iq/dataverse/ingest/IngestableDataCheckerTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/ingest/IngestableDataCheckerTest.java @@ -10,15 +10,18 @@ import java.io.IOException; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; -import org.apache.commons.io.FileUtils; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; -import org.junit.Rule; -import org.junit.rules.TemporaryFolder; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/ingest/metadataextraction/impl/plugins/netcdf/NetcdfFileMetadataExtractorTest.java b/src/test/java/edu/harvard/iq/dataverse/ingest/metadataextraction/impl/plugins/netcdf/NetcdfFileMetadataExtractorTest.java index 203fc96e70a..343d7f39cf5 100644 --- a/src/test/java/edu/harvard/iq/dataverse/ingest/metadataextraction/impl/plugins/netcdf/NetcdfFileMetadataExtractorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/ingest/metadataextraction/impl/plugins/netcdf/NetcdfFileMetadataExtractorTest.java @@ -5,8 +5,7 @@ import java.io.File; import java.util.Map; import java.util.Set; -import static org.junit.Assert.assertNull; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; public class NetcdfFileMetadataExtractorTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/csv/CSVFileReaderTest.java b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/csv/CSVFileReaderTest.java index cdc4249ba94..0d9f7d7ccce 100644 --- a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/csv/CSVFileReaderTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/csv/CSVFileReaderTest.java @@ -22,8 +22,9 @@ import java.util.logging.Logger; import org.dataverse.unf.UNFUtil; import org.dataverse.unf.UnfException; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/DTAFileReaderTest.java b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/DTAFileReaderTest.java index 2f8908c5920..113e9be6b54 100644 --- a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/DTAFileReaderTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/DTAFileReaderTest.java @@ -5,8 +5,9 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class DTAFileReaderTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/DataReaderTest.java b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/DataReaderTest.java index 8ac84d9693a..940d625115c 100644 --- a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/DataReaderTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/DataReaderTest.java @@ -4,8 +4,8 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.ByteBuffer; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; /** * @author oscardssmith diff --git a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/NewDTAFileReaderTest.java b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/NewDTAFileReaderTest.java index 3c8c0a0d224..6960a6d0e7f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/NewDTAFileReaderTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/NewDTAFileReaderTest.java @@ -4,19 +4,16 @@ import edu.harvard.iq.dataverse.datavariable.DataVariable; import edu.harvard.iq.dataverse.datavariable.VariableCategory; import edu.harvard.iq.dataverse.ingest.tabulardata.TabularDataIngest; -import edu.harvard.iq.dataverse.ingest.tabulardata.impl.plugins.dta.DataReader; + import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.nio.ByteBuffer; import java.util.List; import org.apache.commons.io.FileUtils; -import org.junit.Test; -import static org.junit.Assert.*; -import org.junit.Ignore; -import org.junit.Assert; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; public class NewDTAFileReaderTest { NewDTAFileReader instance; diff --git a/src/test/java/edu/harvard/iq/dataverse/locality/StorageSiteUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/locality/StorageSiteUtilTest.java index f35296e560b..6bc7aaad186 100644 --- a/src/test/java/edu/harvard/iq/dataverse/locality/StorageSiteUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/locality/StorageSiteUtilTest.java @@ -4,8 +4,11 @@ import java.util.ArrayList; import java.util.List; import jakarta.json.Json; +import jakarta.json.JsonObject; import jakarta.json.JsonObjectBuilder; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; public class StorageSiteUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/makedatacount/MakeDataCountLoggingServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/makedatacount/MakeDataCountLoggingServiceBeanTest.java index ef30df11e3c..c1051a57db8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/makedatacount/MakeDataCountLoggingServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/makedatacount/MakeDataCountLoggingServiceBeanTest.java @@ -16,11 +16,13 @@ import edu.harvard.iq.dataverse.makedatacount.MakeDataCountLoggingServiceBean.MakeDataCountEntry; import edu.harvard.iq.dataverse.mocks.MocksFactory; import java.util.Date; -import jakarta.faces.context.FacesContext; + import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertThat; -import org.junit.Test; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.Test; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/makedatacount/MakeDataCountUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/makedatacount/MakeDataCountUtilTest.java index 11664b4e18b..5a0ad3d8754 100644 --- a/src/test/java/edu/harvard/iq/dataverse/makedatacount/MakeDataCountUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/makedatacount/MakeDataCountUtilTest.java @@ -6,8 +6,9 @@ import java.util.List; import jakarta.json.Json; import jakarta.json.JsonObject; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class MakeDataCountUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/metrics/MetricsUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/metrics/MetricsUtilTest.java index 41aa2dfb5f3..827e450eff7 100644 --- a/src/test/java/edu/harvard/iq/dataverse/metrics/MetricsUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/metrics/MetricsUtilTest.java @@ -12,17 +12,15 @@ import jakarta.json.JsonArray; import jakarta.json.JsonArrayBuilder; import jakarta.json.JsonObject; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; -@RunWith(Enclosed.class) public class MetricsUtilTest { public static class MetricsUtilNoParamTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/mydata/MyDataUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/mydata/MyDataUtilTest.java index 69996ce71fe..5aa840981ad 100644 --- a/src/test/java/edu/harvard/iq/dataverse/mydata/MyDataUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/mydata/MyDataUtilTest.java @@ -1,26 +1,15 @@ package edu.harvard.iq.dataverse.mydata; -import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeTrue; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EmptySource; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.NullSource; -import org.junit.experimental.theories.DataPoints; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import java.util.List; -/** - * Theories allows to add more formal tests to our code. In a way JUnit Theories behave - * much like mathematical theories that hold for every element of a large (infinite) set. - * JUnit will combine every possible combination (cartesian product) of datapoints and - * pass these to the tests annotated with @Theory. The assume statements make sure, only - * valid datapoints are tested in each Theory. - * - * @Datapoints - defines an array of values to test on - * @Datapoint - stores one single value - * - * JUnit will no longer maintain a JUnit 4 Theories equivalent in the JUnit 5 codebase, as - * mentioned in a discussion here: https://github.com/junit-team/junit5/pull/1422#issuecomment-389644868 - */ +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; @RunWith(Theories.class) public class MyDataUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/mydata/SolrQueryFormatterTest.java b/src/test/java/edu/harvard/iq/dataverse/mydata/SolrQueryFormatterTest.java index c15bc280316..9cd4cfcf41f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/mydata/SolrQueryFormatterTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/mydata/SolrQueryFormatterTest.java @@ -5,8 +5,9 @@ */ package edu.harvard.iq.dataverse.mydata; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; import java.lang.NullPointerException; import java.util.ArrayList; @@ -16,14 +17,13 @@ import java.util.List; import java.util.Random; import java.util.Set; +import java.util.stream.Stream; import org.apache.commons.lang3.StringUtils; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordResetDataTest.java b/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordResetDataTest.java index 9d5b5e0e70e..0d04d715d19 100644 --- a/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordResetDataTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordResetDataTest.java @@ -5,12 +5,13 @@ */ package edu.harvard.iq.dataverse.passwordreset; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class PasswordResetDataTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordValidatorTest.java b/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordValidatorTest.java index f6d02e35ddf..6812ebf382c 100644 --- a/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordValidatorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordValidatorTest.java @@ -1,14 +1,12 @@ package edu.harvard.iq.dataverse.passwordreset; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import java.util.Arrays; -import java.util.Collection; +import java.util.stream.Stream; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; @RunWith(Parameterized.class) public class PasswordValidatorTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/pidproviders/PidUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/pidproviders/PidUtilTest.java index 3a35303d7bb..52dab3ddb6d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/pidproviders/PidUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/pidproviders/PidUtilTest.java @@ -11,15 +11,17 @@ import jakarta.json.JsonObjectBuilder; import jakarta.ws.rs.NotFoundException; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; + import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.mockito.junit.MockitoJUnitRunner; -import org.junit.Before; -import org.junit.Ignore; +import org.mockito.junit.jupiter.MockitoExtension; + import static org.junit.jupiter.api.Assertions.*; /** diff --git a/src/test/java/edu/harvard/iq/dataverse/privateurl/PrivateUrlUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/privateurl/PrivateUrlUtilTest.java index 3984f972308..8c9e0261bfa 100644 --- a/src/test/java/edu/harvard/iq/dataverse/privateurl/PrivateUrlUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/privateurl/PrivateUrlUtilTest.java @@ -14,7 +14,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Assert; + import org.junit.jupiter.api.Test; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.params.ParameterizedTest; diff --git a/src/test/java/edu/harvard/iq/dataverse/provenance/ProvInvestigatorTest.java b/src/test/java/edu/harvard/iq/dataverse/provenance/ProvInvestigatorTest.java index efa83fbb950..20b62bcbb0e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/provenance/ProvInvestigatorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/provenance/ProvInvestigatorTest.java @@ -6,14 +6,15 @@ package edu.harvard.iq.dataverse.provenance; import com.google.gson.JsonParser; -import edu.harvard.iq.dataverse.NonEssentialTests; import java.io.IOException; import java.util.HashMap; import java.util.logging.Logger; -import static org.junit.Assert.*; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import static org.junit.jupiter.api.Assertions.*; + +import edu.harvard.iq.dataverse.util.testing.Tags; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/repositorystorageabstractionlayer/RepositoryStorageAbstractionLayerUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/repositorystorageabstractionlayer/RepositoryStorageAbstractionLayerUtilTest.java index b45da0f68f8..99fd3b2766f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/repositorystorageabstractionlayer/RepositoryStorageAbstractionLayerUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/repositorystorageabstractionlayer/RepositoryStorageAbstractionLayerUtilTest.java @@ -6,8 +6,8 @@ import java.util.List; import jakarta.json.JsonArray; import jakarta.json.JsonObject; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; public class RepositoryStorageAbstractionLayerUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/search/IndexUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/search/IndexUtilTest.java index 6599f829673..84ea519e71f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/search/IndexUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/search/IndexUtilTest.java @@ -1,13 +1,13 @@ package edu.harvard.iq.dataverse.search; import java.util.Arrays; -import java.util.List; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; public class IndexUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/search/SearchFilesServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/search/SearchFilesServiceBeanTest.java index 0ea5597b905..c9f9eb67130 100644 --- a/src/test/java/edu/harvard/iq/dataverse/search/SearchFilesServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/search/SearchFilesServiceBeanTest.java @@ -1,7 +1,7 @@ package edu.harvard.iq.dataverse.search; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; public class SearchFilesServiceBeanTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/search/SearchIncludeFragmentTest.java b/src/test/java/edu/harvard/iq/dataverse/search/SearchIncludeFragmentTest.java index f94da336ca3..234d72c0d19 100644 --- a/src/test/java/edu/harvard/iq/dataverse/search/SearchIncludeFragmentTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/search/SearchIncludeFragmentTest.java @@ -5,7 +5,7 @@ import edu.harvard.iq.dataverse.MetadataBlock; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.Arrays; diff --git a/src/test/java/edu/harvard/iq/dataverse/search/SolrSearchResultTest.java b/src/test/java/edu/harvard/iq/dataverse/search/SolrSearchResultTest.java index e85084f96ab..967b9bbdd5e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/search/SolrSearchResultTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/search/SolrSearchResultTest.java @@ -4,15 +4,15 @@ import jakarta.json.JsonObject; import jakarta.json.JsonObjectBuilder; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; // **************************************************************************************** // The following tests test the setPublicationStatuses method aiming for 100% prime diff --git a/src/test/java/edu/harvard/iq/dataverse/search/SortByTest.java b/src/test/java/edu/harvard/iq/dataverse/search/SortByTest.java index 956063d4e1f..f2c31f137a2 100644 --- a/src/test/java/edu/harvard/iq/dataverse/search/SortByTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/search/SortByTest.java @@ -1,12 +1,12 @@ package edu.harvard.iq.dataverse.search; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SortByTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/sitemap/SiteMapUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/sitemap/SiteMapUtilTest.java index 4f2b00bbea4..41b13417a23 100644 --- a/src/test/java/edu/harvard/iq/dataverse/sitemap/SiteMapUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/sitemap/SiteMapUtilTest.java @@ -21,10 +21,10 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; public class SiteMapUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/userdata/UserListMakerTest.java b/src/test/java/edu/harvard/iq/dataverse/userdata/UserListMakerTest.java index b744db5be20..10c07cf0ef5 100644 --- a/src/test/java/edu/harvard/iq/dataverse/userdata/UserListMakerTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/userdata/UserListMakerTest.java @@ -1,6 +1,6 @@ package edu.harvard.iq.dataverse.userdata; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import org.junit.jupiter.api.AfterEach; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/BitSetTest.java b/src/test/java/edu/harvard/iq/dataverse/util/BitSetTest.java index 5aa37e8b05c..51cd409c3f2 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/BitSetTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/BitSetTest.java @@ -7,12 +7,13 @@ import java.util.Arrays; import java.util.EnumSet; import java.util.List; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/util/BundleUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/util/BundleUtilTest.java index 5be06a5e07b..c7dc13fcaff 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/BundleUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/BundleUtilTest.java @@ -2,11 +2,13 @@ import java.util.Arrays; import java.util.List; -import java.util.Locale; import java.util.MissingResourceException; -import java.util.ResourceBundle; -import org.junit.Test; -import static org.junit.Assert.assertEquals; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class BundleUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/util/FileSortFieldAndOrderTest.java b/src/test/java/edu/harvard/iq/dataverse/util/FileSortFieldAndOrderTest.java index 0ad76832952..84a200542fe 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/FileSortFieldAndOrderTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/FileSortFieldAndOrderTest.java @@ -1,8 +1,8 @@ package edu.harvard.iq.dataverse.util; import edu.harvard.iq.dataverse.search.SortBy; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class FileSortFieldAndOrderTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/util/FileUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/util/FileUtilTest.java index 1d481f18cf5..956b54a08ef 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/FileUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/FileUtilTest.java @@ -8,10 +8,6 @@ import edu.harvard.iq.dataverse.FileMetadata; import edu.harvard.iq.dataverse.Guestbook; import edu.harvard.iq.dataverse.TermsOfUseAndAccess; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import edu.harvard.iq.dataverse.*; -import edu.harvard.iq.dataverse.api.UtilIT; import edu.harvard.iq.dataverse.license.License; import edu.harvard.iq.dataverse.util.FileUtil.FileCitationExtension; @@ -19,26 +15,21 @@ import java.io.IOException; import java.time.LocalDate; import java.net.URI; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collection; import java.util.logging.Level; import java.util.logging.Logger; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.fail; - -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -@RunWith(Enclosed.class) +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + public class FileUtilTest { @RunWith(Parameterized.class) diff --git a/src/test/java/edu/harvard/iq/dataverse/util/FirstNameTest.java b/src/test/java/edu/harvard/iq/dataverse/util/FirstNameTest.java index 972a06ef99e..1925094a2d8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/FirstNameTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/FirstNameTest.java @@ -1,10 +1,8 @@ package edu.harvard.iq.dataverse.util; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import edu.harvard.iq.dataverse.util.FirstNames; - -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/util/JhoveFileTypeTest.java b/src/test/java/edu/harvard/iq/dataverse/util/JhoveFileTypeTest.java index 88a8d24c772..2a08426ac6c 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/JhoveFileTypeTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/JhoveFileTypeTest.java @@ -5,10 +5,10 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.apache.commons.io.FileUtils; -import org.junit.AfterClass; -import static org.junit.Assert.assertEquals; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class JhoveFileTypeTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/util/JsfHelperTest.java b/src/test/java/edu/harvard/iq/dataverse/util/JsfHelperTest.java index 545d3b1a31f..466edc67b60 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/JsfHelperTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/JsfHelperTest.java @@ -4,19 +4,17 @@ package edu.harvard.iq.dataverse.util; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import java.util.Arrays; -import java.util.Collection; +import java.util.stream.Stream; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/util/LruCacheTest.java b/src/test/java/edu/harvard/iq/dataverse/util/LruCacheTest.java index b7ecff4ed8b..f2c2a09d416 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/LruCacheTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/LruCacheTest.java @@ -1,9 +1,10 @@ package edu.harvard.iq.dataverse.util; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/util/MailUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/util/MailUtilTest.java index 76e447b3faa..89b0a7a738b 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/MailUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/MailUtilTest.java @@ -5,7 +5,7 @@ import edu.harvard.iq.dataverse.branding.BrandingUtil; import edu.harvard.iq.dataverse.settings.SettingsServiceBean; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; @@ -14,7 +14,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; @ExtendWith(MockitoExtension.class) @TestMethodOrder(OrderAnnotation.class) diff --git a/src/test/java/edu/harvard/iq/dataverse/util/OrganizationsTest.java b/src/test/java/edu/harvard/iq/dataverse/util/OrganizationsTest.java index 3b6cf4a7242..fb6a8e14fcd 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/OrganizationsTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/OrganizationsTest.java @@ -1,10 +1,8 @@ package edu.harvard.iq.dataverse.util; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import edu.harvard.iq.dataverse.util.Organizations; - -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/util/PersonOrOrgUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/util/PersonOrOrgUtilTest.java index 28a999b55b2..f32f6b0873a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/PersonOrOrgUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/PersonOrOrgUtilTest.java @@ -2,9 +2,9 @@ import edu.harvard.iq.dataverse.util.json.JsonUtil; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; import jakarta.json.JsonObject; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/StringUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/util/StringUtilTest.java index aa2d20362cb..f999b48ea9c 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/StringUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/StringUtilTest.java @@ -1,8 +1,8 @@ package edu.harvard.iq.dataverse.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import java.util.Collection; @@ -10,203 +10,89 @@ import java.util.Optional; import java.util.stream.Stream; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.MethodSource; - -/** - * - * @author michael - */ -@RunWith(Enclosed.class) -public class StringUtilTest { - - public StringUtilTest() { - } +class StringUtilTest { - @BeforeClass - public static void setUpClass() { + /** + * Test of isEmpty method, of class StringUtil. + */ + @ParameterizedTest + @CsvSource(value = { + "false, a", + "true, NULL", + "true, ''", + "true, ' '", + "true, \t", + "true, \t \t \n" + }, nullValues = "NULL") + void testIsEmpty(boolean isValid, String inputString) { + assertEquals( isValid, StringUtil.isEmpty(inputString) ); } - @AfterClass - public static void tearDownClass() { + /** + * Test of isAlphaNumeric method, of class StringUtil. + */ + @ParameterizedTest + @CsvSource({ + "true,abc", + "true,1230", + "true,1230abc", + "true,1230abcABC", + "false,1230abcABC#" + }) + void testIsAlphaNumeric(boolean isValid, String inputString) { + assertEquals(isValid, StringUtil.isAlphaNumeric(inputString) ); } - @Before - public void setUp() { + /** + * Test of isAlphaNumericChar method, of class StringUtil. + */ + @ParameterizedTest + @CsvSource({ + "true,'a'", + "true,'f'", + "true,'z'", + "true,'0'", + "true,'1'", + "true,'9'", + "true,'A'", + "true,'G'", + "true,'Z'", + "false,'@'" + }) + void testIsAlphaNumericChar(boolean isValid, char inputChar) { + assertEquals(isValid, StringUtil.isAlphaNumericChar(inputChar) ); } - @After - public void tearDown() { - } - - @RunWith(Parameterized.class) - public static class TestIsEmpty { - - public boolean isValid; - public String inputString; + @ParameterizedTest + @CsvSource(value = { + // interface-based partitioning + "NULL, NULL, NULL", + "NULL, '', NULL", + "NULL, d, NULL", - public TestIsEmpty(boolean isValid, String inputString) { - this.isValid = isValid; - this.inputString = inputString; - } - - @Parameters - public static Collection parameters() { - return Arrays.asList( - new Object[][] { - { true, null }, - { true, "" }, - { true, " " }, - { true, "\t" }, - { true, "\t \t \n" }, - { false, "a" }, - } - ); - } - - /** - * Test of isEmpty method, of class StringUtil. - */ - @Test - public void testIsEmpty() { - assertEquals( isValid, StringUtil.isEmpty(inputString) ); - } - } - - @RunWith(Parameterized.class) - public static class TestIsAlphaNumeric { - - public boolean isValid; - public String inputString; + "'', NULL, ''", + "'', '', ''", + "'', abcdfg, ''", - public TestIsAlphaNumeric(boolean isValid, String inputString) { - this.isValid = isValid; - this.inputString = inputString; - } - - @Parameters - public static Collection parameters() { - return Arrays.asList( - new Object[][] { - { true, "abc" }, - { true, "1230" }, - { true, "1230abc" }, - { true, "1230abcABC" }, - { false, "1230abcABC#" }, - } - ); - } - - /** - * Test of isAlphaNumeric method, of class StringUtil. - */ - @Test - public void testIsAlphaNumeric() { - assertEquals( isValid, StringUtil.isAlphaNumeric(inputString) ); - } - } - - @RunWith(Parameterized.class) - public static class TestIsAlphaNumericChar { - - public boolean isValid; - public char inputChar; - - public TestIsAlphaNumericChar(boolean isValid, char inputChar) { - this.isValid = isValid; - this.inputChar = inputChar; - } - - @Parameters - public static Collection parameters() { - return Arrays.asList( - new Object[][] { - { true, 'a' }, - { true, 'f' }, - { true, 'z' }, - { true, '0' }, - { true, '1' }, - { true, '9' }, - { true, 'A' }, - { true, 'G' }, - { true, 'Z' }, - { false, '@' }, - } - ); - } - - /** - * Test of isAlphaNumericChar method, of class StringUtil. - */ - @Test - public void testIsAlphaNumericChar() { - assertEquals( isValid, StringUtil.isAlphaNumericChar(inputChar) ); - } - } - - @RunWith(Parameterized.class) - public static class TestSubstringIncludingLast { - - public String str; - public String separator; - public String expectedString; + "abcdfg, NULL, ''", + "abcdfg, '', ''", + "abcdfg, d, dfg", - public TestSubstringIncludingLast(String str, String separator, String expectedString) { - this.str = str; - this.separator = separator; - this.expectedString = expectedString; - } - - @Parameters - public static Collection parameters() { - return Arrays.asList( - new Object[][] { - // interface-based partitioning - {null, null, null}, - {null, "", null}, - {null, "d", null}, - - {"", null, ""}, - {"", "", ""}, - {"", "abcdfg", ""}, - - {"abcdfg", null, ""}, - {"abcdfg", "", ""}, - {"abcdfg", "d", "dfg"}, - - // functionality-based partitioning - {"abcdfg" , null, ""}, - {"abcdfg", "h", ""}, - {"abcdfg", "b", "bcdfg"}, - } - ); - } - - @Test - public void testSubstringIncludingLast() { - assertEquals( expectedString, StringUtil.substringIncludingLast(str, separator) ); - } + // functionality-based partitioning + "abcdfg, NULL, ''", + "abcdfg, h, ''", + "abcdfg, b, bcdfg" + }, nullValues = "NULL") + void testSubstringIncludingLast(String str, String separator, String expectedString) { + assertEquals( expectedString, StringUtil.substringIncludingLast(str, separator) ); } - @RunWith(Parameterized.class) - public static class TestToOption { - - public String inputString; - public Optional expected; - - public TestToOption(String inputString, Optional expected) { - this.inputString = inputString; - this.expected = expected; - } - @Parameters public static Collection parameters() { return Arrays.asList( diff --git a/src/test/java/edu/harvard/iq/dataverse/util/UrlSignerUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/util/UrlSignerUtilTest.java index 2b9d507758f..09739b67023 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/UrlSignerUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/UrlSignerUtilTest.java @@ -1,12 +1,12 @@ package edu.harvard.iq.dataverse.util; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.logging.Level; import java.util.logging.Logger; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class UrlSignerUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/util/bagit/BagChecksumTypeTest.java b/src/test/java/edu/harvard/iq/dataverse/util/bagit/BagChecksumTypeTest.java index 2dfaf2b2371..905f8609276 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/bagit/BagChecksumTypeTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/bagit/BagChecksumTypeTest.java @@ -3,7 +3,7 @@ import org.apache.commons.io.IOUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Map; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/bagit/BagValidationTest.java b/src/test/java/edu/harvard/iq/dataverse/util/bagit/BagValidationTest.java index 4f7a22833e7..87b3382120d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/bagit/BagValidationTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/bagit/BagValidationTest.java @@ -3,7 +3,7 @@ import edu.harvard.iq.dataverse.util.bagit.BagValidation.FileValidationResult; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.nio.file.Path; import java.util.Optional; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/bagit/BagValidatorTest.java b/src/test/java/edu/harvard/iq/dataverse/util/bagit/BagValidatorTest.java index 24c45a8e75c..bb0ea50071d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/bagit/BagValidatorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/bagit/BagValidatorTest.java @@ -8,8 +8,8 @@ import org.apache.commons.lang3.RandomStringUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.nio.file.Path; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/bagit/FileChecksumValidationJobTest.java b/src/test/java/edu/harvard/iq/dataverse/util/bagit/FileChecksumValidationJobTest.java index 63a2650a5ef..08e853a58df 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/bagit/FileChecksumValidationJobTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/bagit/FileChecksumValidationJobTest.java @@ -5,7 +5,7 @@ import org.apache.commons.io.IOUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.io.InputStream; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/bagit/ManifestReaderTest.java b/src/test/java/edu/harvard/iq/dataverse/util/bagit/ManifestReaderTest.java index e31e2fcc87b..3e84fda92b5 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/bagit/ManifestReaderTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/bagit/ManifestReaderTest.java @@ -5,7 +5,7 @@ import edu.harvard.iq.dataverse.util.bagit.data.FileDataProviderFactory; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.nio.file.Path; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/bagit/data/DataFileDataProviderTest.java b/src/test/java/edu/harvard/iq/dataverse/util/bagit/data/DataFileDataProviderTest.java index 50ebaff2b7c..1d5e20a985e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/bagit/data/DataFileDataProviderTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/bagit/data/DataFileDataProviderTest.java @@ -3,7 +3,7 @@ import edu.harvard.iq.dataverse.DataFile; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.nio.file.Path; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/bagit/data/FileDataProviderFactoryTest.java b/src/test/java/edu/harvard/iq/dataverse/util/bagit/data/FileDataProviderFactoryTest.java index c5eadb09811..f43a0c78284 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/bagit/data/FileDataProviderFactoryTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/bagit/data/FileDataProviderFactoryTest.java @@ -2,7 +2,7 @@ import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.nio.file.Path; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/bagit/data/FolderDataProviderTest.java b/src/test/java/edu/harvard/iq/dataverse/util/bagit/data/FolderDataProviderTest.java index 7e892180bed..e403b32b1b3 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/bagit/data/FolderDataProviderTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/bagit/data/FolderDataProviderTest.java @@ -2,7 +2,7 @@ import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.io.IOException; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/bagit/data/ZipFileDataProviderTest.java b/src/test/java/edu/harvard/iq/dataverse/util/bagit/data/ZipFileDataProviderTest.java index 084fb6ed50f..67bd13d61e4 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/bagit/data/ZipFileDataProviderTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/bagit/data/ZipFileDataProviderTest.java @@ -5,7 +5,7 @@ import org.apache.commons.compress.archivers.zip.ZipFile; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.io.InputStream; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerFactoryTest.java b/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerFactoryTest.java index d3f1dbcf805..1bff1e08baf 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerFactoryTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerFactoryTest.java @@ -4,12 +4,12 @@ import edu.harvard.iq.dataverse.util.bagit.BagValidator; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerPostProcessorTest.java b/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerPostProcessorTest.java index f8c7565af7c..064fa8b440f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerPostProcessorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerPostProcessorTest.java @@ -5,7 +5,7 @@ import edu.harvard.iq.dataverse.mocks.MocksFactory; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.nio.file.Path; import java.util.ArrayList; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerTest.java b/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerTest.java index b3687285f6c..7a58a8e04c1 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerTest.java @@ -14,8 +14,8 @@ import edu.harvard.iq.dataverse.util.bagit.data.StringDataProvider; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.io.File; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/file/CreateDataFileResultTest.java b/src/test/java/edu/harvard/iq/dataverse/util/file/CreateDataFileResultTest.java index 7c392418de9..59d3ac15f11 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/file/CreateDataFileResultTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/file/CreateDataFileResultTest.java @@ -3,7 +3,7 @@ import edu.harvard.iq.dataverse.DataFile; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/json/DatasetVersionDTOTest.java b/src/test/java/edu/harvard/iq/dataverse/util/json/DatasetVersionDTOTest.java index c7077f936a0..08c4a78795a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/json/DatasetVersionDTOTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/json/DatasetVersionDTOTest.java @@ -17,12 +17,12 @@ import java.util.HashSet; import java.util.List; import java.util.Scanner; -import junit.framework.Assert; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/util/json/JsonParserTest.java b/src/test/java/edu/harvard/iq/dataverse/util/json/JsonParserTest.java index 2339d3bf6a7..96437022da8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/json/JsonParserTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/json/JsonParserTest.java @@ -27,10 +27,11 @@ import edu.harvard.iq.dataverse.license.LicenseServiceBean; import edu.harvard.iq.dataverse.mocks.MockDatasetFieldSvc; import edu.harvard.iq.dataverse.settings.SettingsServiceBean; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import jakarta.json.Json; @@ -58,9 +59,9 @@ import java.util.Set; import java.util.TimeZone; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * diff --git a/src/test/java/edu/harvard/iq/dataverse/util/json/JsonPrinterTest.java b/src/test/java/edu/harvard/iq/dataverse/util/json/JsonPrinterTest.java index 378158f6ff0..5d7e8eaa50e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/json/JsonPrinterTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/json/JsonPrinterTest.java @@ -25,10 +25,11 @@ import jakarta.json.JsonString; import edu.harvard.iq.dataverse.util.BundleUtil; -import org.junit.Test; -import org.junit.Before; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeEach; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/json/JsonUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/util/json/JsonUtilTest.java index 847fbfc9cba..725862db7ba 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/json/JsonUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/json/JsonUtilTest.java @@ -1,7 +1,7 @@ package edu.harvard.iq.dataverse.util.json; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; public class JsonUtilTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/util/shapefile/ShapefileHandlerTest.java b/src/test/java/edu/harvard/iq/dataverse/util/shapefile/ShapefileHandlerTest.java index 8aa10c9667f..568cec3a9a9 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/shapefile/ShapefileHandlerTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/shapefile/ShapefileHandlerTest.java @@ -11,16 +11,18 @@ import edu.harvard.iq.dataverse.util.ShapefileHandler; import static edu.harvard.iq.dataverse.util.ShapefileHandler.SHP_XML_EXTENSION; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.Arrays; import java.util.List; import java.io.File; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; - -import org.junit.rules.TemporaryFolder; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.FileInputStream; import java.io.FileNotFoundException; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/xml/XmlPrinterTest.java b/src/test/java/edu/harvard/iq/dataverse/util/xml/XmlPrinterTest.java index 8b027b797c5..1a190389ed5 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/xml/XmlPrinterTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/xml/XmlPrinterTest.java @@ -1,7 +1,7 @@ package edu.harvard.iq.dataverse.util.xml; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class XmlPrinterTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/util/xml/XmlValidatorTest.java b/src/test/java/edu/harvard/iq/dataverse/util/xml/XmlValidatorTest.java index dbb87e9e560..6a870a7c3bf 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/xml/XmlValidatorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/xml/XmlValidatorTest.java @@ -1,20 +1,19 @@ package edu.harvard.iq.dataverse.util.xml; -import edu.harvard.iq.dataverse.NonEssentialTests; - import java.io.FileNotFoundException; import java.io.IOException; import java.net.URL; import javax.xml.parsers.ParserConfigurationException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import edu.harvard.iq.dataverse.util.testing.Tags; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; public class XmlValidatorTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/validation/PasswordValidatorUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/validation/PasswordValidatorUtilTest.java index b574ac4a082..6cec8955215 100644 --- a/src/test/java/edu/harvard/iq/dataverse/validation/PasswordValidatorUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/validation/PasswordValidatorUtilTest.java @@ -5,24 +5,18 @@ */ package edu.harvard.iq.dataverse.validation; -import edu.harvard.iq.dataverse.util.BundleUtil; import edu.harvard.iq.dataverse.util.xml.html.HtmlPrinter; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; import java.util.List; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import static org.junit.Assert.*; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.passay.CharacterRule; import org.passay.EnglishCharacterData; From 955bc36f68922a76c9e18cb4da6a8e917b9f548d Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Fri, 18 Aug 2023 16:57:03 +0200 Subject: [PATCH 03/17] build(test): migrate Before, After and Ignore to JUnit 5 equivalents #9782 --- .../AuxiliaryFileServiceBeanTest.java | 2 +- .../edu/harvard/iq/dataverse/CartTest.java | 4 +-- .../iq/dataverse/DataFileServiceBeanTest.java | 2 +- .../iq/dataverse/DatasetFieldTypeTest.java | 8 +++--- .../dataverse/DatasetFieldValidatorTest.java | 8 +++--- .../edu/harvard/iq/dataverse/DatasetTest.java | 4 +-- .../DatasetVersionServiceBeanTest.java | 4 +-- .../harvard/iq/dataverse/DataverseTest.java | 2 +- .../harvard/iq/dataverse/GlobalIdTest.java | 6 ++-- .../iq/dataverse/PermissionsWrapperTest.java | 4 +-- .../PersistentIdentifierServiceBeanTest.java | 2 +- .../iq/dataverse/RoleAssignmentTest.java | 4 +-- .../actionlogging/ActionLogRecordTest.java | 4 +-- .../iq/dataverse/api/AbstractApiBeanTest.java | 2 +- .../harvard/iq/dataverse/api/AccessIT.java | 4 +-- .../edu/harvard/iq/dataverse/api/AdminIT.java | 4 +-- .../iq/dataverse/api/AuxiliaryFilesIT.java | 2 +- .../edu/harvard/iq/dataverse/api/BagIT.java | 4 +-- .../iq/dataverse/api/BatchImportIT.java | 2 +- .../iq/dataverse/api/BuiltinUsersIT.java | 2 +- .../iq/dataverse/api/ConfirmEmailIT.java | 2 +- .../iq/dataverse/api/DataRetrieverApiIT.java | 2 +- .../harvard/iq/dataverse/api/DatasetsIT.java | 8 +++--- .../iq/dataverse/api/DataversesIT.java | 4 +-- .../iq/dataverse/api/DataversesTest.java | 2 +- .../iq/dataverse/api/DeactivateUsersIT.java | 2 +- .../iq/dataverse/api/DeleteUsersIT.java | 2 +- .../iq/dataverse/api/DownloadFilesIT.java | 2 +- .../api/DownloadInstanceWriterTest.java | 2 +- .../iq/dataverse/api/DuplicateFilesIT.java | 2 +- .../harvard/iq/dataverse/api/EditDDIIT.java | 2 +- .../iq/dataverse/api/ExternalToolsIT.java | 10 +++---- .../iq/dataverse/api/FeedbackApiIT.java | 2 +- .../iq/dataverse/api/FileMetadataIT.java | 8 +++--- .../iq/dataverse/api/FileTypeDetectionIT.java | 2 +- .../edu/harvard/iq/dataverse/api/FilesIT.java | 2 +- .../edu/harvard/iq/dataverse/api/FitsIT.java | 2 +- .../iq/dataverse/api/HarvestingClientsIT.java | 2 +- .../iq/dataverse/api/HarvestingServerIT.java | 4 +-- .../iq/dataverse/api/InReviewWorkflowIT.java | 2 +- .../edu/harvard/iq/dataverse/api/IndexIT.java | 6 ++-- .../iq/dataverse/api/InvalidCharactersIT.java | 2 +- .../harvard/iq/dataverse/api/IpGroupsIT.java | 2 +- .../harvard/iq/dataverse/api/LicensesIT.java | 2 +- .../edu/harvard/iq/dataverse/api/LinkIT.java | 2 +- .../harvard/iq/dataverse/api/LogoutIT.java | 2 +- .../iq/dataverse/api/MakeDataCountApiIT.java | 4 +-- .../harvard/iq/dataverse/api/MetricsIT.java | 4 +-- .../edu/harvard/iq/dataverse/api/MoveIT.java | 2 +- .../harvard/iq/dataverse/api/NetcdfIT.java | 2 +- .../iq/dataverse/api/NotificationsIT.java | 2 +- .../edu/harvard/iq/dataverse/api/PidsIT.java | 10 +++---- .../edu/harvard/iq/dataverse/api/ProvIT.java | 4 +-- .../iq/dataverse/api/RemoteStoreIT.java | 2 +- .../edu/harvard/iq/dataverse/api/RolesIT.java | 2 +- .../harvard/iq/dataverse/api/S3AccessIT.java | 2 +- .../harvard/iq/dataverse/api/SearchIT.java | 6 ++-- .../api/SignedUrlAuthMechanismIT.java | 2 +- .../iq/dataverse/api/SignpostingIT.java | 2 +- .../harvard/iq/dataverse/api/SiteMapIT.java | 2 +- .../iq/dataverse/api/StorageSitesIT.java | 2 +- .../edu/harvard/iq/dataverse/api/SwordIT.java | 4 +-- .../harvard/iq/dataverse/api/TabularIT.java | 22 +++++++-------- .../edu/harvard/iq/dataverse/api/UsersIT.java | 2 +- .../iq/dataverse/api/dto/FieldDTOTest.java | 8 +++--- .../api/filesystem/FileRecordJobIT.java | 28 +++++++++---------- .../impl/ipaddress/ip/IPv6AddressTest.java | 4 +-- .../BuiltinAuthenticationProviderTest.java | 2 +- .../users/AuthenticatedUserTest.java | 2 +- .../confirmemail/ConfirmEmailDataTest.java | 4 +-- .../dataaccess/FileAccessIOTest.java | 4 +-- .../dataaccess/SwiftAccessIOTest.java | 2 +- .../DuplicateFileCheckerTest.java | 4 +-- .../impl/CreateDataverseCommandTest.java | 2 +- .../impl/CreatePrivateUrlCommandTest.java | 2 +- .../command/impl/CreateRoleCommandTest.java | 2 +- .../impl/DeletePrivateUrlCommandTest.java | 2 +- .../impl/GetPrivateUrlCommandTest.java | 8 +++--- .../impl/ListMetadataBlocksCommandTest.java | 2 +- .../command/impl/MoveDatasetCommandTest.java | 2 +- .../impl/MoveDataverseCommandTest.java | 2 +- .../impl/RequestRsyncScriptCommandTest.java | 8 +++--- .../command/impl/RestrictFileCommandTest.java | 10 +++---- .../ReturnDatasetToAuthorCommandTest.java | 2 +- .../SubmitDatasetForReviewCommandTest.java | 2 +- .../UpdateDatasetThumbnailCommandTest.java | 8 +++--- ...dateMetadataBlockFacetRootCommandTest.java | 2 +- .../UpdateMetadataBlockFacetsCommandTest.java | 2 +- .../impl/UpdatePermissionRootCommandTest.java | 2 +- .../dataverse/feedback/FeedbackUtilTest.java | 2 +- .../ingest/IngestableDataCheckerTest.java | 8 +++--- .../plugins/dta/NewDTAFileReaderTest.java | 8 +++--- .../passwordreset/PasswordResetDataTest.java | 8 +++--- .../dataverse/pidproviders/PidUtilTest.java | 5 ++-- .../provenance/ProvInvestigatorTest.java | 2 +- .../iq/dataverse/search/IndexUtilTest.java | 8 +++--- .../search/SolrSearchResultTest.java | 4 +-- .../iq/dataverse/search/SortByTest.java | 4 +-- .../harvard/iq/dataverse/util/BitSetTest.java | 8 +++--- .../iq/dataverse/util/JhoveFileTypeTest.java | 4 +-- .../iq/dataverse/util/JsfHelperTest.java | 8 +++--- .../iq/dataverse/util/LruCacheTest.java | 4 +-- .../iq/dataverse/util/MailUtilTest.java | 2 +- .../dataverse/util/PersonOrOrgUtilTest.java | 2 +- .../util/bagit/BagValidatorTest.java | 2 +- .../util/file/BagItFileHandlerTest.java | 2 +- .../util/json/DatasetVersionDTOTest.java | 8 +++--- .../dataverse/util/json/JsonParserTest.java | 6 ++-- .../dataverse/util/json/JsonPrinterTest.java | 2 +- 109 files changed, 222 insertions(+), 221 deletions(-) diff --git a/src/test/java/edu/harvard/iq/dataverse/AuxiliaryFileServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/AuxiliaryFileServiceBeanTest.java index 31d7793eac9..30bd260eb1b 100644 --- a/src/test/java/edu/harvard/iq/dataverse/AuxiliaryFileServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/AuxiliaryFileServiceBeanTest.java @@ -24,7 +24,7 @@ public class AuxiliaryFileServiceBeanTest { List types; DataFile dataFile; - @Before + @BeforeEach public void setup() { svc = new AuxiliaryFileServiceBean(); svc.em = mock(EntityManager.class); diff --git a/src/test/java/edu/harvard/iq/dataverse/CartTest.java b/src/test/java/edu/harvard/iq/dataverse/CartTest.java index 6b44c830ca6..e847cfb3346 100644 --- a/src/test/java/edu/harvard/iq/dataverse/CartTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/CartTest.java @@ -17,14 +17,14 @@ public class CartTest { private String title; private String persistentId; - @Before + @BeforeEach public void setUp() { this.cart = new Cart(); this.title = "title"; this.persistentId = "persistentId"; } - @After + @AfterEach public void tearDwon() { this.cart = null; this.title = null; diff --git a/src/test/java/edu/harvard/iq/dataverse/DataFileServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/DataFileServiceBeanTest.java index 269668b19d7..ab3d0f8ef55 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DataFileServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DataFileServiceBeanTest.java @@ -28,7 +28,7 @@ public DataFileServiceBeanTest() { private DataFileServiceBean dataFileServiceBean; - @Before + @BeforeEach public void setUp() { fileWoContentType = createDataFile(null); fileWithBogusContentType = createDataFile("foo/bar"); diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetFieldTypeTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetFieldTypeTest.java index ca734eb8635..a235c9b0061 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DatasetFieldTypeTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DatasetFieldTypeTest.java @@ -23,19 +23,19 @@ public class DatasetFieldTypeTest { public DatasetFieldTypeTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() { } - @AfterClass + @AfterAll public static void tearDownClass() { } - @Before + @BeforeEach public void setUp() { } - @After + @AfterEach public void tearDown() { } diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetFieldValidatorTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetFieldValidatorTest.java index db60e9b1edd..e9296b431dc 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DatasetFieldValidatorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DatasetFieldValidatorTest.java @@ -26,19 +26,19 @@ public class DatasetFieldValidatorTest { public DatasetFieldValidatorTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() { } - @AfterClass + @AfterAll public static void tearDownClass() { } - @Before + @BeforeEach public void setUp() { } - @After + @AfterEach public void tearDown() { } diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetTest.java index 30d8d0867a0..cd5186e6a87 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DatasetTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DatasetTest.java @@ -79,7 +79,7 @@ public void testLocksManagement() { private DatasetVersion draftVersion; private DatasetVersion releasedVersion; - @Before + @BeforeEach public void before() { this.archivedVersion = new DatasetVersion(); this.archivedVersion.setVersionState(VersionState.ARCHIVED); @@ -94,7 +94,7 @@ public void before() { this.releasedVersion.setVersionState(VersionState.RELEASED); } - @After + @AfterEach public void after() { this.archivedVersion = null; this.deaccessionedVersion = null; diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetVersionServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetVersionServiceBeanTest.java index ef15372c408..424ff54fe02 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DatasetVersionServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DatasetVersionServiceBeanTest.java @@ -18,13 +18,13 @@ public class DatasetVersionServiceBeanTest { private DatasetVersionServiceBean datasetVersionServiceBean; - @Before + @BeforeEach public void setUp() { this.datasetVersionServiceBean = new DatasetVersionServiceBean(); } - @After + @AfterEach public void tearDown() { this.datasetVersionServiceBean = null; } diff --git a/src/test/java/edu/harvard/iq/dataverse/DataverseTest.java b/src/test/java/edu/harvard/iq/dataverse/DataverseTest.java index 35db6c29e89..4e2bd5b3c2d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DataverseTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DataverseTest.java @@ -18,7 +18,7 @@ public class DataverseTest { private Dataverse OWNER; private List OWNER_METADATABLOCKFACETS; - @Before + @BeforeEach public void beforeEachTest() { OWNER = new Dataverse(); OWNER.setId(MocksFactory.nextId()); diff --git a/src/test/java/edu/harvard/iq/dataverse/GlobalIdTest.java b/src/test/java/edu/harvard/iq/dataverse/GlobalIdTest.java index 3c3993d110d..7a615b15345 100644 --- a/src/test/java/edu/harvard/iq/dataverse/GlobalIdTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/GlobalIdTest.java @@ -69,7 +69,7 @@ public void testInject() { } @Test - @Ignore /* Could now add a 'doy' protocol so the test would have to check against registered PIDProviders (currently Beans)*/ + @Disabled /* Could now add a 'doy' protocol so the test would have to check against registered PIDProviders (currently Beans)*/ public void testUnknownProtocol() { System.out.println("testUnknownProtocol"); @@ -81,7 +81,7 @@ public void testUnknownProtocol() { } @Test - @Ignore /* Could now change parsing rules so the test would have to check against registered PIDProviders (currently Beans)*/ + @Disabled /* Could now change parsing rules so the test would have to check against registered PIDProviders (currently Beans)*/ public void testBadIdentifierOnePart() { System.out.println("testBadIdentifierOnePart"); @@ -91,7 +91,7 @@ public void testBadIdentifierOnePart() { } @Test - @Ignore /* Could now change parsing rules so the test would have to check against registered PIDProviders (currently Beans)*/ + @Disabled /* Could now change parsing rules so the test would have to check against registered PIDProviders (currently Beans)*/ public void testBadIdentifierTwoParts() { System.out.println("testBadIdentifierTwoParts"); diff --git a/src/test/java/edu/harvard/iq/dataverse/PermissionsWrapperTest.java b/src/test/java/edu/harvard/iq/dataverse/PermissionsWrapperTest.java index 0acd7a8dca9..751a90fb447 100644 --- a/src/test/java/edu/harvard/iq/dataverse/PermissionsWrapperTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/PermissionsWrapperTest.java @@ -19,14 +19,14 @@ public class PermissionsWrapperTest { private PermissionsWrapper permissionWrapper; - @Before + @BeforeEach public void setUp() { this.permissionWrapper = new PermissionsWrapper(); this.permissionWrapper.permissionService = mock(PermissionServiceBean.class); this.permissionWrapper.dvRequestService = mock(DataverseRequestServiceBean.class); } - @After + @AfterEach public void tearDown() { this.permissionWrapper = null; } diff --git a/src/test/java/edu/harvard/iq/dataverse/PersistentIdentifierServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/PersistentIdentifierServiceBeanTest.java index 2e943bc7647..dcd0f583d9f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/PersistentIdentifierServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/PersistentIdentifierServiceBeanTest.java @@ -43,7 +43,7 @@ public class PersistentIdentifierServiceBeanTest { CommandContext ctxt; - @Before + @BeforeEach public void setup() { MockitoAnnotations.initMocks(this); ctxt = new TestCommandContext(){ diff --git a/src/test/java/edu/harvard/iq/dataverse/RoleAssignmentTest.java b/src/test/java/edu/harvard/iq/dataverse/RoleAssignmentTest.java index 6ed5e8c55bc..f8138537cd7 100644 --- a/src/test/java/edu/harvard/iq/dataverse/RoleAssignmentTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/RoleAssignmentTest.java @@ -22,7 +22,7 @@ public class RoleAssignmentTest { private Dataset dataset; private String privateUrlToken; - @Before + @BeforeEach public void before() { this.dataverseRole = new DataverseRole(); this.roleAssignee = GuestUser.get(); @@ -30,7 +30,7 @@ public void before() { this.privateUrlToken = "some-token"; } - @After + @AfterEach public void after() { this.dataverseRole = null; this.roleAssignee = null; diff --git a/src/test/java/edu/harvard/iq/dataverse/actionlogging/ActionLogRecordTest.java b/src/test/java/edu/harvard/iq/dataverse/actionlogging/ActionLogRecordTest.java index 9641fe57fb6..6a965b17a16 100644 --- a/src/test/java/edu/harvard/iq/dataverse/actionlogging/ActionLogRecordTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/actionlogging/ActionLogRecordTest.java @@ -16,7 +16,7 @@ public class ActionLogRecordTest { private ActionLogRecord referenceRecord; - @Before + @BeforeEach public void setUp() { this.referenceRecord = new ActionLogRecord(ActionType.Admin, "subType1"); this.referenceRecord.setEndTime(new Date()); @@ -25,7 +25,7 @@ public void setUp() { this.referenceRecord.setInfo("info1"); } - @After + @AfterEach public void tearDwon() { this.referenceRecord = null; } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/AbstractApiBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/api/AbstractApiBeanTest.java index 89f2ade1e72..860eeb47f4f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/AbstractApiBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/AbstractApiBeanTest.java @@ -24,7 +24,7 @@ public class AbstractApiBeanTest { AbstractApiBeanImpl sut; - @Before + @BeforeEach public void before() { sut = new AbstractApiBeanImpl(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java b/src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java index 0f83e1a6de8..c3a0de04c8d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java @@ -82,7 +82,7 @@ public class AccessIT { private static String testFileFromZipUploadWithFoldersChecksum3 = "00433ccb20111f9d40f0e5ab6fa8396f"; - @BeforeClass + @BeforeAll public static void setUp() throws InterruptedException { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); @@ -162,7 +162,7 @@ public static void setUp() throws InterruptedException { } - @AfterClass + @AfterAll public static void tearDown() { Response publishDataset = UtilIT.publishDatasetViaNativeApi(datasetId, "major", apiToken); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/AdminIT.java b/src/test/java/edu/harvard/iq/dataverse/api/AdminIT.java index cf7e43268ba..7f3a6d70252 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/AdminIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/AdminIT.java @@ -41,7 +41,7 @@ public class AdminIT { private final String testNonSuperuserApiToken = createTestNonSuperuserApiToken(); - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } @@ -670,7 +670,7 @@ public void testRecalculateDataFileHash() { } @Test - @Ignore + @Disabled public void testMigrateHDLToDOI() { /* This test is set to ignore because it requires a setup that will diff --git a/src/test/java/edu/harvard/iq/dataverse/api/AuxiliaryFilesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/AuxiliaryFilesIT.java index a5251de43f4..506a1186194 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/AuxiliaryFilesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/AuxiliaryFilesIT.java @@ -20,7 +20,7 @@ public class AuxiliaryFilesIT { - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/BagIT.java b/src/test/java/edu/harvard/iq/dataverse/api/BagIT.java index 2fbd1ef8049..80cbedac365 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/BagIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/BagIT.java @@ -12,7 +12,7 @@ public class BagIT { - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); @@ -65,7 +65,7 @@ public void testBagItExport() { } - @AfterClass + @AfterAll public static void tearDownClass() { // Not checking if delete happened. Hopefully, it did. diff --git a/src/test/java/edu/harvard/iq/dataverse/api/BatchImportIT.java b/src/test/java/edu/harvard/iq/dataverse/api/BatchImportIT.java index db13aace0e1..045dae2b313 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/BatchImportIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/BatchImportIT.java @@ -21,7 +21,7 @@ public class BatchImportIT { public BatchImportIT() { } - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/BuiltinUsersIT.java b/src/test/java/edu/harvard/iq/dataverse/api/BuiltinUsersIT.java index 5bc7be3d299..5260eead76a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/BuiltinUsersIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/BuiltinUsersIT.java @@ -36,7 +36,7 @@ public class BuiltinUsersIT { private static final String usernameKey = "userName"; private static final String emailKey = "email"; - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/ConfirmEmailIT.java b/src/test/java/edu/harvard/iq/dataverse/api/ConfirmEmailIT.java index 3db1f6d2d22..01369680536 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/ConfirmEmailIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/ConfirmEmailIT.java @@ -18,7 +18,7 @@ public class ConfirmEmailIT { private static final Logger logger = Logger.getLogger(ConfirmEmailIT.class.getCanonicalName()); - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DataRetrieverApiIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DataRetrieverApiIT.java index f15a1b8e7ee..f58e2007eb1 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DataRetrieverApiIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DataRetrieverApiIT.java @@ -15,7 +15,7 @@ public class DataRetrieverApiIT { - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java index 1419784d5fd..44965c27a3d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java @@ -99,7 +99,7 @@ public class DatasetsIT { - @BeforeClass + @BeforeAll public static void setUpClass() { @@ -129,7 +129,7 @@ public static void setUpClass() { */ } - @AfterClass + @AfterAll public static void afterClass() { Response removeIdentifierGenerationStyle = UtilIT.deleteSetting(SettingsServiceBean.Key.IdentifierGenerationStyle); @@ -1852,7 +1852,7 @@ public void testCreateDeleteDatasetLink() { } @Test - @Ignore + @Disabled public void testApiErrors() { /* @@ -2061,7 +2061,7 @@ public void testDatasetLocksApi() { * This test requires the root dataverse to be published to pass. */ @Test - @Ignore + @Disabled public void testUpdatePIDMetadataAPI() { Response createUser = UtilIT.createRandomUser(); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java index 0a5a773853e..3bb929e0aa7 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java @@ -40,12 +40,12 @@ public class DataversesIT { private static final Logger logger = Logger.getLogger(DataversesIT.class.getCanonicalName()); - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } - @AfterClass + @AfterAll public static void afterClass() { Response removeExcludeEmail = UtilIT.deleteSetting(SettingsServiceBean.Key.ExcludeEmailFromExport); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DataversesTest.java b/src/test/java/edu/harvard/iq/dataverse/api/DataversesTest.java index 3733f87255c..a2f5c3335ee 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DataversesTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DataversesTest.java @@ -79,7 +79,7 @@ public class DataversesTest { private Dataverse VALID_DATAVERSE; - @Before + @BeforeEach public void beforeEachTest() { VALID_DATAVERSE = new Dataverse(); VALID_DATAVERSE.setId(MocksFactory.nextId()); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DeactivateUsersIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DeactivateUsersIT.java index 2af2335b9c7..d3feb3dad7a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DeactivateUsersIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DeactivateUsersIT.java @@ -19,7 +19,7 @@ public class DeactivateUsersIT { - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DeleteUsersIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DeleteUsersIT.java index 926ae5d5d8d..7be43103acc 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DeleteUsersIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DeleteUsersIT.java @@ -130,7 +130,7 @@ */ public class DeleteUsersIT { - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DownloadFilesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DownloadFilesIT.java index 44910d7be29..7fcf7489d1d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DownloadFilesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DownloadFilesIT.java @@ -29,7 +29,7 @@ public class DownloadFilesIT { - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DownloadInstanceWriterTest.java b/src/test/java/edu/harvard/iq/dataverse/api/DownloadInstanceWriterTest.java index 229c7166835..f7f61d18a51 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DownloadInstanceWriterTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DownloadInstanceWriterTest.java @@ -11,7 +11,7 @@ public class DownloadInstanceWriterTest { DownloadInstanceWriter diw; - @Before + @BeforeEach public void setUpClass() { diw = new DownloadInstanceWriter(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DuplicateFilesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DuplicateFilesIT.java index 1516c0c7fc0..3c0ef73f6df 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DuplicateFilesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DuplicateFilesIT.java @@ -25,7 +25,7 @@ */ public class DuplicateFilesIT { - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/EditDDIIT.java b/src/test/java/edu/harvard/iq/dataverse/api/EditDDIIT.java index 8dfe36099c6..d443b22442f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/EditDDIIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/EditDDIIT.java @@ -40,7 +40,7 @@ public class EditDDIIT { private static final Logger logger = Logger.getLogger(EditDDIIT.class.getCanonicalName()); - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/ExternalToolsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/ExternalToolsIT.java index ddd1f059fac..3244dffd8a8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/ExternalToolsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/ExternalToolsIT.java @@ -25,7 +25,7 @@ public class ExternalToolsIT { - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } @@ -309,7 +309,7 @@ public void testAddExternalToolNonReservedWord() throws IOException { .statusCode(BAD_REQUEST.getStatusCode()); } - @Ignore + @Disabled @Test public void deleteTools() { @@ -330,7 +330,7 @@ public void deleteTools() { } // preview only - @Ignore + @Disabled @Test public void createToolShellScript() { JsonObjectBuilder job = Json.createObjectBuilder(); @@ -370,7 +370,7 @@ public void createToolShellScript() { } // explore only - @Ignore + @Disabled @Test public void createToolDataExplorer() { JsonObjectBuilder job = Json.createObjectBuilder(); @@ -403,7 +403,7 @@ public void createToolDataExplorer() { } // both preview and explore - @Ignore + @Disabled @Test public void createToolSpreadsheetViewer() { JsonObjectBuilder job = Json.createObjectBuilder(); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/FeedbackApiIT.java b/src/test/java/edu/harvard/iq/dataverse/api/FeedbackApiIT.java index 5e21abc6b09..bab610cda8f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/FeedbackApiIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/FeedbackApiIT.java @@ -13,7 +13,7 @@ public class FeedbackApiIT { - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/FileMetadataIT.java b/src/test/java/edu/harvard/iq/dataverse/api/FileMetadataIT.java index ebc24d0b23f..8c87440b488 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/FileMetadataIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/FileMetadataIT.java @@ -33,12 +33,12 @@ public class FileMetadataIT { private static int dsId; private static int dsIdFirst; - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } - @Before + @BeforeEach public void setUpDataverse() { try { // create random test name @@ -85,12 +85,12 @@ public void setUpDataverse() { } } - @AfterClass + @AfterAll public static void tearDownClass() { RestAssured.reset(); } - @After + @AfterEach public void tearDownDataverse() { try { // delete dataset diff --git a/src/test/java/edu/harvard/iq/dataverse/api/FileTypeDetectionIT.java b/src/test/java/edu/harvard/iq/dataverse/api/FileTypeDetectionIT.java index dcb0c19eab3..0012f50e29d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/FileTypeDetectionIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/FileTypeDetectionIT.java @@ -15,7 +15,7 @@ public class FileTypeDetectionIT { - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java index ca4597a3680..3463e99412b 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java @@ -44,7 +44,7 @@ public class FilesIT { private static final Logger logger = Logger.getLogger(FilesIT.class.getCanonicalName()); - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/FitsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/FitsIT.java index da9b5b5ccc5..b956fb5bd4c 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/FitsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/FitsIT.java @@ -17,7 +17,7 @@ public class FitsIT { - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/HarvestingClientsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/HarvestingClientsIT.java index bb5b833f6b9..9c9022a95dd 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/HarvestingClientsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/HarvestingClientsIT.java @@ -41,7 +41,7 @@ public class HarvestingClientsIT { private static String adminUserAPIKey; private static String harvestCollectionAlias; - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/HarvestingServerIT.java b/src/test/java/edu/harvard/iq/dataverse/api/HarvestingServerIT.java index 3004d0ef1d2..174f6a63da7 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/HarvestingServerIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/HarvestingServerIT.java @@ -41,7 +41,7 @@ public class HarvestingServerIT { private static String singleSetDatasetPersistentId; private static List extraDatasetsIdentifiers = new ArrayList<>(); - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); // enable harvesting server @@ -56,7 +56,7 @@ public static void setUpClass() { } - @AfterClass + @AfterAll public static void afterClass() { // disable harvesting server (default value) Response enableHarvestingServerResponse = UtilIT.setSetting(SettingsServiceBean.Key.OAIServerEnabled,"false"); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java b/src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java index f88bddb5159..f50743b582f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java @@ -23,7 +23,7 @@ public class InReviewWorkflowIT { private static final Logger logger = Logger.getLogger(DatasetsIT.class.getCanonicalName()); - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/IndexIT.java b/src/test/java/edu/harvard/iq/dataverse/api/IndexIT.java index 91260f61e69..4d6beb30ec8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/IndexIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/IndexIT.java @@ -23,7 +23,7 @@ public class IndexIT { private static final Logger logger = Logger.getLogger(IndexIT.class.getCanonicalName()); - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); @@ -100,11 +100,11 @@ public void testIndexStatus() { } - @After + @AfterEach public void tearDownDataverse() { } - @AfterClass + @AfterAll public static void cleanup() { } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/InvalidCharactersIT.java b/src/test/java/edu/harvard/iq/dataverse/api/InvalidCharactersIT.java index 3d58ecdd739..24450134583 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/InvalidCharactersIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/InvalidCharactersIT.java @@ -16,7 +16,7 @@ public class InvalidCharactersIT { - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/IpGroupsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/IpGroupsIT.java index 40f342af987..0df0cf59bdd 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/IpGroupsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/IpGroupsIT.java @@ -21,7 +21,7 @@ public class IpGroupsIT { private static final Logger logger = Logger.getLogger(IpGroupsIT.class.getCanonicalName()); - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java index b29e6472fcf..7f7c68db792 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java @@ -18,7 +18,7 @@ public class LicensesIT { private static final Logger logger = Logger.getLogger(LicensesIT.class.getCanonicalName()); - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/LinkIT.java b/src/test/java/edu/harvard/iq/dataverse/api/LinkIT.java index 8a440da2ace..d9f42b36096 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/LinkIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/LinkIT.java @@ -16,7 +16,7 @@ public class LinkIT { private static final Logger logger = Logger.getLogger(LinkIT.class.getCanonicalName()); - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/LogoutIT.java b/src/test/java/edu/harvard/iq/dataverse/api/LogoutIT.java index f4b60369443..a9332a5d394 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/LogoutIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/LogoutIT.java @@ -10,7 +10,7 @@ public class LogoutIT { - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/MakeDataCountApiIT.java b/src/test/java/edu/harvard/iq/dataverse/api/MakeDataCountApiIT.java index 107ecece1d7..d4ff45f3b12 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/MakeDataCountApiIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/MakeDataCountApiIT.java @@ -15,7 +15,7 @@ public class MakeDataCountApiIT { - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } @@ -181,7 +181,7 @@ public void testMakeDataCountGetMetric() throws IOException { * * update dvobject set authority = '10.7910' where id = 10; */ - @Ignore + @Disabled @Test public void testMakeDataCountDownloadCitation() { String idOrPersistentIdOfDataset = "doi:10.7910/DVN/HQZOOB"; diff --git a/src/test/java/edu/harvard/iq/dataverse/api/MetricsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/MetricsIT.java index 72e73547979..61eb788b57e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/MetricsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/MetricsIT.java @@ -17,13 +17,13 @@ //go up to show that the caching worked public class MetricsIT { - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); UtilIT.clearMetricCache(); } - @AfterClass + @AfterAll public static void cleanUpClass() { UtilIT.clearMetricCache(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/MoveIT.java b/src/test/java/edu/harvard/iq/dataverse/api/MoveIT.java index 5f9d2f7374b..229e7fa646d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/MoveIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/MoveIT.java @@ -25,7 +25,7 @@ public class MoveIT { private static final Logger logger = Logger.getLogger(MoveIT.class.getCanonicalName()); - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/NetcdfIT.java b/src/test/java/edu/harvard/iq/dataverse/api/NetcdfIT.java index dd39cc3549d..6fa69118bba 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/NetcdfIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/NetcdfIT.java @@ -19,7 +19,7 @@ public class NetcdfIT { - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/NotificationsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/NotificationsIT.java index 683acf7c541..07e942943c5 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/NotificationsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/NotificationsIT.java @@ -14,7 +14,7 @@ public class NotificationsIT { private static final Logger logger = Logger.getLogger(NotificationsIT.class.getCanonicalName()); - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/PidsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/PidsIT.java index cc9fe2dd4b3..39c5b3ed2f0 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/PidsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/PidsIT.java @@ -16,12 +16,12 @@ */ public class PidsIT { - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } - @Ignore + @Disabled @Test public void testGetPid() { String pid = ""; @@ -94,7 +94,7 @@ public void testReservePid() { */ } - @Ignore + @Disabled @Test public void testDeletePid() { String pid = ""; @@ -112,7 +112,7 @@ public void testDeletePid() { deletePid.prettyPrint(); } - @Ignore + @Disabled @Test public void testCannotPublishUntilReserved() { Response createUser = UtilIT.createRandomUser(); @@ -154,7 +154,7 @@ public void testCannotPublishUntilReserved() { .statusCode(FORBIDDEN.getStatusCode()); } - @Ignore + @Disabled @Test public void testDeleteDraftPidOnDelete() { Response createUser = UtilIT.createRandomUser(); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/ProvIT.java b/src/test/java/edu/harvard/iq/dataverse/api/ProvIT.java index ddd523bf553..5e663e40779 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/ProvIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/ProvIT.java @@ -19,13 +19,13 @@ public class ProvIT { - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } - @Test + @Test public void testFreeformDraftActions() { Response createDepositor = UtilIT.createRandomUser(); createDepositor.prettyPrint(); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/RemoteStoreIT.java b/src/test/java/edu/harvard/iq/dataverse/api/RemoteStoreIT.java index 48b52d1c892..f0c07f2f275 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/RemoteStoreIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/RemoteStoreIT.java @@ -11,7 +11,7 @@ public class RemoteStoreIT { - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/RolesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/RolesIT.java index 6168ff27c4d..cfff9acb487 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/RolesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/RolesIT.java @@ -20,7 +20,7 @@ public class RolesIT { private static final Logger logger = Logger.getLogger(AdminIT.class.getCanonicalName()); - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/S3AccessIT.java b/src/test/java/edu/harvard/iq/dataverse/api/S3AccessIT.java index acc47db360a..e4b036b88d9 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/S3AccessIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/S3AccessIT.java @@ -20,7 +20,7 @@ public class S3AccessIT { private static final Logger logger = Logger.getLogger(S3AccessIT.class.getCanonicalName()); - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java b/src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java index 2f67f07d2dc..18c3b3a318e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java @@ -43,7 +43,7 @@ public class SearchIT { private static final Logger logger = Logger.getLogger(SearchIT.class.getCanonicalName()); - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); @@ -1282,7 +1282,7 @@ public void testGeospatialSearchInvalid() { } - @After + @AfterEach public void tearDownDataverse() { File treesThumb = new File("scripts/search/data/binary/trees.png.thumb48"); treesThumb.delete(); @@ -1292,7 +1292,7 @@ public void tearDownDataverse() { dataverseprojectThumb.delete(); } - @AfterClass + @AfterAll public static void cleanup() { } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/SignedUrlAuthMechanismIT.java b/src/test/java/edu/harvard/iq/dataverse/api/SignedUrlAuthMechanismIT.java index ab153ad59bb..cb797af55fb 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/SignedUrlAuthMechanismIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/SignedUrlAuthMechanismIT.java @@ -12,7 +12,7 @@ public class SignedUrlAuthMechanismIT { - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/SignpostingIT.java b/src/test/java/edu/harvard/iq/dataverse/api/SignpostingIT.java index 6e24bad0e01..3b450ad98ca 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/SignpostingIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/SignpostingIT.java @@ -22,7 +22,7 @@ public class SignpostingIT { - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/SiteMapIT.java b/src/test/java/edu/harvard/iq/dataverse/api/SiteMapIT.java index 048bc1c2df5..0df8631581e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/SiteMapIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/SiteMapIT.java @@ -7,7 +7,7 @@ public class SiteMapIT { - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/StorageSitesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/StorageSitesIT.java index 13b1f36d59a..2eaf78e8495 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/StorageSitesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/StorageSitesIT.java @@ -11,7 +11,7 @@ public class StorageSitesIT { - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/SwordIT.java b/src/test/java/edu/harvard/iq/dataverse/api/SwordIT.java index 812fa7897f7..686670d8b3e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/SwordIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/SwordIT.java @@ -55,7 +55,7 @@ public class SwordIT { private static final String rootDvNotPublished = "Many of these SWORD tests require that the root dataverse collection has been published. Publish the root dataverse and then re-run these tests."; private static final String rootDvLackPermissions = "Many of these SWORD tests require you set permissions for the root dataverse collection: \"Anyone with a Dataverse account can add sub dataverses and datasets\" + curator role for new datasets. Please set and re-run these tests."; - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); boolean testAgainstDev1 = false; @@ -968,7 +968,7 @@ public void testDeleteFiles() { } - @AfterClass + @AfterAll public static void tearDownClass() { // cleanup, allow custom terms again (delete because it defaults to true) UtilIT.deleteSetting(SettingsServiceBean.Key.AllowCustomTermsOfUse); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/TabularIT.java b/src/test/java/edu/harvard/iq/dataverse/api/TabularIT.java index 4afd5058a3a..1a5e3a7e7f0 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/TabularIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/TabularIT.java @@ -20,12 +20,12 @@ public class TabularIT { private static final Logger logger = Logger.getLogger(TabularIT.class.getCanonicalName()); - @BeforeClass + @BeforeAll public static void setUpClass() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); } - @Ignore + @Disabled @Test public void testTabularFile() throws InterruptedException { Response createUser = UtilIT.createRandomUser(); @@ -100,7 +100,7 @@ public void testTabularFile() throws InterruptedException { } - @Ignore + @Disabled @Test public void test50by1000() { // cp scripts/search/data/tabular/50by1000.dta /tmp @@ -111,7 +111,7 @@ public void test50by1000() { assertEquals("NVARS: 50", response.body().asString().split("\n")[0]); } - @Ignore + @Disabled @Test public void testStata13TinyFile() { // cp scripts/search/data/tabular/120745.dta /tmp @@ -122,7 +122,7 @@ public void testStata13TinyFile() { assertEquals("NVARS: 1", response.body().asString().split("\n")[0]); } - @Ignore + @Disabled @Test public void testStata13Auto() { // curl https://www.stata-press.com/data/r13/auto.dta > /tmp/stata13-auto.dta @@ -133,7 +133,7 @@ public void testStata13Auto() { assertEquals("NVARS: 12", response.body().asString().split("\n")[0]); } - @Ignore + @Disabled @Test public void testStata14OpenSourceAtHarvard() { // https://dataverse.harvard.edu/file.xhtml?fileId=3040230 converted to Stata 14: 2017-07-31.tab @@ -146,7 +146,7 @@ public void testStata14OpenSourceAtHarvard() { assertEquals("NVARS: 10", response.body().asString().split("\n")[0]); } - @Ignore + @Disabled @Test public void testStata14Aggregated() { // https://dataverse.harvard.edu/file.xhtml?fileId=3140457 Stata 14: 2018_04_06_Aggregated_dataset_v2.dta @@ -158,7 +158,7 @@ public void testStata14Aggregated() { assertEquals("NVARS: 227", response.body().asString().split("\n")[0]); } - @Ignore + @Disabled @Test public void testStata14MmPublic() { // TODO: This file was downloaded at random. We could keep trying to get it to ingest. @@ -173,7 +173,7 @@ public void testStata14MmPublic() { assertEquals("NVARS: 12", response.body().asString().split("\n")[0]); } - @Ignore + @Disabled @Test public void testStata15() { // for i in `echo {0..33000}`; do echo -n "var$i,"; done > 33k.csv @@ -185,7 +185,7 @@ public void testStata15() { assertEquals("NVARS: 33001", response.body().asString().split("\n")[0]); } - @Ignore + @Disabled @Test public void testStata13Multiple() { String fileType = "application/x-stata-13"; @@ -205,7 +205,7 @@ public void testStata13Multiple() { } } - @Ignore + @Disabled @Test public void testStata14Multiple() { String fileType = "application/x-stata-14"; diff --git a/src/test/java/edu/harvard/iq/dataverse/api/UsersIT.java b/src/test/java/edu/harvard/iq/dataverse/api/UsersIT.java index 1dd1199ebd6..be1ea5b9fd6 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/UsersIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/UsersIT.java @@ -27,7 +27,7 @@ public class UsersIT { - @BeforeClass + @BeforeAll public static void setUp() { RestAssured.baseURI = UtilIT.getRestAssuredBaseUri(); /* diff --git a/src/test/java/edu/harvard/iq/dataverse/api/dto/FieldDTOTest.java b/src/test/java/edu/harvard/iq/dataverse/api/dto/FieldDTOTest.java index 21e37625543..4f75669eb05 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/dto/FieldDTOTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/dto/FieldDTOTest.java @@ -27,15 +27,15 @@ public class FieldDTOTest { public FieldDTOTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() { } - @AfterClass + @AfterAll public static void tearDownClass() { } - @Before + @BeforeEach public void setUp() { Set authorFields = new HashSet<>(); @@ -49,7 +49,7 @@ public void setUp() { } - @After + @AfterEach public void tearDown() { } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/filesystem/FileRecordJobIT.java b/src/test/java/edu/harvard/iq/dataverse/api/filesystem/FileRecordJobIT.java index 25b6ec7371d..ffec1f48fd8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/filesystem/FileRecordJobIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/filesystem/FileRecordJobIT.java @@ -93,7 +93,7 @@ public class FileRecordJobIT { private static final String API_TOKEN_HTTP_HEADER = "X-Dataverse-key"; private static final String BUILTIN_USER_KEY = "burrito"; - @BeforeClass + @BeforeAll public static void setUpClass() throws Exception { // this allows for testing on dataverse staging servers via jvm setting @@ -123,7 +123,7 @@ public static void setUpClass() throws Exception { } } - @Before + @BeforeEach public void setUpDataverse() { try { @@ -190,12 +190,12 @@ public void setUpDataverse() { } } - @AfterClass + @AfterAll public static void tearDownClass() { RestAssured.reset(); } - @After + @AfterEach public void tearDownDataverse() { try { @@ -232,7 +232,7 @@ public void tearDownDataverse() { * Ignores failed checksum manifest import. */ @Test - @Ignore + @Disabled public void testSameFileInDifferentDirectories() { try { @@ -311,7 +311,7 @@ public void testSameFileInDifferentDirectories() { } @Test - @Ignore + @Disabled public void testNewEditor() { try { @@ -415,7 +415,7 @@ public void testNewEditor() { * Ignores failed checksum manifest import. */ @Test - @Ignore + @Disabled public void testSameFileInDifferentDirectoriesUnauthorizedUser() { try { @@ -614,7 +614,7 @@ public void testSameFileInDifferentDirectoriesUnauthorizedUser() { // } @Test - @Ignore + @Disabled /** * Add a file in MERGE mode (default), should only need to commit the new file */ @@ -759,7 +759,7 @@ public void testAddingFilesInMergeMode() { } @Test - @Ignore + @Disabled /** * The success case: all files uploaded and present in checksum manifest */ @@ -828,7 +828,7 @@ public void testFilesWithChecksumManifest() { } @Test - @Ignore + @Disabled /** * No checksum manifest found */ @@ -882,7 +882,7 @@ public void testFilesWithoutChecksumManifest() { } @Test - @Ignore + @Disabled /** * Checksum manifest is missing an uploaded file */ @@ -949,7 +949,7 @@ public void testFileMissingInChecksumManifest() { } @Test - @Ignore + @Disabled /** * Checksum manifest references a file that isn't present, it should return failed status and detailed * message in persistentUserData @@ -1021,7 +1021,7 @@ public void testFileInChecksumManifestDoesntExist() { } @Test - @Ignore + @Disabled /** * Published datasets should not allow import jobs for now since it isn't in DRAFT mode */ @@ -1103,7 +1103,7 @@ public void testPublishedDataset() { // } @Test - @Ignore + @Disabled /** * No dataset found responses (bad dataset id, etc.) */ diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv6AddressTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv6AddressTest.java index a6ca37e975c..1fa6e7d2473 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv6AddressTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv6AddressTest.java @@ -16,11 +16,11 @@ public class IPv6AddressTest { public IPv6AddressTest() { } - @Before + @BeforeEach public void setUp() { } - @After + @AfterEach public void tearDown() { } diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/builtin/BuiltinAuthenticationProviderTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/builtin/BuiltinAuthenticationProviderTest.java index aceedd970b7..ff51260d43e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/builtin/BuiltinAuthenticationProviderTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/builtin/BuiltinAuthenticationProviderTest.java @@ -22,7 +22,7 @@ public class BuiltinAuthenticationProviderTest { MockBuiltinUserServiceBean bean = null; AuthenticationServiceBean authBean = null; - @Before + @BeforeEach public void setup() { bean = new MockBuiltinUserServiceBean(); passwordValidatorService = new MockPasswordValidatorServiceBean(); diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/users/AuthenticatedUserTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/users/AuthenticatedUserTest.java index 12e48216f49..9a2781a80bd 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/users/AuthenticatedUserTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/users/AuthenticatedUserTest.java @@ -52,7 +52,7 @@ public AuthenticatedUserTest() { public static final String IDENTIFIER_PREFIX = "@"; public static final Set mutedTypes = EnumSet.of(Type.ASSIGNROLE, Type.REVOKEROLE); - @Before + @BeforeEach public void setUp() { testUser = MocksFactory.makeAuthenticatedUser("Homer", "Simpson"); expResult = testUser.getCreatedTime(); diff --git a/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailDataTest.java b/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailDataTest.java index d807d8b9efe..10de20239e5 100644 --- a/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailDataTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailDataTest.java @@ -14,13 +14,13 @@ public class ConfirmEmailDataTest { private ConfirmEmailData instance; private AuthenticatedUser user; - @Before + @BeforeEach public void setUp() { this.user = new AuthenticatedUser(); this.instance = new ConfirmEmailData(user, 60); } - @After + @AfterEach public void tearDown() { this.instance = null; this.user = null; diff --git a/src/test/java/edu/harvard/iq/dataverse/dataaccess/FileAccessIOTest.java b/src/test/java/edu/harvard/iq/dataverse/dataaccess/FileAccessIOTest.java index d8a94585b38..552d76b74e8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/dataaccess/FileAccessIOTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/dataaccess/FileAccessIOTest.java @@ -51,7 +51,7 @@ public class FileAccessIOTest { public FileAccessIOTest() { } - @Before + @BeforeEach public void setUpClass() throws IOException { dataverse = MocksFactory.makeDataverse(); dataset = MocksFactory.makeDataset(); @@ -77,7 +77,7 @@ public void setUpClass() throws IOException { } } - @After + @AfterEach public void tearDownClass() throws IOException { FileUtils.deleteDirectory(new File("/tmp/files/")); } diff --git a/src/test/java/edu/harvard/iq/dataverse/dataaccess/SwiftAccessIOTest.java b/src/test/java/edu/harvard/iq/dataverse/dataaccess/SwiftAccessIOTest.java index 115103450b8..942e4329384 100644 --- a/src/test/java/edu/harvard/iq/dataverse/dataaccess/SwiftAccessIOTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/dataaccess/SwiftAccessIOTest.java @@ -33,7 +33,7 @@ public class SwiftAccessIOTest { public SwiftAccessIOTest() { } - @Before + @BeforeEach public void setUpClass() throws IOException { datafile = MocksFactory.makeDataFile(); dataset = MocksFactory.makeDataset(); diff --git a/src/test/java/edu/harvard/iq/dataverse/datasetutility/DuplicateFileCheckerTest.java b/src/test/java/edu/harvard/iq/dataverse/datasetutility/DuplicateFileCheckerTest.java index 1fb05becfc8..42d6c2385b8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/datasetutility/DuplicateFileCheckerTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/datasetutility/DuplicateFileCheckerTest.java @@ -19,13 +19,13 @@ public class DuplicateFileCheckerTest { private DuplicateFileChecker duplicateFileChecker; private DatasetVersionServiceBean datasetVersionServiceBean; - @Before + @BeforeEach public void setUp() { this.datasetVersionServiceBean = mock(DatasetVersionServiceBean.class); this.duplicateFileChecker = new DuplicateFileChecker(datasetVersionServiceBean); } - @After + @AfterEach public void tearDown() { duplicateFileChecker = null; } diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDataverseCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDataverseCommandTest.java index 985c70f834e..195c8854b26 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDataverseCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDataverseCommandTest.java @@ -165,7 +165,7 @@ public void deleteFacetsFor(Dataverse d) { TestDataverseEngine engine; - @Before + @BeforeEach public void setUp() { indexCalled = false; dvStore.clear(); diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreatePrivateUrlCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreatePrivateUrlCommandTest.java index 104a4f595a8..33f9acd0e1a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreatePrivateUrlCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreatePrivateUrlCommandTest.java @@ -32,7 +32,7 @@ public class CreatePrivateUrlCommandTest { private final Long versionIsReleased = 4l; - @Before + @BeforeEach public void setUp() { dataset = new Dataset(); testEngine = new TestDataverseEngine(new TestCommandContext() { diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateRoleCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateRoleCommandTest.java index bd42a5469b3..ab4f9dae3db 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateRoleCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateRoleCommandTest.java @@ -52,7 +52,7 @@ public EntityManager em() { } }); - @Before + @BeforeEach public void before() { saveCalled = false; } diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/DeletePrivateUrlCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/DeletePrivateUrlCommandTest.java index 73b160e620d..0a4e5ed2d7e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/DeletePrivateUrlCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/DeletePrivateUrlCommandTest.java @@ -26,7 +26,7 @@ public class DeletePrivateUrlCommandTest { private final Long noPrivateUrlToDelete = 1l; private final Long hasPrivateUrlToDelete = 2l; - @Before + @BeforeEach public void setUp() { testEngine = new TestDataverseEngine(new TestCommandContext() { @Override diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/GetPrivateUrlCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/GetPrivateUrlCommandTest.java index d15162e4053..47174643a1c 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/GetPrivateUrlCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/GetPrivateUrlCommandTest.java @@ -20,15 +20,15 @@ public class GetPrivateUrlCommandTest { public GetPrivateUrlCommandTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() { } - @AfterClass + @AfterAll public static void tearDownClass() { } - @Before + @BeforeEach public void setUp() { testEngine = new TestDataverseEngine(new TestCommandContext() { @@ -47,7 +47,7 @@ public PrivateUrl getPrivateUrlFromDatasetId(long datasetId) { }); } - @After + @AfterEach public void tearDown() { } diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ListMetadataBlocksCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ListMetadataBlocksCommandTest.java index 83780552639..0701454113b 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ListMetadataBlocksCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ListMetadataBlocksCommandTest.java @@ -26,7 +26,7 @@ public class ListMetadataBlocksCommandTest { private Dataverse dataverse; private DataverseMetadataBlockFacet metadataBlockFacet; - @Before + @BeforeEach public void beforeEachTest() { dataverseRequest = Mockito.mock(DataverseRequest.class); dataverse = Mockito.mock(Dataverse.class); diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDatasetCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDatasetCommandTest.java index 7c883b18cb5..9b2591a796e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDatasetCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDatasetCommandTest.java @@ -71,7 +71,7 @@ public class MoveDatasetCommandTest { @Context protected HttpServletRequest httpRequest; - @Before + @BeforeEach public void setUp() { auth = makeAuthenticatedUser("Super", "User"); diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDataverseCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDataverseCommandTest.java index ce56a732267..3725cc942e5 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDataverseCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDataverseCommandTest.java @@ -49,7 +49,7 @@ public class MoveDataverseCommandTest { AuthenticatedUser auth, nobody; protected HttpServletRequest httpRequest; - @Before + @BeforeEach public void setUp() { // authentication auth = makeAuthenticatedUser("Super", "User"); diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/RequestRsyncScriptCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/RequestRsyncScriptCommandTest.java index fef4b03b9a3..7609ef17d3e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/RequestRsyncScriptCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/RequestRsyncScriptCommandTest.java @@ -26,15 +26,15 @@ public class RequestRsyncScriptCommandTest { public RequestRsyncScriptCommandTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() { } - @AfterClass + @AfterAll public static void tearDownClass() { } - @Before + @BeforeEach public void setUp() { testEngine = new TestDataverseEngine(new TestCommandContext() { @@ -66,7 +66,7 @@ public SettingsServiceBean settings() { }); } - @After + @AfterEach public void tearDown() { } diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/RestrictFileCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/RestrictFileCommandTest.java index 2e1abefb4d8..2b1dbc4c64a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/RestrictFileCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/RestrictFileCommandTest.java @@ -46,15 +46,15 @@ public class RestrictFileCommandTest { public RestrictFileCommandTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() { } - @AfterClass + @AfterAll public static void tearDownClass() { } - @Before + @BeforeEach public void setUp() { dataset = makeDataset(); file = makeDataFile(); @@ -76,7 +76,7 @@ public boolean isTrueForKey(SettingsServiceBean.Key key, boolean defaultValue) { } - @After + @AfterEach public void tearDown() { } @@ -249,7 +249,7 @@ public void testUnrestrictUnrestrictedNewFile() throws Exception { } - @Test + @Test public void testPublicInstall() throws CommandException { file.setOwner(dataset); String expected = "Restricting files is not permitted on a public installation."; diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ReturnDatasetToAuthorCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ReturnDatasetToAuthorCommandTest.java index e70771a3348..e7565c1ea64 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ReturnDatasetToAuthorCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ReturnDatasetToAuthorCommandTest.java @@ -39,7 +39,7 @@ public class ReturnDatasetToAuthorCommandTest { private DataverseRequest dataverseRequest; private TestDataverseEngine testEngine; - @Before + @BeforeEach public void setUp() { dataset = new Dataset(); diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/SubmitDatasetForReviewCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/SubmitDatasetForReviewCommandTest.java index 74a632e510a..0934f965b4b 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/SubmitDatasetForReviewCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/SubmitDatasetForReviewCommandTest.java @@ -38,7 +38,7 @@ public class SubmitDatasetForReviewCommandTest { private DataverseRequest dataverseRequest; private TestDataverseEngine testEngine; - @Before + @BeforeEach public void setUp() { dataset = new Dataset(); diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateDatasetThumbnailCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateDatasetThumbnailCommandTest.java index 45ecd1e03dd..34ea7810574 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateDatasetThumbnailCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateDatasetThumbnailCommandTest.java @@ -27,15 +27,15 @@ public class UpdateDatasetThumbnailCommandTest { public UpdateDatasetThumbnailCommandTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() { } - @AfterClass + @AfterAll public static void tearDownClass() { } - @Before + @BeforeEach public void setUp() { dataset = new Dataset(); testEngine = new TestDataverseEngine(new TestCommandContext() { @@ -87,7 +87,7 @@ public String getDataverseSiteUrl() { ); } - @After + @AfterEach public void tearDown() { } diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetRootCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetRootCommandTest.java index 492344ea072..8504db878ca 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetRootCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetRootCommandTest.java @@ -26,7 +26,7 @@ public class UpdateMetadataBlockFacetRootCommandTest { private DataverseRequest dataverseRequest; private Dataverse dataverse; - @Before + @BeforeEach public void beforeEachTest() { dataverseRequest = Mockito.mock(DataverseRequest.class); dataverse = Mockito.mock(Dataverse.class); diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetsCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetsCommandTest.java index e2a08a6add4..4fd80e931a2 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetsCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetsCommandTest.java @@ -27,7 +27,7 @@ public class UpdateMetadataBlockFacetsCommandTest { private DataverseRequest dataverseRequest; private Dataverse dataverse; - @Before + @BeforeEach public void beforeEachTest() { dataverseRequest = Mockito.mock(DataverseRequest.class); dataverse = Mockito.mock(Dataverse.class); diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdatePermissionRootCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdatePermissionRootCommandTest.java index d2e64b3292d..1a46a8803a6 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdatePermissionRootCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdatePermissionRootCommandTest.java @@ -23,7 +23,7 @@ public class UpdatePermissionRootCommandTest { TestCommandContext testCommandContext; boolean serviceBeanCalled; - @Before + @BeforeEach public void setUp() { mockBean = new DataverseServiceBean() { @Override diff --git a/src/test/java/edu/harvard/iq/dataverse/feedback/FeedbackUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/feedback/FeedbackUtilTest.java index ecb7014af7d..7c31db5bee2 100644 --- a/src/test/java/edu/harvard/iq/dataverse/feedback/FeedbackUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/feedback/FeedbackUtilTest.java @@ -58,7 +58,7 @@ public class FeedbackUtilTest { private static final String systemEmail = "support@librascholar.edu"; private static final boolean weKnowHowToCreateMockAuthenticatedUsers = false; - @BeforeClass + @BeforeAll public static void setUpClass() throws IOException, JsonParseException, AddressException { if (weKnowHowToCreateMockAuthenticatedUsers) { diff --git a/src/test/java/edu/harvard/iq/dataverse/ingest/IngestableDataCheckerTest.java b/src/test/java/edu/harvard/iq/dataverse/ingest/IngestableDataCheckerTest.java index 305dcf82260..8bff81e7c87 100644 --- a/src/test/java/edu/harvard/iq/dataverse/ingest/IngestableDataCheckerTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/ingest/IngestableDataCheckerTest.java @@ -35,20 +35,20 @@ public class IngestableDataCheckerTest { public IngestableDataCheckerTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() { } - @AfterClass + @AfterAll public static void tearDownClass() { } - @Before + @BeforeEach public void setUp() { } - @After + @AfterEach public void tearDown() { diff --git a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/NewDTAFileReaderTest.java b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/NewDTAFileReaderTest.java index 6960a6d0e7f..36e667336c8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/NewDTAFileReaderTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/NewDTAFileReaderTest.java @@ -81,7 +81,7 @@ public void testNull() throws IOException { } // TODO: Can we create a small file to check into the code base that exercises the value-label names non-zero offset issue? - @Ignore + @Disabled @Test public void testFirstCategoryNonZeroOffset() throws IOException { instance = new NewDTAFileReader(null, 117); @@ -102,7 +102,7 @@ public void testFirstCategoryNonZeroOffset() throws IOException { } // TODO: Can we create a small file to check into the code base that exercises the value-label names non-zero offset issue? - @Ignore + @Disabled @Test public void testFirstCategoryNonZeroOffset1() throws IOException { instance = new NewDTAFileReader(null, 118); @@ -122,7 +122,7 @@ public void testFirstCategoryNonZeroOffset1() throws IOException { } // TODO: Is there a way to exersise this code with a smaller file? 33k.dta is 21MB. - @Ignore + @Disabled @Test public void test33k() throws IOException { instance = new NewDTAFileReader(null, 119); @@ -132,7 +132,7 @@ public void test33k() throws IOException { // TODO: Can we create a small file to check into the code base that exercises the characteristics issue? // FIXME: testCharacteristics is passing in DTA117FileReaderTest but not here. - @Ignore + @Disabled @Test public void testCharacteristics() throws IOException { instance = new NewDTAFileReader(null, 117); diff --git a/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordResetDataTest.java b/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordResetDataTest.java index 0d04d715d19..d7831003142 100644 --- a/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordResetDataTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordResetDataTest.java @@ -18,19 +18,19 @@ public class PasswordResetDataTest { public PasswordResetDataTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() { } - @AfterClass + @AfterAll public static void tearDownClass() { } - @Before + @BeforeEach public void setUp() { } - @After + @AfterEach public void tearDown() { } diff --git a/src/test/java/edu/harvard/iq/dataverse/pidproviders/PidUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/pidproviders/PidUtilTest.java index 52dab3ddb6d..193a2b533ee 100644 --- a/src/test/java/edu/harvard/iq/dataverse/pidproviders/PidUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/pidproviders/PidUtilTest.java @@ -35,14 +35,15 @@ public class PidUtilTest { private PermaLinkPidProviderServiceBean p = new PermaLinkPidProviderServiceBean(); - @Before public void initMocks() { + @BeforeEach + public void initMocks() { MockitoAnnotations.initMocks(this); Mockito.when(settingsServiceBean.getValueForKey(SettingsServiceBean.Key.Protocol)).thenReturn("perma"); Mockito.when(settingsServiceBean.getValueForKey(SettingsServiceBean.Key.Authority)).thenReturn("DANSLINK"); p.reInit(); } - @Ignore + @Disabled @Test public void testGetDoi() throws IOException { String username = System.getenv("DataCiteUsername"); diff --git a/src/test/java/edu/harvard/iq/dataverse/provenance/ProvInvestigatorTest.java b/src/test/java/edu/harvard/iq/dataverse/provenance/ProvInvestigatorTest.java index 20b62bcbb0e..9ab9f87d15b 100644 --- a/src/test/java/edu/harvard/iq/dataverse/provenance/ProvInvestigatorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/provenance/ProvInvestigatorTest.java @@ -28,7 +28,7 @@ public class ProvInvestigatorTest { JsonParser jsonParser; private static final Logger logger = Logger.getLogger(ProvInvestigatorTest.class.getCanonicalName()); - @Before + @BeforeEach public void setUp() { provUtilBean = ProvInvestigator.getInstance(); jsonParser = new JsonParser(); diff --git a/src/test/java/edu/harvard/iq/dataverse/search/IndexUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/search/IndexUtilTest.java index 84ea519e71f..9be53b8b8b1 100644 --- a/src/test/java/edu/harvard/iq/dataverse/search/IndexUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/search/IndexUtilTest.java @@ -14,19 +14,19 @@ public class IndexUtilTest { public IndexUtilTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() { } - @AfterClass + @AfterAll public static void tearDownClass() { } - @Before + @BeforeEach public void setUp() { } - @After + @AfterEach public void tearDown() { } diff --git a/src/test/java/edu/harvard/iq/dataverse/search/SolrSearchResultTest.java b/src/test/java/edu/harvard/iq/dataverse/search/SolrSearchResultTest.java index 967b9bbdd5e..4fb29869db7 100644 --- a/src/test/java/edu/harvard/iq/dataverse/search/SolrSearchResultTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/search/SolrSearchResultTest.java @@ -35,7 +35,7 @@ public class SolrSearchResultTest { SolrSearchResult solrSearchResult; - @Before + @BeforeEach public void before() { this.unpublishedFlag = IndexServiceBean.getUNPUBLISHED_STRING(); this.publishedFlag = IndexServiceBean.getPUBLISHED_STRING(); @@ -47,7 +47,7 @@ public void before() { this.solrSearchResult = new SolrSearchResult("myQuery", "myName"); } - @After + @AfterEach public void after() { this.unpublishedFlag = null; this.publishedFlag = null; diff --git a/src/test/java/edu/harvard/iq/dataverse/search/SortByTest.java b/src/test/java/edu/harvard/iq/dataverse/search/SortByTest.java index f2c31f137a2..c8425198b83 100644 --- a/src/test/java/edu/harvard/iq/dataverse/search/SortByTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/search/SortByTest.java @@ -14,14 +14,14 @@ public class SortByTest { private String order; private SortBy instance; - @Before + @BeforeEach public void setUp() { this.field = "field"; this.order = SortBy.ASCENDING; this.instance = new SortBy(field, order); } - @After + @AfterEach public void tearDown() { this.field = null; this.order = null; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/BitSetTest.java b/src/test/java/edu/harvard/iq/dataverse/util/BitSetTest.java index 51cd409c3f2..445c61e1857 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/BitSetTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/BitSetTest.java @@ -28,21 +28,21 @@ enum TestEnum { public BitSetTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() { } - @AfterClass + @AfterAll public static void tearDownClass() { } BitSet sut; - @Before + @BeforeEach public void setUp() { sut = new BitSet(); } - @After + @AfterEach public void tearDown() { } diff --git a/src/test/java/edu/harvard/iq/dataverse/util/JhoveFileTypeTest.java b/src/test/java/edu/harvard/iq/dataverse/util/JhoveFileTypeTest.java index 2a08426ac6c..879c4bc1c4e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/JhoveFileTypeTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/JhoveFileTypeTest.java @@ -24,7 +24,7 @@ public class JhoveFileTypeTest { static File ico; static File ipynb; - @BeforeClass + @BeforeAll public static void setUpClass() { System.setProperty("com.sun.aas.instanceRoot", baseDirForConfigFiles); jhoveFileType = new JhoveFileType(); @@ -41,7 +41,7 @@ public static void setUpClass() { ipynb = new File("src/test/java/edu/harvard/iq/dataverse/util/irc-metrics.ipynb"); } - @AfterClass + @AfterAll public static void tearDownClass() { // SiteMapUtilTest relies on com.sun.aas.instanceRoot being null. System.clearProperty("com.sun.aas.instanceRoot"); diff --git a/src/test/java/edu/harvard/iq/dataverse/util/JsfHelperTest.java b/src/test/java/edu/harvard/iq/dataverse/util/JsfHelperTest.java index 466edc67b60..d5230a521b9 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/JsfHelperTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/JsfHelperTest.java @@ -25,19 +25,19 @@ public class JsfHelperTest { enum TestEnum { Lorem, Ipsum, Dolor, Sit, Amet } - @BeforeClass + @BeforeAll public static void setUpClass() { } - @AfterClass + @AfterAll public static void tearDownClass() { } - @Before + @BeforeEach public void setUp() { } - @After + @AfterEach public void tearDown() { } diff --git a/src/test/java/edu/harvard/iq/dataverse/util/LruCacheTest.java b/src/test/java/edu/harvard/iq/dataverse/util/LruCacheTest.java index f2c2a09d416..77aa09c3367 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/LruCacheTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/LruCacheTest.java @@ -14,12 +14,12 @@ public class LruCacheTest { LruCache sut; - @Before + @BeforeEach public void setUp() { sut = new LruCache<>(); } - @After + @AfterEach public void tearDown() { sut = null; } diff --git a/src/test/java/edu/harvard/iq/dataverse/util/MailUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/util/MailUtilTest.java index 89b0a7a738b..bbdf5a84fc3 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/MailUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/MailUtilTest.java @@ -27,7 +27,7 @@ public class MailUtilTest { @Mock SettingsServiceBean settingsSvc; - @Before + @BeforeEach public void setUp() { userNotification = new UserNotification(); diff --git a/src/test/java/edu/harvard/iq/dataverse/util/PersonOrOrgUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/util/PersonOrOrgUtilTest.java index f32f6b0873a..c3d9fd8fcd3 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/PersonOrOrgUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/PersonOrOrgUtilTest.java @@ -58,7 +58,7 @@ public void testOrganizationCommaOrDash() { verifyIsOrganization("Geographic Data Technology, Inc. (GDT)"); } - @Ignore + @Disabled @Test public void testOrganizationES() { //Spanish recognition is not enabled - see export/Organization.java diff --git a/src/test/java/edu/harvard/iq/dataverse/util/bagit/BagValidatorTest.java b/src/test/java/edu/harvard/iq/dataverse/util/bagit/BagValidatorTest.java index bb0ea50071d..1bca0932466 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/bagit/BagValidatorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/bagit/BagValidatorTest.java @@ -33,7 +33,7 @@ public class BagValidatorTest { private ManifestReader manifestReader; private BagValidator target; - @Before + @BeforeEach public void beforeEachTest() { manifestReader = Mockito.mock(ManifestReader.class); target = Mockito.spy(new BagValidator(manifestReader)); diff --git a/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerTest.java b/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerTest.java index 7a58a8e04c1..b3975890d36 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerTest.java @@ -47,7 +47,7 @@ public class BagItFileHandlerTest { private BagItFileHandler target; - @Before + @BeforeEach public void beforeEachTest() { FILE_UTIL = Mockito.mock(FileUtilWrapper.class, Mockito.RETURNS_DEEP_STUBS); SYSTEM_CONFIG = Mockito.mock(SystemConfig.class, Mockito.RETURNS_DEEP_STUBS); diff --git a/src/test/java/edu/harvard/iq/dataverse/util/json/DatasetVersionDTOTest.java b/src/test/java/edu/harvard/iq/dataverse/util/json/DatasetVersionDTOTest.java index 08c4a78795a..9ee2a7717dd 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/json/DatasetVersionDTOTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/json/DatasetVersionDTOTest.java @@ -34,19 +34,19 @@ public class DatasetVersionDTOTest { public DatasetVersionDTOTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() { } - @AfterClass + @AfterAll public static void tearDownClass() { } - @Before + @BeforeEach public void setUp() { } - @After + @AfterEach public void tearDown() { } diff --git a/src/test/java/edu/harvard/iq/dataverse/util/json/JsonParserTest.java b/src/test/java/edu/harvard/iq/dataverse/util/json/JsonParserTest.java index 96437022da8..c1f9e398125 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/json/JsonParserTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/json/JsonParserTest.java @@ -82,15 +82,15 @@ public class JsonParserTest { public JsonParserTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() { } - @AfterClass + @AfterAll public static void tearDownClass() { } - @Before + @BeforeEach public void setUp() { datasetFieldTypeSvc = new MockDatasetFieldSvc(); datasetFieldTypeSvc.setMetadataBlock("citation"); diff --git a/src/test/java/edu/harvard/iq/dataverse/util/json/JsonPrinterTest.java b/src/test/java/edu/harvard/iq/dataverse/util/json/JsonPrinterTest.java index 5d7e8eaa50e..1d054040e84 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/json/JsonPrinterTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/json/JsonPrinterTest.java @@ -37,7 +37,7 @@ public class JsonPrinterTest { MockDatasetFieldSvc datasetFieldTypeSvc = null; - @Before + @BeforeEach public void setUp() { datasetFieldTypeSvc = new MockDatasetFieldSvc(); datasetFieldTypeSvc.setMetadataBlock("citation"); From 930950a06d6f21714fe842b6d63cd8041f97ce73 Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Fri, 18 Aug 2023 17:03:16 +0200 Subject: [PATCH 04/17] build(test): migrate JUnit 4 Categories to JUnit 5 Tags, adapt Maven Surefire config #9782 --- pom.xml | 2 +- .../harvard/iq/dataverse/NonEssentialTests.java | 10 ---------- .../provenance/ProvInvestigatorTest.java | 16 ++++++++-------- .../harvard/iq/dataverse/util/testing/Tags.java | 5 +++++ .../iq/dataverse/util/xml/XmlValidatorTest.java | 4 ++-- 5 files changed, 16 insertions(+), 21 deletions(-) delete mode 100644 src/test/java/edu/harvard/iq/dataverse/NonEssentialTests.java create mode 100644 src/test/java/edu/harvard/iq/dataverse/util/testing/Tags.java diff --git a/pom.xml b/pom.xml index eee3d956f38..3f3be6538c4 100644 --- a/pom.xml +++ b/pom.xml @@ -781,7 +781,7 @@ true - edu.harvard.iq.dataverse.NonEssentialTests + not-essential-unittests diff --git a/src/test/java/edu/harvard/iq/dataverse/NonEssentialTests.java b/src/test/java/edu/harvard/iq/dataverse/NonEssentialTests.java deleted file mode 100644 index 612904cbd26..00000000000 --- a/src/test/java/edu/harvard/iq/dataverse/NonEssentialTests.java +++ /dev/null @@ -1,10 +0,0 @@ -package edu.harvard.iq.dataverse; - -/** - * Tests annotated as non-essential will not be run by default on developers' - * laptops but they will run on continuous integration platforms like Travis CI. - * To work on one of these tests, you have to comment out the annotation. - */ -public interface NonEssentialTests { - -} diff --git a/src/test/java/edu/harvard/iq/dataverse/provenance/ProvInvestigatorTest.java b/src/test/java/edu/harvard/iq/dataverse/provenance/ProvInvestigatorTest.java index 9ab9f87d15b..f59f686a94c 100644 --- a/src/test/java/edu/harvard/iq/dataverse/provenance/ProvInvestigatorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/provenance/ProvInvestigatorTest.java @@ -34,7 +34,7 @@ public void setUp() { jsonParser = new JsonParser(); } - @Category(NonEssentialTests.class) + @Tag(Tags.NOT_ESSENTIAL_UNITTESTS) @Test public void testProvValidator() { String validJsonString = "{\n" + @@ -106,7 +106,7 @@ public void testProvValidator() { } - @Category(NonEssentialTests.class) + @Tag(Tags.NOT_ESSENTIAL_UNITTESTS) @Test public void testProvNamesNotInsideEntity() throws IOException { //name and type on their own @@ -121,7 +121,7 @@ public void testProvNamesNotInsideEntity() throws IOException { assertFalse(entities.size() > 0); } - @Category(NonEssentialTests.class) + @Tag(Tags.NOT_ESSENTIAL_UNITTESTS) @Test public void testProvNameJsonParserEmptyEntities() throws IOException { String jsonString = "{\n" + @@ -160,8 +160,8 @@ public void testProvNameJsonParserEmptyEntities() throws IOException { //Note: this test has entity tags in multiple places, all with unique names //Only one entity is added to our list per unique name. - - @Category(NonEssentialTests.class) + + @Tag(Tags.NOT_ESSENTIAL_UNITTESTS) @Test public void testProvJsonWithEntitiesInMultiplePlaces() throws IOException { String jsonString = "{\n" + @@ -234,7 +234,7 @@ public void testProvJsonWithEntitiesInMultiplePlaces() throws IOException { assertTrue(entities.size() == 7); } - @Category(NonEssentialTests.class) + @Tag(Tags.NOT_ESSENTIAL_UNITTESTS) @Test public void testProvJsonWithEntitiesInMultiplePlacesWithSameNames() throws IOException { String jsonString = "{\n" + @@ -272,8 +272,8 @@ public void testProvJsonWithEntitiesInMultiplePlacesWithSameNames() throws IOExc assertTrue(entities.get("ex:report2").fileType.equals("not report")); assertTrue(entities.size() == 3); //ex:report2 & ex:report1 are repeated } - - @Category(NonEssentialTests.class) + + @Tag(Tags.NOT_ESSENTIAL_UNITTESTS) @Test public void testProvLongJsonWithEntities() throws IOException { String jsonString = "{\n" + diff --git a/src/test/java/edu/harvard/iq/dataverse/util/testing/Tags.java b/src/test/java/edu/harvard/iq/dataverse/util/testing/Tags.java new file mode 100644 index 00000000000..dcbd0529d8b --- /dev/null +++ b/src/test/java/edu/harvard/iq/dataverse/util/testing/Tags.java @@ -0,0 +1,5 @@ +package edu.harvard.iq.dataverse.util.testing; + +public class Tags { + public static final String NOT_ESSENTIAL_UNITTESTS = "not-essential-unittests"; +} diff --git a/src/test/java/edu/harvard/iq/dataverse/util/xml/XmlValidatorTest.java b/src/test/java/edu/harvard/iq/dataverse/util/xml/XmlValidatorTest.java index 6a870a7c3bf..f339691fde3 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/xml/XmlValidatorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/xml/XmlValidatorTest.java @@ -20,8 +20,8 @@ public class XmlValidatorTest { //Ignored as this relies on an external resource that has been down occasionally. //May be a good test for our full vs. everytime test classifications (#4896) -MAD 4.9.1 - @Ignore - @Category(NonEssentialTests.class) + @Disabled + @Tag(Tags.NOT_ESSENTIAL_UNITTESTS) @Test public void testValidateXml() throws IOException, SAXException, ParserConfigurationException { assertTrue(XmlValidator.validateXmlSchema("src/test/java/edu/harvard/iq/dataverse/util/xml/sendToDataCite.xml", new URL("https://schema.datacite.org/meta/kernel-3/metadata.xsd"))); From 889a85788e3f1a0e66c866f20413e5075ad2e1d0 Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Fri, 18 Aug 2023 17:24:13 +0200 Subject: [PATCH 05/17] build(test): migrate JUnit4 @runWith annotations to JUnit5 or delete where obsolete #9782 --- .../iq/dataverse/DataFileCategoryServiceBeanTest.java | 2 +- .../harvard/iq/dataverse/EditDataFilesPageHelperTest.java | 2 +- .../iq/dataverse/PersistentIdentifierServiceBeanTest.java | 2 +- .../java/edu/harvard/iq/dataverse/api/DataversesTest.java | 2 +- .../dataverse/api/imports/ImportGenericServiceBeanTest.java | 2 +- .../harvard/iq/dataverse/authorization/AuthUtilTest.java | 1 - .../authorization/providers/shib/ShibUtilTest.java | 1 - .../authorization/users/AuthenticatedUserTest.java | 2 +- .../iq/dataverse/confirmemail/ConfirmEmailUtilTest.java | 1 - .../edu/harvard/iq/dataverse/mydata/MyDataUtilTest.java | 3 +-- .../harvard/iq/dataverse/mydata/SolrQueryFormatterTest.java | 6 +----- .../iq/dataverse/passwordreset/PasswordValidatorTest.java | 1 - .../edu/harvard/iq/dataverse/pidproviders/PidUtilTest.java | 2 +- .../java/edu/harvard/iq/dataverse/util/JsfHelperTest.java | 5 ----- .../iq/dataverse/util/file/BagItFileHandlerFactoryTest.java | 2 +- .../iq/dataverse/validation/PasswordValidatorUtilTest.java | 1 - 16 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/test/java/edu/harvard/iq/dataverse/DataFileCategoryServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/DataFileCategoryServiceBeanTest.java index 6e6d176194b..53add343f4f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DataFileCategoryServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DataFileCategoryServiceBeanTest.java @@ -21,7 +21,7 @@ * * @author adaybujeda */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class DataFileCategoryServiceBeanTest { @Mock diff --git a/src/test/java/edu/harvard/iq/dataverse/EditDataFilesPageHelperTest.java b/src/test/java/edu/harvard/iq/dataverse/EditDataFilesPageHelperTest.java index 621c05937f5..39d43fec191 100644 --- a/src/test/java/edu/harvard/iq/dataverse/EditDataFilesPageHelperTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/EditDataFilesPageHelperTest.java @@ -19,7 +19,7 @@ * * @author adaybujeda */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class EditDataFilesPageHelperTest { private static final String FILENAME = UUID.randomUUID().toString(); diff --git a/src/test/java/edu/harvard/iq/dataverse/PersistentIdentifierServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/PersistentIdentifierServiceBeanTest.java index dcd0f583d9f..542d00d0d78 100644 --- a/src/test/java/edu/harvard/iq/dataverse/PersistentIdentifierServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/PersistentIdentifierServiceBeanTest.java @@ -26,7 +26,7 @@ * * @author michael */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class PersistentIdentifierServiceBeanTest { @Mock diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DataversesTest.java b/src/test/java/edu/harvard/iq/dataverse/api/DataversesTest.java index a2f5c3335ee..212eb581fc8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DataversesTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DataversesTest.java @@ -44,7 +44,7 @@ * * @author adaybujeda */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class DataversesTest { // From AbstractApiBean class @Mock diff --git a/src/test/java/edu/harvard/iq/dataverse/api/imports/ImportGenericServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/api/imports/ImportGenericServiceBeanTest.java index b2ef3f24ff7..3e7d8407de5 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/imports/ImportGenericServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/imports/ImportGenericServiceBeanTest.java @@ -8,7 +8,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class ImportGenericServiceBeanTest { @InjectMocks diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/AuthUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/AuthUtilTest.java index 7e659d03a5d..66c7fbbbc70 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/AuthUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/AuthUtilTest.java @@ -16,7 +16,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -@RunWith(Enclosed.class) public class AuthUtilTest { @RunWith(Parameterized.class) diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/shib/ShibUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/shib/ShibUtilTest.java index 4c444c3e75d..c011ad3041d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/shib/ShibUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/shib/ShibUtilTest.java @@ -15,7 +15,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; -@RunWith(Enclosed.class) public class ShibUtilTest { @RunWith(Parameterized.class) diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/users/AuthenticatedUserTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/users/AuthenticatedUserTest.java index 9a2781a80bd..6c430d0a09a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/users/AuthenticatedUserTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/users/AuthenticatedUserTest.java @@ -35,7 +35,7 @@ * * @author bsilverstein */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class AuthenticatedUserTest { @Mock diff --git a/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailUtilTest.java index cf4759fe9f5..d2ef6a51a84 100644 --- a/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailUtilTest.java @@ -10,7 +10,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -@RunWith(Enclosed.class) public class ConfirmEmailUtilTest { @RunWith(Parameterized.class) diff --git a/src/test/java/edu/harvard/iq/dataverse/mydata/MyDataUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/mydata/MyDataUtilTest.java index 5aa840981ad..111d785f52d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/mydata/MyDataUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/mydata/MyDataUtilTest.java @@ -11,8 +11,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assumptions.assumeTrue; -@RunWith(Theories.class) -public class MyDataUtilTest { +class MyDataUtilTest { @DataPoints public static String[] userIdentifier = { diff --git a/src/test/java/edu/harvard/iq/dataverse/mydata/SolrQueryFormatterTest.java b/src/test/java/edu/harvard/iq/dataverse/mydata/SolrQueryFormatterTest.java index 9cd4cfcf41f..6f242d67dcf 100644 --- a/src/test/java/edu/harvard/iq/dataverse/mydata/SolrQueryFormatterTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/mydata/SolrQueryFormatterTest.java @@ -25,11 +25,7 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -/** - * - * @author rmp553 - */ -@RunWith(Enclosed.class) + public class SolrQueryFormatterTest { public static class SolrQueryFormatterNoParamTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordValidatorTest.java b/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordValidatorTest.java index 6812ebf382c..2187ff3235d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordValidatorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordValidatorTest.java @@ -8,7 +8,6 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) public class PasswordValidatorTest { public String password; diff --git a/src/test/java/edu/harvard/iq/dataverse/pidproviders/PidUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/pidproviders/PidUtilTest.java index 193a2b533ee..dabc7f68fce 100644 --- a/src/test/java/edu/harvard/iq/dataverse/pidproviders/PidUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/pidproviders/PidUtilTest.java @@ -27,7 +27,7 @@ /** * Useful for testing but requires DataCite credentials, etc. */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class PidUtilTest { @Mock private SettingsServiceBean settingsServiceBean; diff --git a/src/test/java/edu/harvard/iq/dataverse/util/JsfHelperTest.java b/src/test/java/edu/harvard/iq/dataverse/util/JsfHelperTest.java index d5230a521b9..0f68c1e7371 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/JsfHelperTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/JsfHelperTest.java @@ -16,11 +16,6 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -/** - * - * @author michael - */ -@RunWith(Parameterized.class) public class JsfHelperTest { enum TestEnum { Lorem, Ipsum, Dolor, Sit, Amet } diff --git a/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerFactoryTest.java b/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerFactoryTest.java index 1bff1e08baf..8b047443745 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerFactoryTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/file/BagItFileHandlerFactoryTest.java @@ -15,7 +15,7 @@ * * @author adaybujeda */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class BagItFileHandlerFactoryTest { @Mock diff --git a/src/test/java/edu/harvard/iq/dataverse/validation/PasswordValidatorUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/validation/PasswordValidatorUtilTest.java index 6cec8955215..99d42cbb1ff 100644 --- a/src/test/java/edu/harvard/iq/dataverse/validation/PasswordValidatorUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/validation/PasswordValidatorUtilTest.java @@ -24,7 +24,6 @@ * * @author pdurbin */ -@RunWith(Enclosed.class) public class PasswordValidatorUtilTest { public static class PasswordValidatorUtilNoParamTest { From fbd7077814e9a9ba4e03b31a6cbf9cf0ec4001c8 Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Fri, 18 Aug 2023 17:36:38 +0200 Subject: [PATCH 06/17] build(test): migrate exception testing from JUnit4 to JUnit5 style --- .../harvard/iq/dataverse/GlobalIdTest.java | 17 ++--- .../iq/dataverse/api/AbstractApiBeanTest.java | 12 ++-- .../iq/dataverse/api/FileMetadataIT.java | 7 +- .../impl/explicit/ExplicitGroupTest.java | 17 ++--- .../impl/ipaddress/ip/IPv4AddressTest.java | 6 +- .../impl/ipaddress/ip/IPv6AddressTest.java | 24 +++---- .../DuplicateFileCheckerTest.java | 38 +++++------ .../dataverse/DataverseUtilTest.java | 67 ++++--------------- .../impl/AbstractDatasetCommandTest.java | 18 ++--- .../impl/CreateDatasetVersionCommandTest.java | 6 +- .../impl/CreateDataverseCommandTest.java | 27 +++++--- .../command/impl/CreateRoleCommandTest.java | 13 ++-- .../command/impl/MoveDatasetCommandTest.java | 39 +++++------ .../impl/MoveDataverseCommandTest.java | 63 ++++++++--------- .../ReturnDatasetToAuthorCommandTest.java | 7 +- .../SubmitDatasetForReviewCommandTest.java | 7 +- .../UpdateMetadataBlockFacetsCommandTest.java | 6 +- .../impl/plugins/dta/DataReaderTest.java | 6 +- .../plugins/dta/NewDTAFileReaderTest.java | 6 +- .../locality/StorageSiteUtilTest.java | 27 ++++---- .../iq/dataverse/metrics/MetricsUtilTest.java | 20 +++--- .../iq/dataverse/util/BundleUtilTest.java | 10 +-- .../iq/dataverse/util/LruCacheTest.java | 6 +- .../dataverse/util/json/JsonParserTest.java | 58 ++++++++-------- 24 files changed, 229 insertions(+), 278 deletions(-) diff --git a/src/test/java/edu/harvard/iq/dataverse/GlobalIdTest.java b/src/test/java/edu/harvard/iq/dataverse/GlobalIdTest.java index 7a615b15345..394f08c6e93 100644 --- a/src/test/java/edu/harvard/iq/dataverse/GlobalIdTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/GlobalIdTest.java @@ -16,9 +16,6 @@ */ public class GlobalIdTest { - @Rule - public ExpectedException exception = ExpectedException.none(); - @Test public void testValidDOI() { System.out.println("testValidDOI"); @@ -74,9 +71,9 @@ public void testUnknownProtocol() { System.out.println("testUnknownProtocol"); String badProtocol = "doy:10.5072/FK2/BYM3IW"; - - exception.expect(IllegalArgumentException.class); - exception.expectMessage("Failed to parse identifier: " + badProtocol); + + //exception.expect(IllegalArgumentException.class); + //exception.expectMessage("Failed to parse identifier: " + badProtocol); //new GlobalId(badProtocol); } @@ -85,8 +82,8 @@ public void testUnknownProtocol() { public void testBadIdentifierOnePart() { System.out.println("testBadIdentifierOnePart"); - exception.expect(IllegalArgumentException.class); - exception.expectMessage("Failed to parse identifier: 1part"); + //exception.expect(IllegalArgumentException.class); + //exception.expectMessage("Failed to parse identifier: 1part"); //new GlobalId("1part"); } @@ -95,8 +92,8 @@ public void testBadIdentifierOnePart() { public void testBadIdentifierTwoParts() { System.out.println("testBadIdentifierTwoParts"); - exception.expect(IllegalArgumentException.class); - exception.expectMessage("Failed to parse identifier: doi:2part/blah"); + //exception.expect(IllegalArgumentException.class); + //exception.expectMessage("Failed to parse identifier: doi:2part/blah"); //new GlobalId("doi:2part/blah"); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/AbstractApiBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/api/AbstractApiBeanTest.java index 860eeb47f4f..c67dfeeadfa 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/AbstractApiBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/AbstractApiBeanTest.java @@ -38,15 +38,15 @@ public void testParseBooleanOrDie_ok() throws Exception { assertFalse(sut.parseBooleanOrDie("0")); assertFalse(sut.parseBooleanOrDie("no")); } - - @Test(expected = Exception.class) - public void testParseBooleanOrDie_invalid() throws Exception { - sut.parseBooleanOrDie("I'm not a boolean value!"); + + @Test + void testParseBooleanOrDie_invalid() { + assertThrows(Exception.class, () -> sut.parseBooleanOrDie("I'm not a boolean value!")); } @Test - public void testFailIfNull_ok() throws Exception { - sut.failIfNull(sut, ""); + void testFailIfNull_ok() { + assertDoesNotThrow(() -> sut.failIfNull(sut, "")); } @Test diff --git a/src/test/java/edu/harvard/iq/dataverse/api/FileMetadataIT.java b/src/test/java/edu/harvard/iq/dataverse/api/FileMetadataIT.java index 8c87440b488..c867af75956 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/FileMetadataIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/FileMetadataIT.java @@ -80,8 +80,7 @@ public void setUpDataverse() { .then().assertThat().statusCode(201); System.out.println("DATAVERSE: " + RestAssured.baseURI + "/dataverse/" + testName); } catch (Exception e) { - System.out.println("Error setting up test dataverse: " + e.getMessage()); - fail(); + fail("Error setting up test dataverse: " + e.getMessage(), e); } } @@ -166,9 +165,7 @@ public void testJsonParserWithDirectoryLabels() { .statusCode(200); } catch (Exception e) { - System.out.println("Error testJsonParserWithDirectoryLabels: " + e.getMessage()); - e.printStackTrace(); - fail(); + fail("Error testJsonParserWithDirectoryLabels: " + e.getMessage(), e); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/explicit/ExplicitGroupTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/explicit/ExplicitGroupTest.java index d95a95a8d3a..afa07be2e38 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/explicit/ExplicitGroupTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/explicit/ExplicitGroupTest.java @@ -34,15 +34,14 @@ public class ExplicitGroupTest { public ExplicitGroupTest() { } - @Test( expected=GroupException.class ) + @Test public void addGroupToSelf() throws Exception { ExplicitGroup sut = new ExplicitGroup(); sut.setDisplayName("a group"); - sut.add( sut ); - fail("A group cannot be added to itself."); + assertThrows(GroupException.class, () -> sut.add( sut ), "A group cannot be added to itself."); } - @Test( expected=GroupException.class ) + @Test public void addGroupToDescendant() throws GroupException{ Dataverse dv = makeDataverse(); ExplicitGroup root = new ExplicitGroup(prv); @@ -60,11 +59,10 @@ public void addGroupToDescendant() throws GroupException{ sub.add( subSub ); root.add( sub ); - subSub.add(root); - fail("A group cannot contain its parent"); + assertThrows(GroupException.class, () -> subSub.add(root), "A group cannot contain its parent"); } - @Test( expected=GroupException.class ) + @Test public void addGroupToUnrealtedGroup() throws GroupException { Dataverse dv1 = makeDataverse(); Dataverse dv2 = makeDataverse(); @@ -73,9 +71,8 @@ public void addGroupToUnrealtedGroup() throws GroupException { g1.setOwner(dv1); g2.setOwner(dv2); - g1.add(g2); - fail("An explicit group cannot contain an explicit group defined in " - + "a dataverse that's not an ancestor of that group's owner dataverse."); + assertThrows(GroupException.class, () -> g1.add(g2), "An explicit group cannot contain an" + + "explicit group defined in a dataverse that's not an ancestor of that group's owner dataverse."); } diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv4AddressTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv4AddressTest.java index 4bab4546ca4..4683d66decd 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv4AddressTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv4AddressTest.java @@ -22,9 +22,9 @@ public void testValueOf() { assertEquals( new IPv4Address(127,0,0,1), IPv4Address.valueOf("127.0.0.1") ); } - @Test( expected=IllegalArgumentException.class ) - public void testValueOf_bad() { - IPv4Address.valueOf("1.2.3"); + @Test + void testValueOf_bad() { + assertThrows(IllegalArgumentException.class, () -> IPv4Address.valueOf("1.2.3")); } @Test diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv6AddressTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv6AddressTest.java index 1fa6e7d2473..2f43bc64ce8 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv6AddressTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv6AddressTest.java @@ -109,24 +109,24 @@ public void testLocalhostness() { assertFalse(IPv6Address.valueOf("fff::1").isLocalhost()); } - @Test(expected = IllegalArgumentException.class) - public void testIllegalLength() { - IPv6Address.valueOf("0:1:2:3"); + @Test + void testIllegalLength() { + assertThrows(IllegalArgumentException.class, () -> IPv6Address.valueOf("0:1:2:3")); } - @Test(expected = IllegalArgumentException.class) - public void testIllegalLengthPrefix() { - IPv6Address.valueOf(":1:2:3"); + @Test + void testIllegalLengthPrefix() { + assertThrows(IllegalArgumentException.class, () -> IPv6Address.valueOf(":1:2:3")); } - @Test(expected = IllegalArgumentException.class) - public void testIllegalLengthSuffix() { - IPv6Address.valueOf("1:2:3:"); + @Test + void testIllegalLengthSuffix() { + assertThrows(IllegalArgumentException.class, () -> IPv6Address.valueOf("1:2:3:")); } - @Test(expected = IllegalArgumentException.class) - public void testIllegalNumber() { - IPv6Address.valueOf("::xxx"); + @Test + void testIllegalNumber() { + assertThrows(IllegalArgumentException.class, () -> IPv6Address.valueOf("::xxx")); } @Test diff --git a/src/test/java/edu/harvard/iq/dataverse/datasetutility/DuplicateFileCheckerTest.java b/src/test/java/edu/harvard/iq/dataverse/datasetutility/DuplicateFileCheckerTest.java index 42d6c2385b8..ced15594f85 100644 --- a/src/test/java/edu/harvard/iq/dataverse/datasetutility/DuplicateFileCheckerTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/datasetutility/DuplicateFileCheckerTest.java @@ -34,9 +34,9 @@ public void tearDown() { // test constructor // ---------------------------------------------------------------------------------------------------------- - @Test(expected = NullPointerException.class) - public void testConstructorWithUndefinedDatasetVersionService() { - DuplicateFileChecker duplicateFileChecker = new DuplicateFileChecker(null); + @Test + void testConstructorWithUndefinedDatasetVersionService() { + assertThrows(NullPointerException.class, () -> new DuplicateFileChecker(null)); } @Test @@ -49,20 +49,20 @@ public void testConstructorWithDefinedDatasetVersionService() { // test public boolean isFileInSavedDatasetVersion(DatasetVersion datasetVersion, String checkSum) // ---------------------------------------------------------------------------------------------------------- - @Test(expected = NullPointerException.class) - public void testIsFileInSavedDatasetVersionWithCheckSumParamWithUndefinedDatasetVersion() { + @Test + void testIsFileInSavedDatasetVersionWithCheckSumParamWithUndefinedDatasetVersion() { DatasetVersion datasetVersion = null; String checkSum = "checkSum"; - - this.duplicateFileChecker.isFileInSavedDatasetVersion(datasetVersion, checkSum); + + assertThrows(NullPointerException.class, () -> this.duplicateFileChecker.isFileInSavedDatasetVersion(datasetVersion, checkSum)); } - @Test(expected = NullPointerException.class) - public void testIsFileInSavedDatasetVersionWithChecksumParamWithUndefinedChecksum() { + @Test + void testIsFileInSavedDatasetVersionWithChecksumParamWithUndefinedChecksum() { DatasetVersion datasetVersion = new DatasetVersion(); String checkSum = null; - - this.duplicateFileChecker.isFileInSavedDatasetVersion(datasetVersion, checkSum); + + assertThrows(NullPointerException.class, () -> this.duplicateFileChecker.isFileInSavedDatasetVersion(datasetVersion, checkSum)); } @Test @@ -81,20 +81,20 @@ public void testIsFileInSavedDatasetVersionWithChecksumParamWithUnsavedFile() { // test public boolean isFileInSavedDatasetVersion(DatasetVersion datasetVersion, FileMetadata fileMetadata) // ---------------------------------------------------------------------------------------------------------- - @Test(expected = NullPointerException.class) - public void testIsFileInSavedDatasetVersionWithFileMetadataParamWithUndefinedDatasetVersion() { + @Test + void testIsFileInSavedDatasetVersionWithFileMetadataParamWithUndefinedDatasetVersion() { DatasetVersion datasetVersion = null; FileMetadata fileMetadata = new FileMetadata(); - - this.duplicateFileChecker.isFileInSavedDatasetVersion(datasetVersion, fileMetadata); + + assertThrows(NullPointerException.class, () -> this.duplicateFileChecker.isFileInSavedDatasetVersion(datasetVersion, fileMetadata)); } - @Test(expected = NullPointerException.class) - public void testIsFileInSavedDatasetVersionWithFileMetadataParamWithUndefinedFileMetadata() { + @Test + void testIsFileInSavedDatasetVersionWithFileMetadataParamWithUndefinedFileMetadata() { DatasetVersion datasetVersion = new DatasetVersion(); FileMetadata fileMetadata = null; - - this.duplicateFileChecker.isFileInSavedDatasetVersion(datasetVersion, fileMetadata); + + assertThrows(NullPointerException.class, () -> this.duplicateFileChecker.isFileInSavedDatasetVersion(datasetVersion, fileMetadata)); } @Test diff --git a/src/test/java/edu/harvard/iq/dataverse/dataverse/DataverseUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/dataverse/DataverseUtilTest.java index dacebac9117..01e0edd3073 100644 --- a/src/test/java/edu/harvard/iq/dataverse/dataverse/DataverseUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/dataverse/DataverseUtilTest.java @@ -44,69 +44,30 @@ public void testCheckMetadataLanguageCases() { definedFrenchD.setMetadataLanguage("fr"); Dataset definedSpanishD = new Dataset(); definedSpanishD.setMetadataLanguage("es"); + // Not set tests: //Good - no mLang sent, parent doesn't have one - try { - DataverseUtil.checkMetadataLangauge(undefinedD, undefinedParent, emptyMLangSettingMap); - } catch (BadRequestException e) { - Assert.fail(); - } + assertDoesNotThrow(() -> DataverseUtil.checkMetadataLangauge(undefinedD, undefinedParent, emptyMLangSettingMap)); //Bad - one sent, parent doesn't have one - try { - DataverseUtil.checkMetadataLangauge(definedEnglishD, undefinedParent, emptyMLangSettingMap); - Assert.fail(); - } catch (BadRequestException e) { - } + assertThrows(BadRequestException.class, () -> DataverseUtil.checkMetadataLangauge(definedEnglishD, undefinedParent, emptyMLangSettingMap)); //Good - one sent, matches parent - try { - DataverseUtil.checkMetadataLangauge(definedEnglishD, definedParent, emptyMLangSettingMap); - - } catch (BadRequestException e) { - Assert.fail(); - } + assertDoesNotThrow(() -> DataverseUtil.checkMetadataLangauge(definedEnglishD, definedParent, emptyMLangSettingMap)); //Bad - one sent, doesn't match parent - try { - DataverseUtil.checkMetadataLangauge(definedFrenchD, definedParent, emptyMLangSettingMap); - Assert.fail(); - } catch (BadRequestException e) { - } + assertThrows(BadRequestException.class, () -> DataverseUtil.checkMetadataLangauge(definedFrenchD, definedParent, emptyMLangSettingMap)); + //With setting tests - //Bad - one sent, parent doesn't have one - try { - DataverseUtil.checkMetadataLangauge(undefinedD, undefinedParent, mLangSettingMap); - Assert.fail(); - } catch (BadRequestException e) { - } + //Bad - one sent, parent doesn't have one + assertThrows(BadRequestException.class, () -> DataverseUtil.checkMetadataLangauge(undefinedD, undefinedParent, mLangSettingMap)); //Good - sent, parent undefined, is allowed by setting - try { - DataverseUtil.checkMetadataLangauge(definedEnglishD, undefinedParent, mLangSettingMap); - } catch (BadRequestException e) { - Assert.fail(); - } + assertDoesNotThrow(() -> DataverseUtil.checkMetadataLangauge(definedEnglishD, undefinedParent, mLangSettingMap)); //Bad one sent, parent undefined, not allowed by setting - try { - DataverseUtil.checkMetadataLangauge(definedSpanishD, undefinedParent, mLangSettingMap); - Assert.fail(); - } catch (BadRequestException e) { - } + assertThrows(BadRequestException.class, () -> DataverseUtil.checkMetadataLangauge(definedSpanishD, undefinedParent, mLangSettingMap)); //Bad - one sent, doesn't match parent - try { - DataverseUtil.checkMetadataLangauge(definedFrenchD, definedParent, mLangSettingMap); - Assert.fail(); - } catch (BadRequestException e) { - } + assertThrows(BadRequestException.class, () -> DataverseUtil.checkMetadataLangauge(definedFrenchD, definedParent, mLangSettingMap)); //Bad - undefined sent, parent is defined - try { - DataverseUtil.checkMetadataLangauge(undefinedD, definedParent, mLangSettingMap); - Assert.fail(); - } catch (BadRequestException e) { - } - //Good - sent, parent defined, they match - try { - DataverseUtil.checkMetadataLangauge(definedEnglishD, definedParent, mLangSettingMap); - } catch (BadRequestException e) { - Assert.fail(); - } + assertThrows(BadRequestException.class, () -> DataverseUtil.checkMetadataLangauge(undefinedD, definedParent, mLangSettingMap)); + //Good - sent, parent defined, they match + assertDoesNotThrow(() -> DataverseUtil.checkMetadataLangauge(definedEnglishD, definedParent, mLangSettingMap)); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/AbstractDatasetCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/AbstractDatasetCommandTest.java index 388483bfefc..efadd14438a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/AbstractDatasetCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/AbstractDatasetCommandTest.java @@ -19,16 +19,18 @@ public class AbstractDatasetCommandTest { - @Test(expected=IllegalArgumentException.class) - @SuppressWarnings("ResultOfObjectAllocationIgnored") - public void testNullDataset() { - new AbstractDatasetCommandImpl(makeRequest(), null); + @Test + void testNullDataset() { + DataverseRequest request = makeRequest(); + assertThrows(IllegalArgumentException.class, () -> new AbstractDatasetCommandImpl(request, null)); } - @Test(expected=IllegalArgumentException.class) - @SuppressWarnings("ResultOfObjectAllocationIgnored") - public void testNullDatasetNonNullParent() { - new AbstractDatasetCommandImpl(makeRequest(), null, makeDataverse()); + @Test + void testNullDatasetNonNullParent() { + DataverseRequest request = makeRequest(); + Dataverse dataverse = makeDataverse(); + assertThrows(IllegalArgumentException.class, + () -> new AbstractDatasetCommandImpl(request, null, dataverse)); } /** diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDatasetVersionCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDatasetVersionCommandTest.java index ca266d5208f..a2d9cdfb917 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDatasetVersionCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDatasetVersionCommandTest.java @@ -70,8 +70,8 @@ public void testSimpleVersionAddition() throws Exception { assertEquals(expected, testEngine.getReqiredPermissionsForObjects() ); } - @Test(expected=IllegalCommandException.class) - public void testCantCreateTwoDraftVersions() throws Exception { + @Test + void testCantCreateTwoDraftVersions() { DatasetVersion dsvNew = new DatasetVersion(); dsvNew.setVersionState(DatasetVersion.VersionState.DRAFT); Dataset sampleDataset = makeDataset(); @@ -89,7 +89,7 @@ public DatasetServiceBean datasets() { }); - testEngine.submit(sut); + assertThrows(IllegalCommandException.class, () -> testEngine.submit(sut)); } diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDataverseCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDataverseCommandTest.java index 195c8854b26..a52c06edf5e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDataverseCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDataverseCommandTest.java @@ -299,31 +299,38 @@ public void testCustomOptions() throws CommandException { } } - @Test( expected=IllegalCommandException.class ) - public void testCantCreateAdditionalRoot() throws Exception { - engine.submit( new CreateDataverseCommand(makeDataverse(), makeRequest(), null, null) ); + @Test + void testCantCreateAdditionalRoot() { + assertThrows(IllegalCommandException.class, + () -> engine.submit( new CreateDataverseCommand(makeDataverse(), makeRequest(), null, null) ) + ); } - @Test( expected=IllegalCommandException.class ) - public void testGuestCantCreateDataverse() throws Exception { + @Test + void testGuestCantCreateDataverse() { final DataverseRequest request = new DataverseRequest( GuestUser.get(), IpAddress.valueOf("::") ); isRootDvExists = false; - engine.submit(new CreateDataverseCommand(makeDataverse(), request, null, null) ); + assertThrows(IllegalCommandException.class, + () -> engine.submit(new CreateDataverseCommand(makeDataverse(), request, null, null) ) + ); } - @Test( expected=IllegalCommandException.class ) - public void testCantCreateAnotherWithSameAlias() throws Exception { + @Test + void testCantCreateAnotherWithSameAlias() { String alias = "alias"; final Dataverse dvFirst = makeDataverse(); dvFirst.setAlias(alias); dvFirst.setOwner( makeDataverse() ); - engine.submit(new CreateDataverseCommand(dvFirst, makeRequest(), null, null) ); + assertThrows(IllegalCommandException.class, + () -> engine.submit(new CreateDataverseCommand(dvFirst, makeRequest(), null, null) )); final Dataverse dv = makeDataverse(); dv.setOwner( makeDataverse() ); dv.setAlias(alias); - engine.submit(new CreateDataverseCommand(dv, makeRequest(), null, null) ); + assertThrows(IllegalCommandException.class, + () -> engine.submit(new CreateDataverseCommand(dv, makeRequest(), null, null) ) + ); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateRoleCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateRoleCommandTest.java index ab4f9dae3db..b1b1636f8e2 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateRoleCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateRoleCommandTest.java @@ -57,8 +57,8 @@ public void before() { saveCalled = false; } - @Test( expected = IllegalCommandException.class ) - public void testNonSuperUsersCantAddRoles() throws CommandException { + @Test + void testNonSuperUsersCantAddRoles() { DataverseRole dvr = new DataverseRole(); dvr.setAlias("roleTest"); dvr.setName("Tester Role"); @@ -71,8 +71,7 @@ public void testNonSuperUsersCantAddRoles() throws CommandException { normalUser.setSuperuser(false); CreateRoleCommand sut = new CreateRoleCommand(dvr, new DataverseRequest(normalUser,IpAddress.valueOf("89.17.33.33")), dv); - engine.submit(sut); - + assertThrows(IllegalCommandException.class, () -> engine.submit(sut)); } @Test @@ -94,8 +93,8 @@ public void testSuperUsersAddRoles() throws CommandException { } - @Test( expected = IllegalCommandException.class ) - public void testGuestUsersCantAddRoles() throws CommandException { + @Test + void testGuestUsersCantAddRoles() { DataverseRole dvr = new DataverseRole(); dvr.setAlias("roleTest"); dvr.setName("Tester Role"); @@ -105,7 +104,7 @@ public void testGuestUsersCantAddRoles() throws CommandException { dvr.setOwner(dv); CreateRoleCommand sut = new CreateRoleCommand(dvr, new DataverseRequest(GuestUser.get(),IpAddress.valueOf("89.17.33.33")), dv); - engine.submit(sut); + assertThrows(IllegalCommandException.class, () -> engine.submit(sut)); } private class LocalTestEntityManager extends TestEntityManager { diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDatasetCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDatasetCommandTest.java index 9b2591a796e..ed6112539ed 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDatasetCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDatasetCommandTest.java @@ -283,13 +283,11 @@ public void testRemoveGuestbook() throws Exception { * Moving DS to its owning DV * @throws IllegalCommandException */ - @Test(expected = IllegalCommandException.class) - public void testInvalidMove() throws Exception { - + @Test + void testInvalidMove() { DataverseRequest aRequest = new DataverseRequest(auth, httpRequest); - testEngine.submit( - new MoveDatasetCommand(aRequest, moved, root, false)); - fail(); + assertThrows(IllegalCommandException.class, + () -> testEngine.submit(new MoveDatasetCommand(aRequest, moved, root, false))); } /** @@ -301,14 +299,13 @@ public void testInvalidMove() throws Exception { * Ignoring after permissions change in 47fb045. Did that change make this * case untestable? Unclear. */ - @Ignore - @Test(expected = PermissionException.class) - public void testAuthenticatedUserWithNoRole() throws Exception { + @Disabled("Unstable test. Disabled since #5115 by @pdurbin. See commit 7a917177") + @Test + void testAuthenticatedUserWithNoRole() { DataverseRequest aRequest = new DataverseRequest(nobody, httpRequest); - testEngine.submit( - new MoveDatasetCommand(aRequest, moved, childA, null)); - fail(); + assertThrows(IllegalCommandException.class, + () -> testEngine.submit(new MoveDatasetCommand(aRequest, moved, childA, null))); } /** @@ -317,25 +314,23 @@ public void testAuthenticatedUserWithNoRole() throws Exception { * * @throws java.lang.Exception */ - @Test(expected = PermissionException.class) - public void testNotAuthenticatedUser() throws Exception { + @Test + void testNotAuthenticatedUser() { DataverseRequest aRequest = new DataverseRequest(GuestUser.get(), httpRequest); - testEngine.submit( - new MoveDatasetCommand(aRequest, moved, root, null)); - fail(); + assertThrows(PermissionException.class, + () -> testEngine.submit(new MoveDatasetCommand(aRequest, moved, root, null))); } /** * Moving published DS to unpublished DV * @throws IllegalCommandException */ - @Test(expected = IllegalCommandException.class) - public void testInvalidMovePublishedToUnpublished() throws Exception { + @Test + void testInvalidMovePublishedToUnpublished() { DataverseRequest aRequest = new DataverseRequest(auth, httpRequest); - testEngine.submit( - new MoveDatasetCommand(aRequest, moved, childDraft, null)); - fail(); + assertThrows(IllegalCommandException.class, + () -> testEngine.submit(new MoveDatasetCommand(aRequest, moved, childDraft, null))); } diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDataverseCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDataverseCommandTest.java index 3725cc942e5..3c3188da830 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDataverseCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/MoveDataverseCommandTest.java @@ -302,43 +302,39 @@ public void testValidMove() throws Exception { /** * Moving ChildA to its child (illegal). */ - @Test( expected=IllegalCommandException.class ) - public void testInvalidMove() throws Exception { + @Test + void testInvalidMove() { System.out.println("testInvalidMove"); DataverseRequest aRequest = new DataverseRequest(auth, httpRequest); - testEngine.submit( - new MoveDataverseCommand(aRequest, childA, grandchildAA, null)); - fail(); + assertThrows(IllegalCommandException.class, + () -> testEngine.submit(new MoveDataverseCommand(aRequest, childA, grandchildAA, null))); } /** * Calling API as a non super user (illegal). */ - @Test(expected = PermissionException.class) - public void testNotSuperUser() throws Exception { + @Test + void testNotSuperUser() { System.out.println("testNotSuperUser"); DataverseRequest aRequest = new DataverseRequest(nobody, httpRequest); - testEngine.submit( - new MoveDataverseCommand(aRequest, childB, childA, null)); - fail(); + assertThrows(PermissionException.class, + () -> testEngine.submit(new MoveDataverseCommand(aRequest, childB, childA, null))); } - @Test( expected=IllegalCommandException.class ) - public void testMoveIntoSelf() throws Exception { + @Test + void testMoveIntoSelf() { System.out.println("testMoveIntoSelf"); DataverseRequest aRequest = new DataverseRequest(auth, httpRequest); - testEngine.submit( - new MoveDataverseCommand(aRequest, childB, childB, null)); - fail(); + assertThrows(IllegalCommandException.class, + () -> testEngine.submit(new MoveDataverseCommand(aRequest, childB, childB, null))); } - @Test( expected=IllegalCommandException.class ) - public void testMoveIntoParent() throws Exception { + @Test + void testMoveIntoParent() { System.out.println("testMoveIntoParent"); DataverseRequest aRequest = new DataverseRequest(auth, httpRequest); - testEngine.submit( - new MoveDataverseCommand(aRequest, grandchildAA, childA, null)); - fail(); + assertThrows(IllegalCommandException.class, + () -> testEngine.submit(new MoveDataverseCommand(aRequest, grandchildAA, childA, null))); } @Test @@ -355,13 +351,12 @@ public void testKeepGuestbook() throws Exception { assertEquals( root, childC.getOwner() ); } - @Test(expected = IllegalCommandException.class) - public void testRemoveGuestbookWithoutForce() throws Exception { + @Test + void testRemoveGuestbookWithoutForce() { System.out.println("testRemoveGuestbookWithoutForce"); DataverseRequest aRequest = new DataverseRequest(auth, httpRequest); - testEngine.submit( - new MoveDataverseCommand(aRequest, grandchildCC, root, null)); - fail(); + assertThrows(IllegalCommandException.class, + () -> testEngine.submit(new MoveDataverseCommand(aRequest, grandchildCC, root, null))); } @Test @@ -393,13 +388,12 @@ public void testKeepTemplate() throws Exception { } - @Test(expected = IllegalCommandException.class) - public void testRemoveTemplateWithoutForce() throws Exception { + @Test + void testRemoveTemplateWithoutForce() { System.out.println("testRemoveTemplateWithoutForce"); DataverseRequest aRequest = new DataverseRequest(auth, httpRequest); - testEngine.submit( - new MoveDataverseCommand(aRequest, grandchildDD, root, null)); - fail(); + assertThrows(IllegalCommandException.class, + () -> testEngine.submit(new MoveDataverseCommand(aRequest, grandchildDD, root, null))); } @Test @@ -430,13 +424,12 @@ public void testKeepMetadataBlock() throws Exception { assertEquals( root, childE.getOwner() ); } - @Test(expected = IllegalCommandException.class) - public void testRemoveMetadataBlockWithoutForce() throws Exception { + @Test + void testRemoveMetadataBlockWithoutForce() { System.out.println("testRemoveMetadataBlockWithoutForce"); DataverseRequest aRequest = new DataverseRequest(auth, httpRequest); - testEngine.submit( - new MoveDataverseCommand(aRequest, grandchildEE, root, null)); - fail(); + assertThrows(IllegalCommandException.class, + () -> testEngine.submit(new MoveDataverseCommand(aRequest, grandchildEE, root, null))); } @Test diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ReturnDatasetToAuthorCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ReturnDatasetToAuthorCommandTest.java index e7565c1ea64..23cc4547bc4 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ReturnDatasetToAuthorCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/ReturnDatasetToAuthorCommandTest.java @@ -141,9 +141,10 @@ public List getUsersWithPermissionOn(Permission permission, D throw new IllegalCommandException("You must enter a reason for returning a dataset to its author.", this); } */ - @Test(expected=IllegalArgumentException.class) - public void testDatasetNull() throws CommandException { - new ReturnDatasetToAuthorCommand(dataverseRequest, null, ""); + @Test + void testDatasetNull() { + assertThrows(IllegalArgumentException.class, + () -> new ReturnDatasetToAuthorCommand(dataverseRequest, null, "")); } @Test diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/SubmitDatasetForReviewCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/SubmitDatasetForReviewCommandTest.java index 0934f965b4b..700ba332247 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/SubmitDatasetForReviewCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/SubmitDatasetForReviewCommandTest.java @@ -136,9 +136,10 @@ public List getUsersWithPermissionOn(Permission permission, D ); } - @Test( expected=IllegalArgumentException.class ) - public void testDatasetNull() { - new SubmitDatasetForReviewCommand(dataverseRequest, null); + @Test + void testDatasetNull() { + assertThrows(IllegalArgumentException.class, + () -> new SubmitDatasetForReviewCommand(dataverseRequest, null)); } @Test diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetsCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetsCommandTest.java index 4fd80e931a2..51892f20df3 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetsCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/UpdateMetadataBlockFacetsCommandTest.java @@ -33,14 +33,14 @@ public void beforeEachTest() { dataverse = Mockito.mock(Dataverse.class); } - @Test(expected = IllegalCommandException.class) - public void should_throw_IllegalCommandException_when_dataverse_is_not_metadata_facet_root() throws CommandException { + @Test + void should_throw_IllegalCommandException_when_dataverse_is_not_metadata_facet_root() { Mockito.when(dataverse.isMetadataBlockFacetRoot()).thenReturn(false); UpdateMetadataBlockFacetsCommand target = new UpdateMetadataBlockFacetsCommand(dataverseRequest, dataverse, Collections.emptyList()); CommandContext context = Mockito.mock(CommandContext.class, Mockito.RETURNS_DEEP_STUBS); - target.execute(context); + Assertions.assertThrows(IllegalCommandException.class, () -> target.execute(context)); } @Test diff --git a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/DataReaderTest.java b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/DataReaderTest.java index 940d625115c..a181f73c058 100644 --- a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/DataReaderTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/DataReaderTest.java @@ -39,12 +39,12 @@ public void testReadUShort() throws IOException { } // This should throw until we figure out what to do with uLongs that are large - @Test(expected = IOException.class) - public void testReadULong() throws IOException { + @Test + void testReadULong() throws IOException { byte[] bytes = {-1,-1,-1,-1,-1,-1,-1,-1,}; BufferedInputStream stream = new BufferedInputStream(new ByteArrayInputStream(bytes)); DataReader reader = new DataReader(stream); reader.setLSF(true); - assertEquals(-1, reader.readULong()); + assertThrows(IOException.class, () -> reader.readULong()); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/NewDTAFileReaderTest.java b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/NewDTAFileReaderTest.java index 36e667336c8..4a1acdfa607 100644 --- a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/NewDTAFileReaderTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/NewDTAFileReaderTest.java @@ -74,10 +74,10 @@ public void testDates() throws IOException { assertEquals(expected, FileUtils.readFileToString(result.getTabDelimitedFile())); } - @Test(expected = IOException.class) - public void testNull() throws IOException { + @Test + void testNull() { instance = new NewDTAFileReader(null, 117); - TabularDataIngest result = instance.read(null, new File("")); + assertThrows(IOException.class, () -> instance.read(null, new File(""))); } // TODO: Can we create a small file to check into the code base that exercises the value-label names non-zero offset issue? diff --git a/src/test/java/edu/harvard/iq/dataverse/locality/StorageSiteUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/locality/StorageSiteUtilTest.java index 6bc7aaad186..b2f70ba2675 100644 --- a/src/test/java/edu/harvard/iq/dataverse/locality/StorageSiteUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/locality/StorageSiteUtilTest.java @@ -25,44 +25,47 @@ public void testParse() throws Exception { System.out.println("output: " + output); } - @Test(expected = IllegalArgumentException.class) - public void testMissingHostname() throws Exception { + @Test + void testMissingHostname() { JsonObjectBuilder job = Json.createObjectBuilder(); job.add(StorageSite.NAME, "myName"); job.add(StorageSite.PRIMARY_STORAGE, true); job.add(StorageSite.TRANSFER_PROTOCOLS, "rsync"); - StorageSiteUtil.parse(job.build()); + JsonObject sut = job.build(); + assertThrows(IllegalArgumentException.class, () -> StorageSiteUtil.parse(sut)); } - @Test(expected = IllegalArgumentException.class) - public void testBadProtocol() throws Exception { + @Test + void testBadProtocol() { JsonObjectBuilder job = Json.createObjectBuilder(); job.add(StorageSite.HOSTNAME, "myHostname"); job.add(StorageSite.NAME, "myName"); job.add(StorageSite.PRIMARY_STORAGE, true); job.add(StorageSite.TRANSFER_PROTOCOLS, "junk"); - StorageSiteUtil.parse(job.build()); + JsonObject sut = job.build(); + assertThrows(IllegalArgumentException.class, () -> StorageSiteUtil.parse(sut)); } - @Test(expected = IllegalArgumentException.class) - public void testNonBoolean() throws Exception { + @Test + void testNonBoolean() { JsonObjectBuilder job = Json.createObjectBuilder(); job.add(StorageSite.HOSTNAME, "myHostname"); job.add(StorageSite.NAME, "myName"); job.add(StorageSite.PRIMARY_STORAGE, "not a boolean"); job.add(StorageSite.TRANSFER_PROTOCOLS, "rsync"); - StorageSiteUtil.parse(job.build()); + JsonObject sut = job.build(); + assertThrows(IllegalArgumentException.class, () -> StorageSiteUtil.parse(sut)); } - @Test(expected = Exception.class) - public void testSecondPrimaryNotAllowed() throws Exception { + @Test + void testSecondPrimaryNotAllowed() { StorageSite newStorageSite = new StorageSite(); newStorageSite.setPrimaryStorage(true); List exitingSites = new ArrayList<>(); StorageSite existingSite1 = new StorageSite(); existingSite1.setPrimaryStorage(true); exitingSites.add(existingSite1); - StorageSiteUtil.ensureOnlyOnePrimary(newStorageSite, exitingSites); + assertThrows(Exception.class, () -> StorageSiteUtil.ensureOnlyOnePrimary(newStorageSite, exitingSites)); } @Test diff --git a/src/test/java/edu/harvard/iq/dataverse/metrics/MetricsUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/metrics/MetricsUtilTest.java index 827e450eff7..bb42bda68ea 100644 --- a/src/test/java/edu/harvard/iq/dataverse/metrics/MetricsUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/metrics/MetricsUtilTest.java @@ -144,23 +144,23 @@ public void testDataversesBySubjectToJson() { } @Test - public void testSanitizeHappyPath() throws Exception { + void testSanitizeHappyPath() { assertEquals("2018-04", MetricsUtil.sanitizeYearMonthUserInput("2018-04")); } - @Test(expected = Exception.class) - public void testSanitizeJunk() throws Exception { - MetricsUtil.sanitizeYearMonthUserInput("junk"); + @Test + void testSanitizeJunk() { + assertThrows(Exception.class, () -> MetricsUtil.sanitizeYearMonthUserInput("junk")); } - @Test(expected = Exception.class) - public void testSanitizeFullIso() throws Exception { - MetricsUtil.sanitizeYearMonthUserInput("2018-01-01"); + @Test + void testSanitizeFullIso() { + assertThrows(Exception.class, () -> MetricsUtil.sanitizeYearMonthUserInput("2018-01-01")); } - @Test(expected = Exception.class) - public void testSanitizeYearMonthUserInputIsAfterCurrentDate() throws Exception { - MetricsUtil.sanitizeYearMonthUserInput("2099-01"); + @Test + void testSanitizeYearMonthUserInputIsAfterCurrentDate() { + assertThrows(Exception.class, () -> MetricsUtil.sanitizeYearMonthUserInput("2099-01")); } @Test diff --git a/src/test/java/edu/harvard/iq/dataverse/util/BundleUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/util/BundleUtilTest.java index c7dc13fcaff..8f788154a93 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/BundleUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/BundleUtilTest.java @@ -81,14 +81,14 @@ public void testStringFromPropertyFile() { } //To assure that the MissingResourceException bubble up from this call - @Test(expected = MissingResourceException.class) - public void testStringFromPropertyFileException() { - BundleUtil.getStringFromPropertyFile("FAKE","MimeTypeFacets"); + @Test + void testStringFromPropertyFileException() { + assertThrows(MissingResourceException.class, () -> BundleUtil.getStringFromPropertyFile("FAKE","MimeTypeFacets")); } //To assure MissingResourceException is caught when calling normal bundle calls @Test - public void testNoErrorNonExistentStringBundle() { - BundleUtil.getStringFromBundle("FAKE", null, BundleUtil.getResourceBundle("MimeTypeFacets")); + void testNoErrorNonExistentStringBundle() { + assertDoesNotThrow(() -> BundleUtil.getStringFromBundle("FAKE", null, BundleUtil.getResourceBundle("MimeTypeFacets"))); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/util/LruCacheTest.java b/src/test/java/edu/harvard/iq/dataverse/util/LruCacheTest.java index 77aa09c3367..122cf39e2c3 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/LruCacheTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/LruCacheTest.java @@ -66,9 +66,9 @@ public void testLRU() { } - @Test(expected = IllegalArgumentException.class) - public void testSetMaxSizeWithException() { - sut.setMaxSize(0l); + @Test + void testSetMaxSizeWithException() { + assertThrows(IllegalArgumentException.class, () -> sut.setMaxSize(0l)); } @Test diff --git a/src/test/java/edu/harvard/iq/dataverse/util/json/JsonParserTest.java b/src/test/java/edu/harvard/iq/dataverse/util/json/JsonParserTest.java index c1f9e398125..6576c1cfd84 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/json/JsonParserTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/json/JsonParserTest.java @@ -185,8 +185,8 @@ public void testControlledVocalRepeatsRoundTrip() throws JsonParseException { } - @Test(expected=JsonParseException.class) - public void testChildValidation() throws JsonParseException { + @Test + void testChildValidation() { // This Json String is a compound field that contains the wrong // fieldType as a child ("description" is not a child of "coordinate"). // It should throw a JsonParseException when it encounters the invalid child. @@ -211,8 +211,8 @@ public void testChildValidation() throws JsonParseException { JsonReader jsonReader = Json.createReader(new StringReader(text)); JsonObject obj = jsonReader.readObject(); - sut.parseField(obj); - } + assertThrows(JsonParseException.class, () -> sut.parseField(obj)); + } @Test @@ -334,12 +334,12 @@ public void testParseMinimalDataverse() throws JsonParseException { * @throws JsonParseException if all goes well - this is expected. * @throws IOException when test file IO goes wrong - this is bad. */ - @Test(expected = JsonParseException.class) - public void testParseNoAliasDataverse() throws JsonParseException, IOException { + @Test + void testParseNoAliasDataverse() throws IOException { JsonObject dvJson; try (InputStream jsonFile = ClassLoader.getSystemResourceAsStream("json/no-alias-dataverse.json")) { dvJson = Json.createReader(jsonFile).readObject(); - Dataverse actual = sut.parseDataverse(dvJson); + assertThrows(JsonParseException.class, () -> sut.parseDataverse(dvJson)); } } @@ -348,12 +348,12 @@ public void testParseNoAliasDataverse() throws JsonParseException, IOException { * @throws JsonParseException if all goes well - this is expected. * @throws IOException when test file IO goes wrong - this is bad. */ - @Test(expected = JsonParseException.class) - public void testParseNoNameDataverse() throws JsonParseException, IOException { + @Test + void testParseNoNameDataverse() throws IOException { JsonObject dvJson; try (InputStream jsonFile = ClassLoader.getSystemResourceAsStream("json/no-name-dataverse.json")) { dvJson = Json.createReader(jsonFile).readObject(); - Dataverse actual = sut.parseDataverse(dvJson); + assertThrows(JsonParseException.class, () -> sut.parseDataverse(dvJson)); } } @@ -363,12 +363,12 @@ public void testParseNoNameDataverse() throws JsonParseException, IOException { * @throws JsonParseException if all goes well - this is expected. * @throws IOException when test file IO goes wrong - this is bad. */ - @Test(expected = JsonParseException.class) - public void testParseNoContactEmailsDataverse() throws JsonParseException, IOException { + @Test + void testParseNoContactEmailsDataverse() throws IOException { JsonObject dvJson; try (InputStream jsonFile = ClassLoader.getSystemResourceAsStream("json/no-contacts-dataverse.json")) { dvJson = Json.createReader(jsonFile).readObject(); - Dataverse actual = sut.parseDataverse(dvJson); + assertThrows(JsonParseException.class, () -> sut.parseDataverse(dvJson)); } } @@ -421,16 +421,14 @@ public void testDateTimeRoundtrip() throws ParseException { * Expect an exception when the dataset JSON is empty. * @throws JsonParseException when the test is broken */ - @Test(expected = NullPointerException.class) - public void testParseEmptyDataset() throws JsonParseException { + @Test + void testParseEmptyDataset() throws JsonParseException { JsonObject dsJson; try (InputStream jsonFile = ClassLoader.getSystemResourceAsStream("json/empty-dataset.json")) { InputStreamReader reader = new InputStreamReader(jsonFile, "UTF-8"); dsJson = Json.createReader(reader).readObject(); System.out.println(dsJson != null); - Dataset actual = sut.parseDataset(dsJson); - assertEquals("10.5072", actual.getAuthority()); - assertEquals("doi", actual.getProtocol()); + assertThrows(NullPointerException.class, () -> sut.parseDataset(dsJson)); } catch (IOException ioe) { throw new JsonParseException("Couldn't read test file", ioe); } @@ -444,13 +442,13 @@ public void testParseEmptyDataset() throws JsonParseException { * @throws IOException when test file IO goes wrong - this is bad. */ @Test - public void testParseOvercompleteDatasetVersion() throws JsonParseException, IOException { + void testParseOvercompleteDatasetVersion() throws IOException { JsonObject dsJson; try (InputStream jsonFile = ClassLoader.getSystemResourceAsStream("json/complete-dataset-version.json")) { InputStreamReader reader = new InputStreamReader(jsonFile, "UTF-8"); dsJson = Json.createReader(reader).readObject(); - System.out.println(dsJson != null); - DatasetVersion actual = sut.parseDatasetVersion(dsJson); + Assumptions.assumeTrue(dsJson != null); + assertDoesNotThrow(() -> sut.parseDatasetVersion(dsJson)); } } @@ -567,31 +565,31 @@ public void testValidRegexMailDomainGroup() throws JsonParseException { assertEquals(test.hashCode(), parsed.hashCode()); } - @Test(expected = JsonParseException.class) - public void testMailDomainGroupMissingName() throws JsonParseException { + @Test + void testMailDomainGroupMissingName() { // given String noname = "{ \"id\": 1, \"alias\": \"test\", \"domains\": [] }"; JsonObject obj = Json.createReader(new StringReader(noname)).readObject(); // when && then - MailDomainGroup parsed = new JsonParser().parseMailDomainGroup(obj); + assertThrows(JsonParseException.class, () -> new JsonParser().parseMailDomainGroup(obj)); } - @Test(expected = JsonParseException.class) - public void testMailDomainGroupMissingDomains() throws JsonParseException { + @Test + void testMailDomainGroupMissingDomains() { // given String noname = "{ \"name\": \"test\", \"alias\": \"test\" }"; JsonObject obj = Json.createReader(new StringReader(noname)).readObject(); // when && then - MailDomainGroup parsed = new JsonParser().parseMailDomainGroup(obj); + assertThrows(JsonParseException.class, () -> new JsonParser().parseMailDomainGroup(obj)); } - @Test(expected = JsonParseException.class) - public void testMailDomainGroupNotEnabledRegexDomains() throws JsonParseException { + @Test + void testMailDomainGroupNotEnabledRegexDomains() { // given String regexNotEnabled = "{ \"id\": 1, \"alias\": \"test\", \"domains\": [\"^foobar\\\\.com\"] }"; JsonObject obj = Json.createReader(new StringReader(regexNotEnabled)).readObject(); // when && then - MailDomainGroup parsed = new JsonParser().parseMailDomainGroup(obj); + assertThrows(JsonParseException.class, () -> new JsonParser().parseMailDomainGroup(obj)); } @Test From 6ddc8dbc5d7f480daec4892d23839f97ffbe8ecc Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Fri, 18 Aug 2023 17:42:56 +0200 Subject: [PATCH 07/17] build(test): switch to static imports for assertions everywhere and simplify where reasonable #9782 --- .../iq/dataverse/api/AuxiliaryFilesIT.java | 10 +++--- .../harvard/iq/dataverse/api/DatasetsIT.java | 4 +-- .../iq/dataverse/api/DownloadFilesIT.java | 32 +++++++++---------- .../edu/harvard/iq/dataverse/api/FilesIT.java | 4 +-- .../iq/dataverse/api/InReviewWorkflowIT.java | 6 ++-- .../edu/harvard/iq/dataverse/api/MoveIT.java | 8 ++--- .../iq/dataverse/api/dto/FieldDTOTest.java | 12 +++---- .../imports/ImportGenericServiceBeanTest.java | 18 +++++------ .../impl/DRSSubmitToArchiveCommandTest.java | 2 +- .../plugins/dta/NewDTAFileReaderTest.java | 4 +-- .../makedatacount/MakeDataCountUtilTest.java | 2 +- .../util/json/DatasetVersionDTOTest.java | 2 +- 12 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/test/java/edu/harvard/iq/dataverse/api/AuxiliaryFilesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/AuxiliaryFilesIT.java index 506a1186194..3c77be56810 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/AuxiliaryFilesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/AuxiliaryFilesIT.java @@ -243,29 +243,29 @@ public void testUploadAuxFiles() throws IOException { // Download JSON aux file. Response downloadAuxFileJson = UtilIT.downloadAuxFile(fileId, formatTagJson, formatVersionJson, apiToken); downloadAuxFileJson.then().assertThat().statusCode(OK.getStatusCode()); - Assert.assertEquals("attachment; filename=\"data.tab.dpJson_0.1.json\"", downloadAuxFileJson.header("Content-disposition")); + assertEquals("attachment; filename=\"data.tab.dpJson_0.1.json\"", downloadAuxFileJson.header("Content-disposition")); // Download XML aux file. Response downloadAuxFileXml = UtilIT.downloadAuxFile(fileId, formatTagXml, formatVersionXml, apiToken); downloadAuxFileXml.then().assertThat().statusCode(OK.getStatusCode()); - Assert.assertEquals("attachment; filename=\"data.tab.dpXml_0.1.xml\"", downloadAuxFileXml.header("Content-disposition")); + assertEquals("attachment; filename=\"data.tab.dpXml_0.1.xml\"", downloadAuxFileXml.header("Content-disposition")); // Download PDF aux file. Response downloadAuxFilePdf = UtilIT.downloadAuxFile(fileId, formatTagPdf, formatVersionPdf, apiToken); downloadAuxFilePdf.then().assertThat().statusCode(OK.getStatusCode()); - Assert.assertEquals("attachment; filename=\"data.tab.dpPdf_0.1.pdf\"", downloadAuxFilePdf.header("Content-disposition")); + assertEquals("attachment; filename=\"data.tab.dpPdf_0.1.pdf\"", downloadAuxFilePdf.header("Content-disposition")); // Download Markdown aux file. Response downloadAuxFileMd = UtilIT.downloadAuxFile(fileId, formatTagMd, formatVersionMd, apiToken); downloadAuxFileMd.then().assertThat().statusCode(OK.getStatusCode()); // No file extenstion here because Tika's getDefaultMimeTypes doesn't include "text/markdown". // Note: browsers seem to add ".bin" ("myfile.bin") rather than no extension ("myfile"). - Assert.assertEquals("attachment; filename=\"data.tab.README_0.1\"", downloadAuxFileMd.header("Content-disposition")); + assertEquals("attachment; filename=\"data.tab.README_0.1\"", downloadAuxFileMd.header("Content-disposition")); // Download Markdown aux file with no MIME type given Response downloadAuxFileNoMime1 = UtilIT.downloadAuxFile(fileId, formatTagNoMimeType1, formatVersionNoMimeType1, apiToken); downloadAuxFileNoMime1.then().assertThat().statusCode(OK.getStatusCode()); - Assert.assertEquals("attachment; filename=\"data.tab.noMimeType1_0.1.txt\"", downloadAuxFileNoMime1.header("Content-disposition")); + assertEquals("attachment; filename=\"data.tab.noMimeType1_0.1.txt\"", downloadAuxFileNoMime1.header("Content-disposition")); Response createUserNoPrivs = UtilIT.createRandomUser(); createUserNoPrivs.then().assertThat().statusCode(OK.getStatusCode()); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java index 44965c27a3d..990bac7cfe0 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java @@ -2407,7 +2407,7 @@ public void testRestrictFileExportDdi() throws IOException { // Here we are asserting that dataDscr is empty. TODO: Do this in REST Assured. String dataDscrForGuest = XmlPath.from(exportByGuest.asString()).getString("codeBook.dataDscr"); - Assert.assertEquals("", dataDscrForGuest); + assertEquals("", dataDscrForGuest); // Author export (has access) Response exportByAuthor = UtilIT.exportDataset(datasetPid, "ddi", authorApiToken); @@ -2418,7 +2418,7 @@ public void testRestrictFileExportDdi() throws IOException { // Here we are asserting that dataDscr is empty. TODO: Do this in REST Assured. String dataDscrForAuthor = XmlPath.from(exportByAuthor.asString()).getString("codeBook.dataDscr"); - Assert.assertEquals("", dataDscrForAuthor); + assertEquals("", dataDscrForAuthor); // Now we are testing file-level retrieval. // The author has access to a restricted file and gets all the metadata. diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DownloadFilesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DownloadFilesIT.java index 7fcf7489d1d..0ce93da2666 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DownloadFilesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DownloadFilesIT.java @@ -90,7 +90,7 @@ public void downloadAllFilesByVersion() throws IOException { // Note that a MANIFEST.TXT file is added. HashSet expectedFiles1 = new HashSet<>(Arrays.asList("MANIFEST.TXT", "README.md", "CONTRIBUTING.md")); - Assert.assertEquals(expectedFiles1, filenamesFound1); + assertEquals(expectedFiles1, filenamesFound1); // A guest user can't download unpublished files. // (a guest user cannot even see that the draft version actually exists; @@ -130,7 +130,7 @@ public void downloadAllFilesByVersion() throws IOException { // The creator gets the draft version with an extra file. HashSet expectedFiles2 = new HashSet<>(Arrays.asList("LICENSE.md", "MANIFEST.TXT", "README.md", "CONTRIBUTING.md")); - Assert.assertEquals(expectedFiles2, filenamesFound2); + assertEquals(expectedFiles2, filenamesFound2); Response downloadFiles5 = UtilIT.downloadFiles(datasetPid, null); downloadFiles5.then().assertThat() @@ -140,7 +140,7 @@ public void downloadAllFilesByVersion() throws IOException { // A guest user gets the 1.0 version with only 3 files. HashSet expectedFiles3 = new HashSet<>(Arrays.asList("MANIFEST.TXT", "README.md", "CONTRIBUTING.md")); - Assert.assertEquals(expectedFiles3, filenamesFound3); + assertEquals(expectedFiles3, filenamesFound3); // Publishing version 2.0 UtilIT.publishDatasetViaNativeApi(datasetPid, "major", apiToken) @@ -154,7 +154,7 @@ public void downloadAllFilesByVersion() throws IOException { // By not specifying a version, the creator gets the latest version. In this case, 2.0 (published) with 4 files. HashSet expectedFiles4 = new HashSet<>(Arrays.asList("LICENSE.md", "MANIFEST.TXT", "README.md", "CONTRIBUTING.md")); - Assert.assertEquals(expectedFiles4, filenamesFound4); + assertEquals(expectedFiles4, filenamesFound4); String datasetVersion = "1.0"; Response downloadFiles7 = UtilIT.downloadFiles(datasetPid, datasetVersion, apiToken); @@ -165,7 +165,7 @@ public void downloadAllFilesByVersion() throws IOException { // Creator specifies the 1.0 version and gets the expected 3 files. HashSet expectedFiles5 = new HashSet<>(Arrays.asList("MANIFEST.TXT", "README.md", "CONTRIBUTING.md")); - Assert.assertEquals(expectedFiles5, filenamesFound5); + assertEquals(expectedFiles5, filenamesFound5); // Add Code of Conduct file Path pathtoCocFile = Paths.get(Files.createTempDirectory(null) + File.separator + "CODE_OF_CONDUCT.md"); @@ -186,7 +186,7 @@ public void downloadAllFilesByVersion() throws IOException { // If the creator doesn't specify a version, they get the latest draft with 5 files. HashSet expectedFiles6 = new HashSet<>(Arrays.asList("CODE_OF_CONDUCT.md", "LICENSE.md", "MANIFEST.TXT", "README.md", "CONTRIBUTING.md")); - Assert.assertEquals(expectedFiles6, filenamesFound6); + assertEquals(expectedFiles6, filenamesFound6); String datasetVersionLatestPublished = ":latest-published"; Response downloadFiles9 = UtilIT.downloadFiles(datasetPid, datasetVersionLatestPublished, apiToken); @@ -197,7 +197,7 @@ public void downloadAllFilesByVersion() throws IOException { // The contributor requested "latest published" and got version 3 with 4 files. HashSet expectedFiles7 = new HashSet<>(Arrays.asList("LICENSE.md", "MANIFEST.TXT", "README.md", "CONTRIBUTING.md")); - Assert.assertEquals(expectedFiles7, filenamesFound7); + assertEquals(expectedFiles7, filenamesFound7); // Guests cannot download draft versions. String datasetVersionDraft = ":draft"; @@ -266,14 +266,14 @@ public void downloadAllFilesRestricted() throws IOException { .statusCode(OK.getStatusCode()); // The creator can download a restricted file from a draft. - Assert.assertEquals(new HashSet<>(Arrays.asList("secrets.md", "MANIFEST.TXT")), gatherFilenames(downloadFiles1.getBody().asInputStream())); + assertEquals(new HashSet<>(Arrays.asList("secrets.md", "MANIFEST.TXT")), gatherFilenames(downloadFiles1.getBody().asInputStream())); Response downloadFiles2 = UtilIT.downloadFiles(datasetPid, apiToken); downloadFiles2.then().assertThat() .statusCode(OK.getStatusCode()); // The creator can download a restricted file and an unrestricted file from a draft. - Assert.assertEquals(new HashSet<>(Arrays.asList("secrets.md", "MANIFEST.TXT")), gatherFilenames(downloadFiles2.getBody().asInputStream())); + assertEquals(new HashSet<>(Arrays.asList("secrets.md", "MANIFEST.TXT")), gatherFilenames(downloadFiles2.getBody().asInputStream())); UtilIT.publishDataverseViaNativeApi(dataverseAlias, apiToken) .then().assertThat().statusCode(OK.getStatusCode()); @@ -307,14 +307,14 @@ public void downloadAllFilesRestricted() throws IOException { .statusCode(OK.getStatusCode()); // The guest can only get the unrestricted file (and the manifest). - Assert.assertEquals(new HashSet<>(Arrays.asList("README.md", "MANIFEST.TXT")), gatherFilenames(downloadFiles4.getBody().asInputStream())); + assertEquals(new HashSet<>(Arrays.asList("README.md", "MANIFEST.TXT")), gatherFilenames(downloadFiles4.getBody().asInputStream())); Response downloadFiles5 = UtilIT.downloadFiles(datasetPid, apiToken); downloadFiles5.then().assertThat() .statusCode(OK.getStatusCode()); // The creator can download both files (and the manifest). - Assert.assertEquals(new HashSet<>(Arrays.asList("secrets.md", "README.md", "MANIFEST.TXT")), gatherFilenames(downloadFiles5.getBody().asInputStream())); + assertEquals(new HashSet<>(Arrays.asList("secrets.md", "README.md", "MANIFEST.TXT")), gatherFilenames(downloadFiles5.getBody().asInputStream())); } @@ -363,14 +363,14 @@ public void downloadAllFilesTabular() throws IOException { .statusCode(OK.getStatusCode()); // By default we get the archival version (.tab). - Assert.assertEquals(new HashSet<>(Arrays.asList("50by1000.tab", "MANIFEST.TXT")), gatherFilenames(downloadFiles1.getBody().asInputStream())); + assertEquals(new HashSet<>(Arrays.asList("50by1000.tab", "MANIFEST.TXT")), gatherFilenames(downloadFiles1.getBody().asInputStream())); Response downloadFiles2 = UtilIT.downloadFiles(datasetPid, UtilIT.DownloadFormat.original, apiToken); downloadFiles2.then().assertThat() .statusCode(OK.getStatusCode()); // By passing format=original we get the original version, Stata (.dta) in this case. - Assert.assertEquals(new HashSet<>(Arrays.asList("50by1000.dta", "MANIFEST.TXT")), gatherFilenames(downloadFiles2.getBody().asInputStream())); + assertEquals(new HashSet<>(Arrays.asList("50by1000.dta", "MANIFEST.TXT")), gatherFilenames(downloadFiles2.getBody().asInputStream())); } /** @@ -437,8 +437,8 @@ public void downloadFilenameUtf8() throws IOException { .statusCode(OK.getStatusCode()); Headers headers = downloadFile.getHeaders(); // In "MY READ–ME.md" below the space is %20 and the en-dash ("–") is "%E2%80%93" (e2 80 93 in hex). - Assert.assertEquals("attachment; filename=\"MY%20READ%E2%80%93ME.md\"", headers.getValue("Content-disposition")); - Assert.assertEquals("text/markdown; name=\"MY%20READ%E2%80%93ME.md\";charset=UTF-8", headers.getValue("Content-Type")); + assertEquals("attachment; filename=\"MY%20READ%E2%80%93ME.md\"", headers.getValue("Content-disposition")); + assertEquals("text/markdown; name=\"MY%20READ%E2%80%93ME.md\";charset=UTF-8", headers.getValue("Content-Type")); // Download all files as a zip and assert "MY READ–ME.md" has an en-dash. Response downloadFiles = UtilIT.downloadFiles(datasetPid, apiToken); @@ -450,7 +450,7 @@ public void downloadFilenameUtf8() throws IOException { // Note that a MANIFEST.TXT file is added. // "MY READ–ME.md" (with an en-dash) is correctly extracted from the downloaded zip HashSet expectedFiles = new HashSet<>(Arrays.asList("MANIFEST.TXT", "MY READ–ME.md")); - Assert.assertEquals(expectedFiles, filenamesFound); + assertEquals(expectedFiles, filenamesFound); } private HashSet gatherFilenames(InputStream inputStream) throws IOException { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java index 3463e99412b..0e7ae69688d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java @@ -2092,8 +2092,8 @@ public void testFilePIDsBehavior() { fileInfoResponseString = fileInfoResponse.body().asString(); msg(fileInfoResponseString); - org.junit.Assert.assertEquals("The file was NOT supposed to be issued a PID", "", - JsonPath.from(fileInfoResponseString).getString("data.dataFile.persistentId")); + assertEquals("", JsonPath.from(fileInfoResponseString).getString("data.dataFile.persistentId"), + "The file was NOT supposed to be issued a PID"); } finally { UtilIT.deleteSetting(SettingsServiceBean.Key.FilePIDsEnabled); UtilIT.deleteSetting(SettingsServiceBean.Key.AllowEnablingFilePIDsPerCollection); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java b/src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java index f50743b582f..736aadd9931 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java @@ -168,7 +168,7 @@ public void testCuratorSendsCommentsToAuthor() throws InterruptedException { .statusCode(OK.getStatusCode()); String citation = XmlPath.from(atomEntry.body().asString()).getString("bibliographicCitation"); System.out.println("citation: " + citation); - Assert.assertTrue(citation.contains("A Better Title")); + assertTrue(citation.contains("A Better Title")); // The author tries to update the title while the dataset is in review via native. String pathToJsonFile = "doc/sphinx-guides/source/_static/api/dataset-update-metadata.json"; @@ -184,7 +184,7 @@ public void testCuratorSendsCommentsToAuthor() throws InterruptedException { String citationAuthorNative = XmlPath.from(atomEntryAuthorNative.body().asString()).getString("bibliographicCitation"); System.out.println("citation: " + citationAuthorNative); // The author was unable to change the title. - Assert.assertTrue(citationAuthorNative.contains("A Better Title")); + assertTrue(citationAuthorNative.contains("A Better Title")); // The author remembers she forgot to add a file and tries to upload it while // the dataset is in review via native API but this fails. @@ -271,7 +271,7 @@ public void testCuratorSendsCommentsToAuthor() throws InterruptedException { .statusCode(OK.getStatusCode()); String citationCuratorNative = XmlPath.from(atomEntryCuratorNative.body().asString()).getString("bibliographicCitation"); System.out.println("citation: " + citationCuratorNative); - Assert.assertTrue(citationCuratorNative.contains("newTitle")); + assertTrue(citationCuratorNative.contains("newTitle")); // END https://github.com/IQSS/dataverse/issues/4139 // TODO: test where curator neglecting to leave a comment. Should fail with "reason for return" required. diff --git a/src/test/java/edu/harvard/iq/dataverse/api/MoveIT.java b/src/test/java/edu/harvard/iq/dataverse/api/MoveIT.java index 229e7fa646d..5ef7c210bf5 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/MoveIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/MoveIT.java @@ -278,8 +278,8 @@ public void testMoveLinkedDataset() { .body("message", equalTo("Use the query parameter forceMove=true to complete the move. This dataset is linked to the new host dataverse or one of its parents. This move would remove the link to this dataset. ")); JsonObject linksBeforeData = Json.createReader(new StringReader(getLinksBefore.asString())).readObject(); - Assert.assertEquals("OK", linksBeforeData.getString("status")); - Assert.assertEquals(dataverse2Alias + " (id " + dataverse2Id + ")", linksBeforeData.getJsonObject("data").getJsonArray("dataverses that link to dataset id " + datasetId).getString(0)); + assertEquals("OK", linksBeforeData.getString("status")); + assertEquals(dataverse2Alias + " (id " + dataverse2Id + ")", linksBeforeData.getJsonObject("data").getJsonArray("dataverses that link to dataset id " + datasetId).getString(0)); boolean forceMove = true; Response forceMoveLinkedDataset = UtilIT.moveDataset(datasetId.toString(), dataverse2Alias, forceMove, superuserApiToken); @@ -307,8 +307,8 @@ public void testMoveLinkedDataset() { .statusCode(OK.getStatusCode()); JsonObject linksAfterData = Json.createReader(new StringReader(getLinksAfter.asString())).readObject(); - Assert.assertEquals("OK", linksAfterData.getString("status")); - Assert.assertEquals(0, linksAfterData.getJsonObject("data").getJsonArray("dataverses that link to dataset id " + datasetId).size()); + assertEquals("OK", linksAfterData.getString("status")); + assertEquals(0, linksAfterData.getJsonObject("data").getJsonArray("dataverses that link to dataset id " + datasetId).size()); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/dto/FieldDTOTest.java b/src/test/java/edu/harvard/iq/dataverse/api/dto/FieldDTOTest.java index 4f75669eb05..0202f11d469 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/dto/FieldDTOTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/dto/FieldDTOTest.java @@ -60,7 +60,7 @@ public void tearDown() { public void testSinglePrimitive() { FieldDTO affil = FieldDTO.createPrimitiveFieldDTO("authorAffiliation", "Top"); System.out.println(affil.getSinglePrimitive()); - Assert.assertEquals("Top", affil.getSinglePrimitive()); + assertEquals("Top", affil.getSinglePrimitive()); } @@ -78,10 +78,10 @@ public void testMultipleVocab() { value.add("EventList"); astroType.setMultipleVocab(value); - Assert.assertEquals(value, astroType.getMultipleVocab()); + assertEquals(value, astroType.getMultipleVocab()); String jsonStr = gson.toJson(astroType); FieldDTO astroType2 = gson.fromJson(jsonStr, FieldDTO.class); - Assert.assertEquals(astroType, astroType2); + assertEquals(astroType, astroType2); } @@ -116,7 +116,7 @@ public void testSetMultipleCompound() { compoundField.setTypeName("author"); compoundField.setMultipleCompound(authorList); - Assert.assertEquals(compoundField.getMultipleCompound(), authorList); + assertEquals(compoundField.getMultipleCompound(), authorList); } /** @@ -132,8 +132,8 @@ public void testSetSingleCompound() { FieldDTO compoundField = new FieldDTO(); compoundField.setSingleCompound(authorFields.toArray(new FieldDTO[]{})); - Set returned = compoundField.getSingleCompound(); - Assert.assertTrue(returned.equals(authorFields)); + Set returned = compoundField.getSingleCompound(); + assertEquals(returned, authorFields); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/imports/ImportGenericServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/api/imports/ImportGenericServiceBeanTest.java index 3e7d8407de5..44739f3f62a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/imports/ImportGenericServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/imports/ImportGenericServiceBeanTest.java @@ -17,18 +17,18 @@ public class ImportGenericServiceBeanTest { @Test public void testReassignIdentifierAsGlobalId() { // non-URL - Assert.assertEquals("doi:10.7910/DVN/TJCLKP", importGenericService.reassignIdentifierAsGlobalId("doi:10.7910/DVN/TJCLKP", new DatasetDTO())); - Assert.assertEquals("hdl:10.7910/DVN/TJCLKP", importGenericService.reassignIdentifierAsGlobalId("hdl:10.7910/DVN/TJCLKP", new DatasetDTO())); + assertEquals("doi:10.7910/DVN/TJCLKP", importGenericService.reassignIdentifierAsGlobalId("doi:10.7910/DVN/TJCLKP", new DatasetDTO())); + assertEquals("hdl:10.7910/DVN/TJCLKP", importGenericService.reassignIdentifierAsGlobalId("hdl:10.7910/DVN/TJCLKP", new DatasetDTO())); // HTTPS - Assert.assertEquals("doi:10.7910/DVN/TJCLKP", importGenericService.reassignIdentifierAsGlobalId("https://doi.org/10.7910/DVN/TJCLKP", new DatasetDTO())); - Assert.assertEquals("doi:10.7910/DVN/TJCLKP", importGenericService.reassignIdentifierAsGlobalId("https://dx.doi.org/10.7910/DVN/TJCLKP", new DatasetDTO())); - Assert.assertEquals("hdl:10.7910/DVN/TJCLKP", importGenericService.reassignIdentifierAsGlobalId("https://hdl.handle.net/10.7910/DVN/TJCLKP", new DatasetDTO())); + assertEquals("doi:10.7910/DVN/TJCLKP", importGenericService.reassignIdentifierAsGlobalId("https://doi.org/10.7910/DVN/TJCLKP", new DatasetDTO())); + assertEquals("doi:10.7910/DVN/TJCLKP", importGenericService.reassignIdentifierAsGlobalId("https://dx.doi.org/10.7910/DVN/TJCLKP", new DatasetDTO())); + assertEquals("hdl:10.7910/DVN/TJCLKP", importGenericService.reassignIdentifierAsGlobalId("https://hdl.handle.net/10.7910/DVN/TJCLKP", new DatasetDTO())); // HTTP (no S) - Assert.assertEquals("doi:10.7910/DVN/TJCLKP", importGenericService.reassignIdentifierAsGlobalId("http://doi.org/10.7910/DVN/TJCLKP", new DatasetDTO())); - Assert.assertEquals("doi:10.7910/DVN/TJCLKP", importGenericService.reassignIdentifierAsGlobalId("http://dx.doi.org/10.7910/DVN/TJCLKP", new DatasetDTO())); - Assert.assertEquals("hdl:10.7910/DVN/TJCLKP", importGenericService.reassignIdentifierAsGlobalId("http://hdl.handle.net/10.7910/DVN/TJCLKP", new DatasetDTO())); + assertEquals("doi:10.7910/DVN/TJCLKP", importGenericService.reassignIdentifierAsGlobalId("http://doi.org/10.7910/DVN/TJCLKP", new DatasetDTO())); + assertEquals("doi:10.7910/DVN/TJCLKP", importGenericService.reassignIdentifierAsGlobalId("http://dx.doi.org/10.7910/DVN/TJCLKP", new DatasetDTO())); + assertEquals("hdl:10.7910/DVN/TJCLKP", importGenericService.reassignIdentifierAsGlobalId("http://hdl.handle.net/10.7910/DVN/TJCLKP", new DatasetDTO())); // junk - Assert.assertEquals(null, importGenericService.reassignIdentifierAsGlobalId("junk", new DatasetDTO())); + assertNull(importGenericService.reassignIdentifierAsGlobalId("junk", new DatasetDTO())); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/DRSSubmitToArchiveCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/DRSSubmitToArchiveCommandTest.java index d91384557fb..70e65bfe34c 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/DRSSubmitToArchiveCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/DRSSubmitToArchiveCommandTest.java @@ -114,7 +114,7 @@ public void createJWT() throws CommandException { System.out.println(e.getClass() + e.getLocalizedMessage()); e.printStackTrace(); //Any exception is a failure, otherwise decoding worked. - Assert.fail(e.getLocalizedMessage()); + fail(e.getLocalizedMessage()); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/NewDTAFileReaderTest.java b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/NewDTAFileReaderTest.java index 4a1acdfa607..c963346b05e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/NewDTAFileReaderTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/dta/NewDTAFileReaderTest.java @@ -48,7 +48,7 @@ public void testStrl() throws IOException { String[] vars = {"make","price","mpg","rep78","trunk","gear_ratio","strls"}; String[] actualVars = table.getDataVariables().stream().map((var) -> var.getName()).toArray(String[]::new); - Assert.assertArrayEquals(vars, actualVars); + assertArrayEquals(vars, actualVars); String expected = "\"Buick LeSabre\" 5788 1.1111111111111111E21 100 32767 2.73 \"a\"\n" + "\"Buick Opel\" 4453 26.0 10 2.87 \"bb\"\n" + "\"Buick Regal\" 5189 20.0 3 16 2.93 \"ccc\"\n"; @@ -66,7 +66,7 @@ public void testDates() throws IOException { assertEquals(4, (long)table.getCaseQuantity()); String[] vars = {"Clock","Daily","Weekly","Monthly","Quarterly","BiAnnually","Annually"}; String[] actualVars = table.getDataVariables().stream().map((var) -> var.getName()).toArray(String[]::new); - Assert.assertArrayEquals(vars, actualVars); + assertArrayEquals(vars, actualVars); String expected = "2595-09-27 06:58:52.032 2018-06-20 2018-11-05 2018-06-01 2018-01-01 2018-01-01 2018\n" + "2595-09-27 06:58:52.032 2018-06-20 2018-11-05 2018-06-01 2018-04-01 2018-01-01 2018\n" + "2595-09-27 06:58:52.032 2018-06-20 2018-11-05 2018-06-01 2018-07-01 2018-07-01 2018\n" + diff --git a/src/test/java/edu/harvard/iq/dataverse/makedatacount/MakeDataCountUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/makedatacount/MakeDataCountUtilTest.java index 5a0ad3d8754..56e786714b6 100644 --- a/src/test/java/edu/harvard/iq/dataverse/makedatacount/MakeDataCountUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/makedatacount/MakeDataCountUtilTest.java @@ -31,7 +31,7 @@ public void testParseCitations() { try (FileReader reader = new FileReader("src/test/java/edu/harvard/iq/dataverse/makedatacount/citations-for-doi-10.7910-DVN-HQZOOB.json")) { report = Json.createReader(reader).readObject(); List datasetExternalCitations = MakeDataCountUtil.parseCitations(report); - Assert.assertEquals(2, datasetExternalCitations.size()); + assertEquals(2, datasetExternalCitations.size()); } catch (FileNotFoundException ex) { System.out.print("File not found: " + ex.getMessage()); } catch (IOException ex) { diff --git a/src/test/java/edu/harvard/iq/dataverse/util/json/DatasetVersionDTOTest.java b/src/test/java/edu/harvard/iq/dataverse/util/json/DatasetVersionDTOTest.java index 9ee2a7717dd..7dd5ad9da8d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/json/DatasetVersionDTOTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/json/DatasetVersionDTOTest.java @@ -89,7 +89,7 @@ public void testReadDataSet() { JsonElement expected = gson.toJsonTree(expectedDTO, FieldDTO.class); JsonElement result = gson.toJsonTree(authorDTO); - Assert.assertEquals(expected, result); + assertEquals(expected, result); } catch (IOException e) { e.printStackTrace(); From d2044f132c5c146c4d577b5497d8b11c32d700ef Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Fri, 18 Aug 2023 17:46:16 +0200 Subject: [PATCH 08/17] build(test): migrate JUnit4 parameterized tests and theories to JUnit5 ParameterizedTest #9782 --- .../iq/dataverse/DatasetAuthorTest.java | 42 ++--- .../FileDirectoryNameValidatorTest.java | 37 ++--- .../dataverse/authorization/AuthUtilTest.java | 99 +++++------- .../providers/shib/ShibUtilTest.java | 74 +++------ .../confirmemail/ConfirmEmailUtilTest.java | 68 +++----- .../iq/dataverse/metrics/MetricsUtilTest.java | 52 ++---- .../iq/dataverse/mydata/MyDataUtilTest.java | 80 +++++----- .../mydata/SolrQueryFormatterTest.java | 125 ++++++++++----- .../passwordreset/PasswordValidatorTest.java | 85 ++++------ .../iq/dataverse/util/FileUtilTest.java | 151 +++++++----------- .../iq/dataverse/util/JsfHelperTest.java | 30 ++-- .../iq/dataverse/util/StringUtilTest.java | 107 +++++-------- .../validation/PasswordValidatorUtilTest.java | 107 ++++--------- 13 files changed, 439 insertions(+), 618 deletions(-) diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetAuthorTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetAuthorTest.java index 78dacf08166..fa225de18ba 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DatasetAuthorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DatasetAuthorTest.java @@ -7,34 +7,20 @@ public class DatasetAuthorTest { - public String idType; - public String idValue; - public String expectedIdentifierAsUrl; - - public DatasetAuthorTest(String idType, String idValue, String expectedIdentifierAsUrl) { - this.idType = idType; - this.idValue = idValue; - this.expectedIdentifierAsUrl = expectedIdentifierAsUrl; - } - - @Parameters - public static Collection parameters() { - return Arrays.asList(new String[][] { - { "ORCID", "0000-0002-1825-0097", "https://orcid.org/0000-0002-1825-0097" }, - { "ISNI", "0000000121032683", "http://www.isni.org/isni/0000000121032683"}, - { "LCNA", "n82058243", "http://id.loc.gov/authorities/names/n82058243" }, - { "VIAF", "172389567", "https://viaf.org/viaf/172389567" }, - { "GND", "4079154-3", "https://d-nb.info/gnd/4079154-3" }, - { "ResearcherID", "634082", "https://publons.com/researcher/634082/" }, - { "ResearcherID", "AAW-9289-2021", "https://publons.com/researcher/AAW-9289-2021/" }, - { "ResearcherID", "J-9733-2013", "https://publons.com/researcher/J-9733-2013/" }, - { "ScopusID", "6602344670", "https://www.scopus.com/authid/detail.uri?authorId=6602344670" }, - { null, null, null, }, - }); - } - - @Test - public void getIdentifierAsUrl() { + @ParameterizedTest + @CsvSource(value = { + "ORCID,0000-0002-1825-0097,https://orcid.org/0000-0002-1825-0097", + "ISNI,0000000121032683,http://www.isni.org/isni/0000000121032683", + "LCNA,n82058243,http://id.loc.gov/authorities/names/n82058243", + "VIAF,172389567,https://viaf.org/viaf/172389567", + "GND,4079154-3,https://d-nb.info/gnd/4079154-3", + "ResearcherID,634082,https://publons.com/researcher/634082/", + "ResearcherID,AAW-9289-2021,https://publons.com/researcher/AAW-9289-2021/", + "ResearcherID,J-9733-2013,https://publons.com/researcher/J-9733-2013/", + "ScopusID,6602344670,https://www.scopus.com/authid/detail.uri?authorId=6602344670", + "NULL,NULL,NULL" + }, nullValues = "NULL") + void getIdentifierAsUrl(String idType, String idValue, String expectedIdentifierAsUrl) { DatasetAuthor datasetAuthor = new DatasetAuthor(); if (idType !=null && idValue != null) { datasetAuthor.setIdType(idType); diff --git a/src/test/java/edu/harvard/iq/dataverse/FileDirectoryNameValidatorTest.java b/src/test/java/edu/harvard/iq/dataverse/FileDirectoryNameValidatorTest.java index c8d6a8cd747..5ff74aea603 100644 --- a/src/test/java/edu/harvard/iq/dataverse/FileDirectoryNameValidatorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/FileDirectoryNameValidatorTest.java @@ -7,30 +7,19 @@ public class FileDirectoryNameValidatorTest { - public boolean isValid; - public String fileDirectoryName; - - public FileDirectoryNameValidatorTest(boolean isValid, String fileDirectoryName) { - this.isValid = isValid; - this.fileDirectoryName = fileDirectoryName; - } - - @Parameterized.Parameters - public static Collection parameters() { - return Arrays.asList(new Object[][]{ - {true, "foobar"}, - // The leading "-" gets stripped. - {true, "-foobar"}, - {true, "_foobar"}, - {true, "foobar_"}, - {true, "folder/sub"}, - {true, "folder///sub"}, - {true, "folder///sub/third"}, - {false, "f**bar"},}); - } - - @Test - public void testIsFileDirectoryNameValid() { + @ParameterizedTest + @CsvSource({ + "true,foobar", + // The leading "-" gets stripped. + "true,-foobar", + "true,_foobar", + "true,foobar_", + "true,folder/sub", + "true,folder///sub", + "true,folder///sub/third", + "false,f**bar" + }) + public void testIsFileDirectoryNameValid(boolean isValid, String fileDirectoryName) { assertEquals(isValid, FileDirectoryNameValidator.isFileDirectoryNameValid(fileDirectoryName, null)); } diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/AuthUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/AuthUtilTest.java index 66c7fbbbc70..74f6d714a5e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/AuthUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/AuthUtilTest.java @@ -17,68 +17,45 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class AuthUtilTest { - - @RunWith(Parameterized.class) - public static class AuthUtilParamTests { - - @Parameters - public static Collection data() { - return Arrays.asList( - new String[][] { - { null, null, null }, - { "Homer", "Homer", null }, - { "Simpson", null, "Simpson" }, - { "Homer Simpson", "Homer", "Simpson" }, - { "Homer Simpson", " Homer", "Simpson" } - } - ); - } - - @Parameter - public String expectedDisplayName; - - @Parameter(1) - public String displayFirst; - - @Parameter(2) - public String displayLast; - - @Test - public void testGetDisplayName() { - assertEquals(expectedDisplayName, AuthUtil.getDisplayName(displayFirst, displayLast)); - } + + @ParameterizedTest + @CsvSource(value = { + "NULL,NULL,NULL", + "Homer,Homer,NULL", + "Simpson,NULL,Simpson", + "Homer Simpson,Homer,Simpson", + "Homer Simpson,Homer,Simpson" + }, nullValues = "NULL") + void testGetDisplayName(String expectedDisplayName, String displayFirst, String displayLast) { + assertEquals(expectedDisplayName, AuthUtil.getDisplayName(displayFirst, displayLast)); } - - public static class AuthUtilNoParamTests { - - /** - * Test of isNonLocalLoginEnabled method, of class AuthUtil. - */ - @Test - public void testIsNonLocalLoginEnabled() { - System.out.println("isNonLocalLoginEnabled"); - - AuthUtil authUtil = new AuthUtil(); - - assertEquals(false, AuthUtil.isNonLocalLoginEnabled(null)); - - Collection shibOnly = new HashSet<>(); - shibOnly.add(new ShibAuthenticationProvider()); - assertEquals(true, AuthUtil.isNonLocalLoginEnabled(shibOnly)); - - Collection manyNonLocal = new HashSet<>(); - manyNonLocal.add(new ShibAuthenticationProvider()); - manyNonLocal.add(new GitHubOAuth2AP(null, null)); - manyNonLocal.add(new GoogleOAuth2AP(null, null)); - manyNonLocal.add(new OrcidOAuth2AP(null, null, null)); - assertEquals(true, AuthUtil.isNonLocalLoginEnabled(manyNonLocal)); - - Collection onlyBuiltin = new HashSet<>(); - onlyBuiltin.add(new BuiltinAuthenticationProvider(null, null, null)); - // only builtin provider - assertEquals(false, AuthUtil.isNonLocalLoginEnabled(onlyBuiltin)); - - } + + /** + * Test of isNonLocalLoginEnabled method, of class AuthUtil. + */ + @Test + public void testIsNonLocalLoginEnabled() { + System.out.println("isNonLocalLoginEnabled"); + + AuthUtil authUtil = new AuthUtil(); + + assertFalse(AuthUtil.isNonLocalLoginEnabled(null)); + + Collection shibOnly = new HashSet<>(); + shibOnly.add(new ShibAuthenticationProvider()); + assertTrue(AuthUtil.isNonLocalLoginEnabled(shibOnly)); + + Collection manyNonLocal = new HashSet<>(); + manyNonLocal.add(new ShibAuthenticationProvider()); + manyNonLocal.add(new GitHubOAuth2AP(null, null)); + manyNonLocal.add(new GoogleOAuth2AP(null, null)); + manyNonLocal.add(new OrcidOAuth2AP(null, null, null)); + assertTrue(AuthUtil.isNonLocalLoginEnabled(manyNonLocal)); + + Collection onlyBuiltin = new HashSet<>(); + onlyBuiltin.add(new BuiltinAuthenticationProvider(null, null, null)); + // only builtin provider + assertFalse(AuthUtil.isNonLocalLoginEnabled(onlyBuiltin)); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/shib/ShibUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/shib/ShibUtilTest.java index c011ad3041d..c644a4e2b2a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/providers/shib/ShibUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/providers/shib/ShibUtilTest.java @@ -16,55 +16,33 @@ import static org.mockito.Mockito.mock; public class ShibUtilTest { - - @RunWith(Parameterized.class) - public static class ShibUtilParamTest { - - @Parameters - public static Collection data() { - return Arrays.asList(new String[][] { - { "John", "Harvard", "John", "Harvard", null }, - { "Guido", "van Rossum", "Guido", "van Rossum", null }, - { "Philip Seymour", "Hoffman", "Philip Seymour", "Hoffman", "Philip Seymour Hoffman" }, - { "Edward", "Cummings", "Edward;e e", "Cummings", null }, - { "Edward", "Cummings", "Edward;e e", "Cummings", "e e cummings" }, - { "Anthony", "Stark", "Tony;Anthony", "Stark", null }, - { "Anthony", "Stark", "Anthony;Tony", "Stark", null }, - { "Antoni", "Gaudí", "Antoni", "Gaudí i Cornet;Gaudí", null }, - { "Jane", "Doe", null, null, "Jane Doe" }, - /** - * @todo Make findBestFirstAndLastName smart enough to know that the last name - * should be "Hoffman" rather than "Seymour". - */ - { "Philip", "Seymour", null, null, "Philip Seymour Hoffman" }, - { null, null, null, null, "" } - }); - } - - @Parameter - public String expectedFirstName; - - @Parameter(1) - public String expectedLastName; - - @Parameter(2) - public String actualFirstName; - - @Parameter(3) - public String actualLastName; - - @Parameter(4) - public String actualDisplayName; - - @Test - public void testFindBestFirstAndLastName() { - - // ShibUserNameFields expected1 = new ShibUserNameFields("John", "Harvard"); - ShibUserNameFields actualValues = ShibUtil.findBestFirstAndLastName(actualFirstName, actualLastName, actualDisplayName); - assertEquals(expectedFirstName, actualValues.getFirstName()); - assertEquals(expectedLastName, actualValues.getLastName()); - } + + @ParameterizedTest + @CsvSource(value = { + "John,Harvard,John,Harvard,NULL", + "Guido,van Rossum,Guido,van Rossum,NULL", + "Philip Seymour,Hoffman,Philip Seymour,Hoffman,Philip Seymour Hoffman", + "Edward,Cummings,Edward;e e,Cummings,NULL", + "Edward,Cummings,Edward;e e,Cummings,e e cummings", + "Anthony,Stark,Tony;Anthony,Stark,NULL", + "Anthony,Stark,Anthony;Tony,Stark,NULL", + "Antoni,Gaudí,Antoni,Gaudí i Cornet;Gaudí,NULL", + "Jane,Doe,NULL,NULL,Jane Doe", + /** + * @todo Make findBestFirstAndLastName smart enough to know that the last name + * should be "Hoffman" rather than "Seymour". + */ + "Philip,Seymour,NULL,NULL,Philip Seymour Hoffman", + "NULL,NULL,NULL,NULL,EMPTY" + }, nullValues = "NULL", emptyValue = "EMPTY") + void testFindBestFirstAndLastName(String expectedFirstName, String expectedLastName, String actualFirstName, + String actualLastName, String actualDisplayName) { + // ShibUserNameFields expected1 = new ShibUserNameFields("John", "Harvard"); + ShibUserNameFields actualValues = ShibUtil.findBestFirstAndLastName(actualFirstName, actualLastName, actualDisplayName); + assertEquals(expectedFirstName, actualValues.getFirstName()); + assertEquals(expectedLastName, actualValues.getLastName()); } + public static class ShibUtilNoParamTest { diff --git a/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailUtilTest.java index d2ef6a51a84..43795f0114f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailUtilTest.java @@ -11,49 +11,31 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class ConfirmEmailUtilTest { - - @RunWith(Parameterized.class) - public static class ConfirmEmailUtilParamTest { - - public String timeAsFriendlyString; - public int timeInMinutes; - - public ConfirmEmailUtilParamTest(String timeAsFriendlyString, int timeInSeconds) { - this.timeAsFriendlyString = timeAsFriendlyString; - this.timeInMinutes = timeInSeconds; - } - - @Parameters - public static Collection parameters() { - return Arrays.asList( - new Object[][] { - { "48 hours", 2880 }, - { "24 hours", 1440 }, - { "2.75 hours", 165 }, - { "2.5 hours", 150 }, - { "1.5 hours", 90 }, - { "1 hour", 60 }, - { "30 minutes", 30 }, - { "1 minute", 1 } - } - ); - } - - @Test - public void friendlyExpirationTimeTest() { - assertEquals(timeAsFriendlyString, ConfirmEmailUtil.friendlyExpirationTime(timeInMinutes)); - } + + static Stream dataPoints() { + return Stream.of( + Arguments.of("48 hours", 2880), + Arguments.of("24 hours", 1440), + Arguments.of("2.75 hours", 165), + Arguments.of("2.5 hours", 150), + Arguments.of("1.5 hours", 90), + Arguments.of("1 hour", 60), + Arguments.of("30 minutes", 30), + Arguments.of("1 minute", 1) + ); } - - public static class ConfirmEmailUtilNoParamTest { - - @Test - public void testGrandfatheredTime() { - System.out.println(); - System.out.println("Grandfathered account timestamp test"); - System.out.println("Grandfathered Time (y2k): " + ConfirmEmailUtil.getGrandfatheredTime()); - assertEquals(Timestamp.valueOf("2000-01-01 00:00:00.0"), ConfirmEmailUtil.getGrandfatheredTime()); - System.out.println(); - } + + @ParameterizedTest + @MethodSource("dataPoints") + void friendlyExpirationTimeTest(String timeAsFriendlyString, int timeInMinutes) { + assertEquals(timeAsFriendlyString, ConfirmEmailUtil.friendlyExpirationTime(timeInMinutes)); + } + + @Test + void testGrandfatheredTime() { + //System.out.println("Grandfathered account timestamp test"); + //System.out.println("Grandfathered Time (y2k): " + ConfirmEmailUtil.getGrandfatheredTime()); + assertEquals(Timestamp.valueOf("2000-01-01 00:00:00.0"), ConfirmEmailUtil.getGrandfatheredTime()); + //System.out.println(); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/metrics/MetricsUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/metrics/MetricsUtilTest.java index bb42bda68ea..484ce2ebe47 100644 --- a/src/test/java/edu/harvard/iq/dataverse/metrics/MetricsUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/metrics/MetricsUtilTest.java @@ -205,42 +205,20 @@ public void testStringToJsonObjectBuilder() { } } - - @RunWith(Parameterized.class) - public static class ValidateDataLocationStringTypeTest { - @Parameter - public String dataLocation; - - @Parameter(1) - public boolean isExceptionExpected; - - @Parameter(2) - public String expectedOutput; - - @Parameters - public static Collection parameters() { - return Arrays.asList(new Object[][] { - { "local", false, "local" }, - { "remote", false, "remote" }, - { "all", false, "all" }, - { null, false, "local" }, - { "", false, "local" }, - { "abcd", true, null } - }); - } - - @Test - public void testValidateDataLocationStringType() { - try { - assertEquals(expectedOutput, MetricsUtil.validateDataLocationStringType(dataLocation)); - } catch (Exception e) { - if (isExceptionExpected) { - return; - } else { - fail("should not throw an exception!"); - } - } - } - + + @ParameterizedTest + @CsvSource(value = { + "local,false,local", + "remote,false,remote", + "all,false,all", + "NULL,false,local", + "'',false,local", + "abcd,true,NULL" + }, nullValues = "NULL") + void testValidateDataLocationStringType(String dataLocation, boolean isExceptionExpected, String expectedOutput) { + if (isExceptionExpected) + assertThrows(Exception.class, () -> MetricsUtil.validateDataLocationStringType(dataLocation)); + else + assertEquals(expectedOutput, MetricsUtil.validateDataLocationStringType(dataLocation)); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/mydata/MyDataUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/mydata/MyDataUtilTest.java index 111d785f52d..8cf5b0a3f44 100644 --- a/src/test/java/edu/harvard/iq/dataverse/mydata/MyDataUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/mydata/MyDataUtilTest.java @@ -13,64 +13,70 @@ class MyDataUtilTest { - @DataPoints - public static String[] userIdentifier = { - "@nzaugg", "nzaugg@", "nzaugg", "123nzaugg", "", " ", null, "@", "n" }; + static List userIdentifier() { + return List.of("@nzaugg", "nzaugg@", "nzaugg", "123nzaugg", " ", "@", "n"); + } - @Theory - public void testFormatUserIdentifierAsAssigneeIdentifierNull(String userIdentifier) { - assumeTrue(userIdentifier == null); + @ParameterizedTest + @NullSource + void testFormatUserIdentifierAsAssigneeIdentifierNull(String userIdentifier) { String formattedUserIdentifier = MyDataUtil.formatUserIdentifierAsAssigneeIdentifier(userIdentifier); - assertTrue(formattedUserIdentifier == null); + assertNull(formattedUserIdentifier); } - - @Theory - public void testFormatUserIdentifierAsAssigneeIdentifierOneCharString(String userIdentifier) { - assumeTrue(userIdentifier != null); + + @ParameterizedTest + @MethodSource("userIdentifier") + void testFormatUserIdentifierAsAssigneeIdentifierOneCharString(String userIdentifier) { assumeTrue(userIdentifier.startsWith("@")); + String formattedUserIdentifier = MyDataUtil.formatUserIdentifierAsAssigneeIdentifier(userIdentifier); - assertTrue(formattedUserIdentifier.equals(userIdentifier)); + assertEquals(formattedUserIdentifier, userIdentifier); } - - @Theory - public void testFormatUserIdentifierAsAssigneeIdentifier(String userIdentifier) { - assumeTrue(userIdentifier != null); + + @ParameterizedTest + @MethodSource("userIdentifier") + void testFormatUserIdentifierAsAssigneeIdentifier(String userIdentifier) { assumeTrue(!userIdentifier.startsWith("@")); + String formattedUserIdentifier = MyDataUtil.formatUserIdentifierAsAssigneeIdentifier(userIdentifier); - assertTrue(formattedUserIdentifier.equals("@" + userIdentifier)); + assertEquals(formattedUserIdentifier, "@" + userIdentifier); } - - @Theory - public void testFormatUserIdentifierForMyDataFormNull(String userIdentifier) { - assumeTrue(userIdentifier == null); + + @ParameterizedTest + @NullSource + void testFormatUserIdentifierForMyDataFormNull(String userIdentifier) { String formattedUserIdentifier = MyDataUtil.formatUserIdentifierForMyDataForm(userIdentifier); - assertTrue(formattedUserIdentifier == null); + assertNull(formattedUserIdentifier); } - - @Theory - public void testFormatUserIdentifierForMyDataFormOneCharString(String userIdentifier) { - assumeTrue(userIdentifier != null); + + @ParameterizedTest + @MethodSource("userIdentifier") + void testFormatUserIdentifierForMyDataFormOneCharString(String userIdentifier) { assumeTrue(userIdentifier.startsWith("@")); assumeTrue(userIdentifier.length() == 1); + String formattedUserIdentifier = MyDataUtil.formatUserIdentifierForMyDataForm(userIdentifier); - assertTrue(formattedUserIdentifier == null); + assertNull(formattedUserIdentifier); } - - @Theory - public void testFormatUserIdentifierForMyDataFormLongerString(String userIdentifier) { - assumeTrue(userIdentifier != null); + + @ParameterizedTest + @MethodSource("userIdentifier") + void testFormatUserIdentifierForMyDataFormLongerString(String userIdentifier) { assumeTrue(userIdentifier.startsWith("@")); assumeTrue(userIdentifier.length() > 1); + String formattedUserIdentifier = MyDataUtil.formatUserIdentifierForMyDataForm(userIdentifier); - assertTrue(formattedUserIdentifier.equals(userIdentifier.substring(1))); + assertEquals(formattedUserIdentifier, userIdentifier.substring(1)); } - - @Theory - public void testFormatUserIdentifierForMyDataForm(String userIdentifier) { - assumeTrue(userIdentifier != null); + + @ParameterizedTest + @MethodSource("userIdentifier") + @EmptySource + void testFormatUserIdentifierForMyDataForm(String userIdentifier) { assumeTrue(!userIdentifier.startsWith("@")); + String formattedUserIdentifier = MyDataUtil.formatUserIdentifierForMyDataForm(userIdentifier); - assertTrue(formattedUserIdentifier.equals(userIdentifier)); + assertEquals(formattedUserIdentifier, userIdentifier); } } \ No newline at end of file diff --git a/src/test/java/edu/harvard/iq/dataverse/mydata/SolrQueryFormatterTest.java b/src/test/java/edu/harvard/iq/dataverse/mydata/SolrQueryFormatterTest.java index 6f242d67dcf..789204c1db4 100644 --- a/src/test/java/edu/harvard/iq/dataverse/mydata/SolrQueryFormatterTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/mydata/SolrQueryFormatterTest.java @@ -126,28 +126,7 @@ private void msgt(String s){ } } - @RunWith(Parameterized.class) - public static class SolrQueryFormatterParamTest { - - @Parameter(0) - public List sliceOfIds; - - @Parameter(1) - public String paramName; - - @Parameter(2) - public String dvObjectType; - - // may be either - // (i) the expected query part or - // (ii) the expected exception message - @Parameter(3) - public String expectedResult; - - @Parameter(4) - public Class expectedException; - - @Parameters + /* public static Collection data() { // The following list of test cases was compiled using the interface-based approach for input-space partition. // Therefor, for every input parameter, the domain of possible values was partitioned into different sets: @@ -208,24 +187,90 @@ public static Collection data() { { new ArrayList(Arrays.asList(1L, null)), "paramName", "dvObjectType", "(paramName:(1) AND dvObjectType:(dvObjectType))", null }, }); } - - @Test - public void testFormatIdsForSolrClause() { - SolrQueryFormatter sqf = new SolrQueryFormatter(); - - if (expectedException == null) { - assertEquals(expectedResult, sqf.formatIdsForSolrClause(sliceOfIds, paramName, dvObjectType)); - return; - } - - try { - sqf.formatIdsForSolrClause(sliceOfIds, paramName, dvObjectType); - fail("Expected exception (" + expectedException.toString() + ") was not thrown"); - } catch (Exception ex) { - assertEquals("verify the exception class", expectedException, ex.getClass()); - assertEquals("verify the exception message", expectedResult, ex.getMessage()); - } + */ + + /* + * The following list of test cases was compiled using the interface-based approach for input-space partition. + * Therefor, for every input parameter, the domain of possible values was partitioned into different sets: + * - sliceOfIds (5 sets): null, empty, non-empty with null values only, non-empty with Long values only, non-empty with both null and Long values + * - paramName (3 sets): null, empty, non-empty + * - dvObjectType (3 sets): null, empty, non-empty + * Then, for every set, a representative value was chosen and combined with every other set (3*3*5 = 45 test cases). + */ + static Stream data() { + return Stream.of( + // sliceOfIds paramName dvObjectType expectedResult expectedException + Arguments.of(null, null, null, "paramName cannot be null", NullPointerException.class), + Arguments.of(null, null, "", "paramName cannot be null", NullPointerException.class), + Arguments.of(null, null, "dvObjectType", "paramName cannot be null", NullPointerException.class), + Arguments.of(null, "", null, "sliceOfIds cannot be null", NullPointerException.class), + Arguments.of(null, "", "", "sliceOfIds cannot be null", NullPointerException.class), + Arguments.of(null, "", "dvObjectType", "sliceOfIds cannot be null", NullPointerException.class), + Arguments.of(null, "paramName", null, "sliceOfIds cannot be null", NullPointerException.class), + Arguments.of(null, "paramName", "", "sliceOfIds cannot be null", NullPointerException.class), + Arguments.of(null, "paramName", "dvObjectType", "sliceOfIds cannot be null", NullPointerException.class), + + Arguments.of(list(), null, null, "paramName cannot be null", NullPointerException.class), + Arguments.of(list(), null, "", "paramName cannot be null", NullPointerException.class), + Arguments.of(list(), null, "dvObjectType", "paramName cannot be null", NullPointerException.class), + Arguments.of(list(), "", null, "sliceOfIds must have at least 1 value", IllegalStateException.class), + Arguments.of(list(), "", "", "sliceOfIds must have at least 1 value", IllegalStateException.class), + Arguments.of(list(), "", "dvObjectType", "sliceOfIds must have at least 1 value", IllegalStateException.class), + Arguments.of(list(), "paramName", null, "sliceOfIds must have at least 1 value", IllegalStateException.class), + Arguments.of(list(), "paramName", "", "sliceOfIds must have at least 1 value", IllegalStateException.class), + Arguments.of(list(), "paramName", "dvObjectType", "sliceOfIds must have at least 1 value", IllegalStateException.class), + + Arguments.of(list((Long) null), null, null, "paramName cannot be null", NullPointerException.class), + Arguments.of(list((Long) null), null, "", "paramName cannot be null", NullPointerException.class), + Arguments.of(list((Long) null), null, "dvObjectType", "paramName cannot be null", NullPointerException.class), + Arguments.of(list((Long) null), "", null, "(:())", null), + Arguments.of(list((Long) null), "", "", "(:() AND dvObjectType:())", null), + Arguments.of(list((Long) null), "", "dvObjectType", "(:() AND dvObjectType:(dvObjectType))", null), + Arguments.of(list((Long) null), "paramName", null, "(paramName:())", null), + Arguments.of(list((Long) null), "paramName", "", "(paramName:() AND dvObjectType:())", null), + Arguments.of(list((Long) null), "paramName", "dvObjectType", "(paramName:() AND dvObjectType:(dvObjectType))", null), + + Arguments.of(list(1L), null, null, "paramName cannot be null", NullPointerException.class), + Arguments.of(list(1L), null, "", "paramName cannot be null", NullPointerException.class), + Arguments.of(list(1L), null, "dvObjectType", "paramName cannot be null", NullPointerException.class), + Arguments.of(list(1L), "", null, "(:(1))", null), + Arguments.of(list(1L), "", "", "(:(1) AND dvObjectType:())", null), + Arguments.of(list(1L), "", "dvObjectType", "(:(1) AND dvObjectType:(dvObjectType))", null), + Arguments.of(list(1L), "paramName", null, "(paramName:(1))", null), + Arguments.of(list(1L), "paramName", "", "(paramName:(1) AND dvObjectType:())", null), + Arguments.of(list(1L), "paramName", "dvObjectType", "(paramName:(1) AND dvObjectType:(dvObjectType))", null), + + Arguments.of(list(1L, null), null, null, "paramName cannot be null", NullPointerException.class), + Arguments.of(list(1L, null), null, "", "paramName cannot be null", NullPointerException.class), + Arguments.of(list(1L, null), null, "dvObjectType", "paramName cannot be null", NullPointerException.class), + Arguments.of(list(1L, null), "", null, "(:(1))", null), + Arguments.of(list(1L, null), "", "", "(:(1) AND dvObjectType:())", null), + Arguments.of(list(1L, null), "", "dvObjectType", "(:(1) AND dvObjectType:(dvObjectType))", null), + Arguments.of(list(1L, null), "paramName", null, "(paramName:(1))", null), + Arguments.of(list(1L, null), "paramName", "", "(paramName:(1) AND dvObjectType:())", null), + Arguments.of(list(1L, null), "paramName", "dvObjectType", "(paramName:(1) AND dvObjectType:(dvObjectType))", null) + ); + } + + /** + * @param expectedResult May either be (i) the expected query part or (ii) the expected exception message + */ + @ParameterizedTest + @MethodSource("data") + void testFormatIdsForSolrClause(List sliceOfIds, String paramName, String dvObjectType, + String expectedResult, Class expectedException) { + SolrQueryFormatter sqf = new SolrQueryFormatter(); + + if (expectedException == null) { + assertEquals(expectedResult, sqf.formatIdsForSolrClause(sliceOfIds, paramName, dvObjectType)); + return; } - + + Throwable e = assertThrows(expectedException, () -> sqf.formatIdsForSolrClause(sliceOfIds, paramName, dvObjectType)); + assertEquals(expectedResult, e.getMessage()); + } + + static List list(Long... args) { + return Arrays.asList(args); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordValidatorTest.java b/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordValidatorTest.java index 2187ff3235d..c15f7fa95e9 100644 --- a/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordValidatorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/passwordreset/PasswordValidatorTest.java @@ -9,61 +9,42 @@ import org.junit.jupiter.params.provider.MethodSource; public class PasswordValidatorTest { - - public String password; - public boolean expected; - public boolean mustContainSpecialCharacters; - public boolean mustContainCapitalLetters; - public boolean mustContainNumbers; - public int minLength; - public int maxLength; - - public PasswordValidatorTest(String password, boolean expected, boolean mustContainSpecialCharacters, - boolean mustContainCapitalLetters, boolean mustContainNumbers, int minLength, int maxLength) { - this.password = password; - this.expected = expected; - this.mustContainSpecialCharacters = mustContainSpecialCharacters; - this.mustContainCapitalLetters = mustContainCapitalLetters; - this.mustContainNumbers = mustContainNumbers; - this.minLength = minLength; - this.maxLength = maxLength; - } - - @Parameters - public static Collection parameters() { - return Arrays.asList( - new Object[][] { - // Check if PasswordValidator correctly validates correct passwords - // with all combinations of Special Characters, - // Capital Letters and Numbers - {"abcdefghabcdefgh", true, false, false, false, 8, 30}, - {"@bcdefgh@bcdefgh", true, true, false, false, 8, 30}, - {"@bAdefgh@bAdefgh", true, true, true, false, 8, 30}, - {"abAdefghabAdefgh", true, false, true, false, 8, 30}, - {"a1Adefgha1Adefgh", true, false, true, true, 8, 30}, - {"ab1defghab1defgh", true, false, false, true, 8, 30}, - {"@1cdefgh@1cdefgh", true, true, false, true, 8, 30}, - {"@1Adefgh@1Adefgh", true, true, true, true, 8, 30}, - // Check if PasswordValidator correctly rejects wrong passwords - // with all combinations of Special Characters, - // Capital Letters and Numbers - {"abcabc", false, false, false, false, 8, 30}, - {"abcdabcd", false, true, false, false, 8, 30}, - {"@bcd@bcd", false, true, true, false, 8, 30}, - {"@bc1@bc1", false, false, true, false, 8, 30}, - {"a1cda1cd", false, false, true, true, 8, 30}, - {"AbcdAbcd", false, false, false, true, 8, 30}, - {"@Bcd@Bcd", false, true, false, true, 8, 30}, - {"a1Ada1Ad", false, true, true, true, 8, 30}, - {"", false, false, false, false, 1, 30}, - {" ", false, false, false, false, 1, 30}, - {"?!abcdef", false, true, false, false, 8, 30} - } + + static Stream testCases() { + return Stream.of( + // Check if PasswordValidator correctly validates correct passwords + // with all combinations of Special Characters, + // Capital Letters and Numbers + Arguments.of("abcdefghabcdefgh", true, false, false, false, 8, 30), + Arguments.of("@bcdefgh@bcdefgh", true, true, false, false, 8, 30), + Arguments.of("@bAdefgh@bAdefgh", true, true, true, false, 8, 30), + Arguments.of("abAdefghabAdefgh", true, false, true, false, 8, 30), + Arguments.of("a1Adefgha1Adefgh", true, false, true, true, 8, 30), + Arguments.of("ab1defghab1defgh", true, false, false, true, 8, 30), + Arguments.of("@1cdefgh@1cdefgh", true, true, false, true, 8, 30), + Arguments.of("@1Adefgh@1Adefgh", true, true, true, true, 8, 30), + // Check if PasswordValidator correctly rejects wrong passwords + // with all combinations of Special Characters, + // Capital Letters and Numbers + Arguments.of("abcabc", false, false, false, false, 8, 30), + Arguments.of("abcdabcd", false, true, false, false, 8, 30), + Arguments.of("@bcd@bcd", false, true, true, false, 8, 30), + Arguments.of("@bc1@bc1", false, false, true, false, 8, 30), + Arguments.of("a1cda1cd", false, false, true, true, 8, 30), + Arguments.of("AbcdAbcd", false, false, false, true, 8, 30), + Arguments.of("@Bcd@Bcd", false, true, false, true, 8, 30), + Arguments.of("a1Ada1Ad", false, true, true, true, 8, 30), + Arguments.of("", false, false, false, false, 1, 30), + Arguments.of(" ", false, false, false, false, 1, 30), + Arguments.of("?!abcdef", false, true, false, false, 8, 30) ); } - @Test - public void testValidatePassword() { + @ParameterizedTest + @MethodSource("testCases") + void testValidatePassword(String password, boolean expected, boolean mustContainSpecialCharacters, + boolean mustContainCapitalLetters, boolean mustContainNumbers, int minLength, + int maxLength) { PasswordValidator validator = PasswordValidator.buildValidator(mustContainSpecialCharacters, mustContainCapitalLetters, mustContainNumbers, minLength, maxLength); boolean isValidPassword = validator.validatePassword(password); diff --git a/src/test/java/edu/harvard/iq/dataverse/util/FileUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/util/FileUtilTest.java index 956b54a08ef..2cfe9f25d7e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/FileUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/FileUtilTest.java @@ -31,89 +31,60 @@ import static org.junit.jupiter.api.Assertions.fail; public class FileUtilTest { - - @RunWith(Parameterized.class) - public static class FileUtilParamTest { - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { null, null, null }, - - { "trees.png-endnote.xml", "trees.png", FileUtil.FileCitationExtension.ENDNOTE }, - { "trees.png.ris", "trees.png", FileUtil.FileCitationExtension.RIS }, - { "trees.png.bib", "trees.png", FileUtil.FileCitationExtension.BIBTEX }, - { null, "trees.png", null }, - - { "50by1000-endnote.xml", "50by1000.tab", FileUtil.FileCitationExtension.ENDNOTE }, - { "50by1000.ris", "50by1000.tab", FileUtil.FileCitationExtension.RIS }, - { "50by1000.bib", "50by1000.tab", FileUtil.FileCitationExtension.BIBTEX } - }); - } - - @Parameter - public String expectedFileName; - - @Parameter(1) - public String actualFileName; - - @Parameter(2) - public FileCitationExtension citationExtension; - - @Test - public void testGetCiteDataFileFilename() { - assertEquals(expectedFileName, FileUtil.getCiteDataFileFilename(actualFileName, citationExtension)); - } + + static Stream dataFilenames() { + return Stream.of( + Arguments.of(null, null, null), + Arguments.of("trees.png-endnote.xml", "trees.png", FileUtil.FileCitationExtension.ENDNOTE), + Arguments.of("trees.png.ris", "trees.png", FileUtil.FileCitationExtension.RIS), + Arguments.of("trees.png.bib", "trees.png", FileUtil.FileCitationExtension.BIBTEX), + Arguments.of(null, "trees.png", null), + Arguments.of("50by1000-endnote.xml", "50by1000.tab", FileUtil.FileCitationExtension.ENDNOTE), + Arguments.of("50by1000.ris", "50by1000.tab", FileUtil.FileCitationExtension.RIS), + Arguments.of("50by1000.bib", "50by1000.tab", FileUtil.FileCitationExtension.BIBTEX) + ); } - - @RunWith(Parameterized.class) - public static class FileUtilParamTest2 { - - @Parameter - public String expectedString; - - @Parameter(1) - public String originalName; - - @Parameter(2) - public String newExtension; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - // functional approach: what should the method do - // replace no extension with an empty extension - { "no-extension.", "no-extension", ""}, - - // replace extension x with same extension - { "extension.x", "extension.x", "x" }, - - // replace extension x with another extension y - { "extension.y", "extension.x", "y" }, - - // interface approach: what are possible inputs - // will not pass as null is not handled - //{ null, null, null }, - //{ null, null, "" }, - //{ null, null, "y" }, - - { ".null", "", null }, - { ".", "", "" }, - { ".y", "", "y" }, - }); - } - - @Test - public void testReplaceExtension() { - assertEquals(expectedString, FileUtil.replaceExtension(originalName, newExtension)); - } - + + @ParameterizedTest + @MethodSource("dataFilenames") + void testGetCiteDataFileFilename(String expectedFileName, String actualFileName, FileCitationExtension citationExtension) { + assertEquals(expectedFileName, FileUtil.getCiteDataFileFilename(actualFileName, citationExtension)); + } + + static Stream dataReplaceNames() { + return Stream.of( + // functional approach: what should the method do + // replace no extension with an empty extension + Arguments.of("no-extension.", "no-extension", ""), + + // replace extension x with same extension + Arguments.of("extension.x", "extension.x", "x"), + + // replace extension x with another extension y + Arguments.of("extension.y", "extension.x", "y"), + + // interface approach: what are possible inputs + // will not pass as null is not handled + //Arguments.of(null, null, null), + //Arguments.of(null, null, ""), + //Arguments.of(null, null, "y"), + + Arguments.of(".null", "", null), + Arguments.of(".", "", ""), + Arguments.of(".y", "", "y") + ); + } + + @ParameterizedTest + @MethodSource("dataReplaceNames") + void testReplaceExtension(String expectedString, String originalName, String newExtension) { + assertEquals(expectedString, FileUtil.replaceExtension(originalName, newExtension)); } - public static class FileUtilNoParamTest { + static class FileUtilNoParamTest { @Test public void testIsDownloadPopupRequiredNull() { - assertEquals(false, FileUtil.isDownloadPopupRequired(null)); + assertFalse(FileUtil.isDownloadPopupRequired(null)); } @Test @@ -121,7 +92,7 @@ public void testIsDownloadPopupRequiredDraft() { Dataset dataset = new Dataset(); DatasetVersion dsv1 = dataset.getOrCreateEditVersion(); assertEquals(DatasetVersion.VersionState.DRAFT, dsv1.getVersionState()); - assertEquals(false, FileUtil.isDownloadPopupRequired(dsv1)); + assertFalse(FileUtil.isDownloadPopupRequired(dsv1)); } @Test @@ -133,7 +104,7 @@ public void testIsDownloadPopupRequiredLicenseCC0() { license.setDefault(true); termsOfUseAndAccess.setLicense(license); dsv1.setTermsOfUseAndAccess(termsOfUseAndAccess); - assertEquals(false, FileUtil.isDownloadPopupRequired(dsv1)); + assertFalse(FileUtil.isDownloadPopupRequired(dsv1)); } @Test @@ -151,7 +122,7 @@ public void testIsDownloadPopupRequiredHasTermsOfUseAndCc0License() { termsOfUseAndAccess.setLicense(license); termsOfUseAndAccess.setTermsOfUse("be excellent to each other"); dsv1.setTermsOfUseAndAccess(termsOfUseAndAccess); - assertEquals(false, FileUtil.isDownloadPopupRequired(dsv1)); + assertFalse(FileUtil.isDownloadPopupRequired(dsv1)); } @Test @@ -162,7 +133,7 @@ public void testIsDownloadPopupRequiredHasTermsOfUseAndNoneLicense() { termsOfUseAndAccess.setLicense(null); termsOfUseAndAccess.setTermsOfUse("be excellent to each other"); dsv1.setTermsOfUseAndAccess(termsOfUseAndAccess); - assertEquals(true, FileUtil.isDownloadPopupRequired(dsv1)); + assertTrue(FileUtil.isDownloadPopupRequired(dsv1)); } @Test @@ -172,7 +143,7 @@ public void testIsDownloadPopupRequiredHasTermsOfAccess() { TermsOfUseAndAccess termsOfUseAndAccess = new TermsOfUseAndAccess(); termsOfUseAndAccess.setTermsOfAccess("Terms of *Access* is different than Terms of Use"); dsv1.setTermsOfUseAndAccess(termsOfUseAndAccess); - assertEquals(true, FileUtil.isDownloadPopupRequired(dsv1)); + assertTrue(FileUtil.isDownloadPopupRequired(dsv1)); } @Test @@ -186,17 +157,17 @@ public void testIsDownloadPopupRequiredHasGuestBook() { dataset.setGuestbook(guestbook); Dataverse dataverse = new Dataverse(); guestbook.setDataverse(dataverse); - assertEquals(true, FileUtil.isDownloadPopupRequired(datasetVersion)); + assertTrue(FileUtil.isDownloadPopupRequired(datasetVersion)); } @Test public void testIsPubliclyDownloadable() { - assertEquals(false, FileUtil.isPubliclyDownloadable(null)); + assertFalse(FileUtil.isPubliclyDownloadable(null)); FileMetadata restrictedFileMetadata = new FileMetadata(); restrictedFileMetadata.setRestricted(true); restrictedFileMetadata.setDataFile(new DataFile()); - assertEquals(false, FileUtil.isPubliclyDownloadable(restrictedFileMetadata)); + assertFalse(FileUtil.isPubliclyDownloadable(restrictedFileMetadata)); FileMetadata nonRestrictedFileMetadata = new FileMetadata(); nonRestrictedFileMetadata.setDataFile(new DataFile()); @@ -206,7 +177,7 @@ public void testIsPubliclyDownloadable() { Dataset dataset = new Dataset(); dsv.setDataset(dataset); nonRestrictedFileMetadata.setRestricted(false); - assertEquals(true, FileUtil.isPubliclyDownloadable(nonRestrictedFileMetadata)); + assertTrue(FileUtil.isPubliclyDownloadable(nonRestrictedFileMetadata)); } @Test @@ -223,7 +194,7 @@ public void testIsPubliclyDownloadable2() { Dataset dataset = new Dataset(); dsv.setDataset(dataset); nonRestrictedFileMetadata.setRestricted(false); - assertEquals(false, FileUtil.isPubliclyDownloadable(nonRestrictedFileMetadata)); + assertFalse(FileUtil.isPubliclyDownloadable(nonRestrictedFileMetadata)); } @Test @@ -241,7 +212,7 @@ public void testIsPubliclyDownloadable3() { Dataset dataset = new Dataset(); dsv.setDataset(dataset); embargoedFileMetadata.setRestricted(false); - assertEquals(false, FileUtil.isPubliclyDownloadable(embargoedFileMetadata)); + assertFalse(FileUtil.isPubliclyDownloadable(embargoedFileMetadata)); } @Test @@ -263,7 +234,7 @@ public void testgetFileDownloadUrl() { @Test public void testGetPublicDownloadUrl() { - assertEquals(null, FileUtil.getPublicDownloadUrl(null, null, null)); + assertNull(FileUtil.getPublicDownloadUrl(null, null, null)); assertEquals("https://demo.dataverse.org/api/access/datafile/:persistentId?persistentId=doi:10.5072/FK2/TLU3EP", FileUtil.getPublicDownloadUrl("https://demo.dataverse.org", "doi:10.5072/FK2/TLU3EP", 33L)); //pid before fileId assertEquals("https://demo.dataverse.org/api/access/datafile/:persistentId?persistentId=doi:10.5072/FK2/TLU3EP", FileUtil.getPublicDownloadUrl("https://demo.dataverse.org", "doi:10.5072/FK2/TLU3EP", null)); assertEquals("https://demo.dataverse.org/api/access/datafile/33", FileUtil.getPublicDownloadUrl("https://demo.dataverse.org", null, 33L)); //pid before fileId diff --git a/src/test/java/edu/harvard/iq/dataverse/util/JsfHelperTest.java b/src/test/java/edu/harvard/iq/dataverse/util/JsfHelperTest.java index 0f68c1e7371..316b9c3a2aa 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/JsfHelperTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/JsfHelperTest.java @@ -35,34 +35,22 @@ public void setUp() { @AfterEach public void tearDown() { } - - public TestEnum inputEnum; - public String inputString; - public TestEnum defaultEnumValue; - public JsfHelperTest(TestEnum inputEnum, String inputString, TestEnum defaultEnumValue) { - this.inputEnum = inputEnum; - this.inputString = inputString; - this.defaultEnumValue = defaultEnumValue; - } - - @Parameters - public static Collection parameters() { - return Arrays.asList ( - new Object[][] { - { TestEnum.Lorem, "Lorem", TestEnum.Dolor }, - { TestEnum.Lorem, "Lorem ", TestEnum.Dolor }, - { TestEnum.Dolor, null, TestEnum.Dolor }, - { TestEnum.Dolor, "THIS IS A BAD VALUE", TestEnum.Dolor }, - } + static Stream parameters() { + return Stream.of( + Arguments.of(TestEnum.Lorem, "Lorem", TestEnum.Dolor), + Arguments.of(TestEnum.Lorem, "Lorem ", TestEnum.Dolor), + Arguments.of(TestEnum.Dolor, null, TestEnum.Dolor), + Arguments.of(TestEnum.Dolor, "THIS IS A BAD VALUE", TestEnum.Dolor ) ); } /** * Test of enumValue method, of class JsfHelper. */ - @Test - public void testEnumValue() { + @ParameterizedTest + @MethodSource("parameters") + public void testEnumValue(TestEnum inputEnum, String inputString, TestEnum defaultEnumValue) { System.out.println("enumValue"); JsfHelper instance = new JsfHelper(); diff --git a/src/test/java/edu/harvard/iq/dataverse/util/StringUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/util/StringUtilTest.java index f999b48ea9c..b00b4afca7d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/StringUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/StringUtilTest.java @@ -93,70 +93,51 @@ void testSubstringIncludingLast(String str, String separator, String expectedStr assertEquals( expectedString, StringUtil.substringIncludingLast(str, separator) ); } - @Parameters - public static Collection parameters() { - return Arrays.asList( - new Object[][] { - {null, Optional.empty()}, - {"", Optional.empty()}, - {" leadingWhitespace", Optional.of("leadingWhitespace")}, - {"trailingWhiteSpace ", Optional.of("trailingWhiteSpace")}, - {"someString", Optional.of("someString")}, - {"some string with spaces", Optional.of("some string with spaces")} - } - ); - } - - @Test - public void testToOption() { - assertEquals(expected, StringUtil.toOption(inputString)); - } + static Stream toOptionData() { + return Stream.of( + Arguments.of(Optional.empty(), null), + Arguments.of(Optional.empty(), ""), + Arguments.of(Optional.of("leadingWhitespace"), " leadingWhitespace"), + Arguments.of(Optional.of("trailingWhiteSpace"), "trailingWhiteSpace "), + Arguments.of(Optional.of("someString"), "someString"), + Arguments.of(Optional.of("some string with spaces"), "some string with spaces") + ); } - - @RunWith(Parameterized.class) - public static class TestSanitizeFileDirectory { - - public String inputString; - public String expected; - public boolean aggressively; - - public TestSanitizeFileDirectory(String inputString, String expected, boolean aggressively) { - this.inputString = inputString; - this.expected = expected; - this.aggressively = aggressively; - } - - @Parameters - public static Collection parameters() { - return Arrays.asList( - new Object[][] { - {"some\\path\\to\\a\\directory", "some/path/to/a/directory", false}, - {"some\\//path\\//to\\//a\\//directory", "some/path/to/a/directory", false}, - // starts with / or - or . or whitepsace - {"/some/path/to/a/directory", "some/path/to/a/directory", false}, - {"-some/path/to/a/directory", "some/path/to/a/directory", false}, - {".some/path/to/a/directory", "some/path/to/a/directory", false}, - {" some/path/to/a/directory", "some/path/to/a/directory", false}, - // ends with / or - or . or whitepsace - {"some/path/to/a/directory/", "some/path/to/a/directory", false}, - {"some/path/to/a/directory-", "some/path/to/a/directory", false}, - {"some/path/to/a/directory.", "some/path/to/a/directory", false}, - {"some/path/to/a/directory ", "some/path/to/a/directory", false}, - - {"", null, false}, - {"/", null, false}, - - // aggressively - {"some/path/to/a/dire{`~}ctory", "some/path/to/a/dire.ctory", true}, - {"some/path/to/a/directory\\.\\.", "some/path/to/a/directory", true}, - } - ); - } - - @Test - public void testSanitizeFileDirectory() { - assertEquals(expected, StringUtil.sanitizeFileDirectory(inputString, aggressively)); - } + + @ParameterizedTest + @MethodSource("toOptionData") + void testToOption(Optional expected, String inputString) { + assertEquals(expected, StringUtil.toOption(inputString)); + } + + static Stream sanitizeData() { + return Stream.of( + Arguments.of("some\\path\\to\\a\\directory", "some/path/to/a/directory", false), + Arguments.of("some\\//path\\//to\\//a\\//directory", "some/path/to/a/directory", false), + // starts with / or - or . or whitepsace + Arguments.of("/some/path/to/a/directory", "some/path/to/a/directory", false), + Arguments.of("-some/path/to/a/directory", "some/path/to/a/directory", false), + Arguments.of(".some/path/to/a/directory", "some/path/to/a/directory", false), + Arguments.of(" some/path/to/a/directory", "some/path/to/a/directory", false), + // ends with / or - or . or whitepsace + Arguments.of("some/path/to/a/directory/", "some/path/to/a/directory", false), + Arguments.of("some/path/to/a/directory-", "some/path/to/a/directory", false), + Arguments.of("some/path/to/a/directory.", "some/path/to/a/directory", false), + Arguments.of("some/path/to/a/directory ", "some/path/to/a/directory", false), + + Arguments.of("", null, false), + Arguments.of("/", null, false), + + // aggressively + Arguments.of("some/path/to/a/dire{`~}ctory", "some/path/to/a/dire.ctory", true), + Arguments.of("some/path/to/a/directory\\.\\.", "some/path/to/a/directory", true) + ); + } + + @ParameterizedTest + @MethodSource("sanitizeData") + void testSanitizeFileDirectory(String inputString, String expected, boolean aggressively) { + assertEquals(expected, StringUtil.sanitizeFileDirectory(inputString, aggressively)); } public static class StringUtilNoParamTest{ diff --git a/src/test/java/edu/harvard/iq/dataverse/validation/PasswordValidatorUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/validation/PasswordValidatorUtilTest.java index 99d42cbb1ff..c5a38c473fb 100644 --- a/src/test/java/edu/harvard/iq/dataverse/validation/PasswordValidatorUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/validation/PasswordValidatorUtilTest.java @@ -26,7 +26,7 @@ */ public class PasswordValidatorUtilTest { - public static class PasswordValidatorUtilNoParamTest { + static class PasswordValidatorUtilNoParamTest { /** * Test of getPasswordRequirements method, of class PasswordValidatorUtil. */ @@ -76,79 +76,38 @@ public void testParseConfigString() { } - @RunWith(Parameterized.class) - public static class PasswordValidatorUtilParamTest { - - // influences use of # or "each" in text generation - @Parameter(0) - public int numberOfCharacteristics; - - @Parameter(1) - public String characterRulesConfigString; - - @Parameter(2) - public String expectedValue; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { - 2, - null, - "At least 1 character from each of the following types: letter, numeral" - }, - { - 2, - "UpperCase:1,LowerCase:1,Digit:1,Special:1", - "At least 1 character from 2 of the following types: uppercase, lowercase, numeral, special" - }, - { - 4, - "UpperCase:1,LowerCase:1,Digit:1,Special:1", - "At least 1 character from each of the following types: uppercase, lowercase, numeral, special" - }, - - // Should say each, even if more characteristics set than possible - { - 2, - "Digit:1", - "At least 1 character from each of the following types: numeral" - }, - - { - 2, - "Digit:2", - "Fufill 2: At least 2 numeral characters" - }, - { - 2, - "LowerCase:1,Digit:2,Special:3", - "Fufill 2: At least 1 lowercase characters, 2 numeral characters, 3 special characters" - }, - - // letter is mentioned even though that configuration is discouraged - { - 2, - "UpperCase:1,LowerCase:1,Digit:1,Special:1,Alphabetical:1", - "At least 1 character from 2 of the following types: uppercase, lowercase, letter, numeral, special" - } - }); - } - - @Test - public void testGetRequiredCharacters() { - List characterRules; - String message = "Character rules string for "; - if (characterRulesConfigString != null) { - characterRules = PasswordValidatorUtil.getCharacterRules(characterRulesConfigString); - message += characterRulesConfigString; - } else { - characterRules = PasswordValidatorUtil.getCharacterRulesDefault(); - message += "default"; - } - - String reqString = PasswordValidatorUtil.getRequiredCharacters(characterRules, numberOfCharacteristics); - assertEquals(message + ": " + reqString, expectedValue, reqString); + static Stream configurations() { + return Stream.of( + Arguments.of(2, null, + "At least 1 character from each of the following types: letter, numeral"), + Arguments.of(2, "UpperCase:1,LowerCase:1,Digit:1,Special:1", + "At least 1 character from 2 of the following types: uppercase, lowercase, numeral, special"), + Arguments.of(4, "UpperCase:1,LowerCase:1,Digit:1,Special:1", + "At least 1 character from each of the following types: uppercase, lowercase, numeral, special"), + // Should say each, even if more characteristics set than possible + Arguments.of(2, "Digit:1", "At least 1 character from each of the following types: numeral"), + Arguments.of(2, "Digit:2", "Fufill 2: At least 2 numeral characters"), + Arguments.of(2, "LowerCase:1,Digit:2,Special:3", + "Fufill 2: At least 1 lowercase characters, 2 numeral characters, 3 special characters"), + // letter is mentioned even though that configuration is discouraged + Arguments.of(2, "UpperCase:1,LowerCase:1,Digit:1,Special:1,Alphabetical:1", + "At least 1 character from 2 of the following types: uppercase, lowercase, letter, numeral, special") + ); + } + @ParameterizedTest + @MethodSource("configurations") + void testGetRequiredCharacters(int numberOfCharacteristics, String characterRulesConfigString, String expectedValue) { + List characterRules; + String message = "Character rules string for "; + if (characterRulesConfigString != null) { + characterRules = PasswordValidatorUtil.getCharacterRules(characterRulesConfigString); + message += characterRulesConfigString; + } else { + characterRules = PasswordValidatorUtil.getCharacterRulesDefault(); + message += "default"; } + + String reqString = PasswordValidatorUtil.getRequiredCharacters(characterRules, numberOfCharacteristics); + assertEquals(expectedValue, reqString, message + ": " + reqString); } } From ddd0dccfa978f4757f1c4a95306035c26ff8b325 Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Fri, 18 Aug 2023 17:49:55 +0200 Subject: [PATCH 09/17] build(test): migrate JUnit4 temp dir rules to JUnit5 @TempDir #9782 --- .../ingest/IngestableDataCheckerTest.java | 11 ++---- .../util/shapefile/ShapefileHandlerTest.java | 37 ++++--------------- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/src/test/java/edu/harvard/iq/dataverse/ingest/IngestableDataCheckerTest.java b/src/test/java/edu/harvard/iq/dataverse/ingest/IngestableDataCheckerTest.java index 8bff81e7c87..11257f188fe 100644 --- a/src/test/java/edu/harvard/iq/dataverse/ingest/IngestableDataCheckerTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/ingest/IngestableDataCheckerTest.java @@ -29,9 +29,6 @@ */ public class IngestableDataCheckerTest { - @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(); - public IngestableDataCheckerTest() { } @@ -60,14 +57,14 @@ private File createTempFile(String filename, String fileContents) throws IOExcep if (filename == null){ return null; } - File fh = this.tempFolder.newFile(filename); - fh.createNewFile(); + + Path tmpFile = Files.createTempFile("ingestdatachecker", ""); if (fileContents != null){ - FileUtils.writeStringToFile(fh, fileContents); + Files.writeString(tmpFile, fileContents, StandardCharsets.UTF_8); } - return fh; + return tmpFile.toFile(); } private MappedByteBuffer createTempFileAndGetBuffer(String filename, String fileContents) throws IOException { diff --git a/src/test/java/edu/harvard/iq/dataverse/util/shapefile/ShapefileHandlerTest.java b/src/test/java/edu/harvard/iq/dataverse/util/shapefile/ShapefileHandlerTest.java index 568cec3a9a9..482981264c4 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/shapefile/ShapefileHandlerTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/shapefile/ShapefileHandlerTest.java @@ -42,10 +42,8 @@ */ public class ShapefileHandlerTest { - - @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(); - + @TempDir + Path tempFolder; public void msg(String s){ System.out.println(s); @@ -63,28 +61,9 @@ private File createBlankFile(String filename) throws IOException { if (filename == null){ return null; } - File aFile = this.tempFolder.newFile(filename); - // FileUtils.writeStringToFile(tempFile, "hello world"); - - aFile.createNewFile(); - return aFile; + return Files.createFile(tempFolder.resolve(filename)).toFile(); } - - - - private void showFilesInFolder(String m, String folder_name) throws IOException{ - msgt(m); - File folder = new File(folder_name); - for (File f : folder.listFiles() ){ - this.msg("fname: " + f.getCanonicalPath()); - } - } - - private void showFilesInTempFolder(String m) throws IOException{ - this.showFilesInFolder(m, this.tempFolder.getRoot().getAbsolutePath()); - } - private FileInputStream createZipReturnFilestream(List file_names, String zipfile_name) throws IOException{ File zip_file_obj = this.createAndZipFiles(file_names, zipfile_name); @@ -118,8 +97,8 @@ private File createAndZipFiles(List file_names, String zipfile_name) thr //msg("File created: " + file_obj.getName()); } - File zip_file_obj = this.tempFolder.newFile(zipfile_name); - ZipOutputStream zip_stream = new ZipOutputStream(new FileOutputStream(zip_file_obj)); + Path zip_file_obj = this.tempFolder.resolve(zipfile_name); + ZipOutputStream zip_stream = new ZipOutputStream(new FileOutputStream(zip_file_obj.toFile())); // Iterate through File objects and add them to the ZipOutputStream for (File file_obj : fileCollection) { @@ -133,7 +112,7 @@ private File createAndZipFiles(List file_names, String zipfile_name) thr file_obj.delete(); } - return zip_file_obj; + return zip_file_obj.toFile(); } // end createAndZipFiles @@ -211,7 +190,7 @@ public void testZippedTwoShapefiles() throws IOException{ // Rezip/Reorder the files - File test_unzip_folder = this.tempFolder.newFolder("test_unzip").getAbsoluteFile(); + File test_unzip_folder = Files.createDirectory(this.tempFolder.resolve("test_unzip")).toFile(); //File test_unzip_folder = new File("/Users/rmp553/Desktop/blah"); shp_handler.rezipShapefileSets(new FileInputStream(zipfile_obj), test_unzip_folder ); @@ -258,7 +237,7 @@ public void testZippedShapefileWithExtraFiles() throws IOException{ assertEquals("verify value of key 'README'", file_groups.get("README"), Arrays.asList("md")); assertEquals("verify value of key 'shape_notes'", file_groups.get("shape_notes"), Arrays.asList("txt")); - File unzip2Folder = this.tempFolder.newFolder("test_unzip2").getAbsoluteFile(); + File unzip2Folder = Files.createDirectory(this.tempFolder.resolve("test_unzip2")).toFile(); // Rezip/Reorder the files shp_handler.rezipShapefileSets(new FileInputStream(zipfile_obj), unzip2Folder); //shp_handler.rezipShapefileSets(new FileInputStream(zipfile_obj), new File("/Users/rmp553/Desktop/blah")); From 9b8dc3d09581e3b7244cbe150565476f261271c1 Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Fri, 18 Aug 2023 17:56:11 +0200 Subject: [PATCH 10/17] build(test): migrate JUnit4 assertion arguments order to JUnit5 style, simplify where reasonable #9782 --- .../dataverse/DatasetFieldValidatorTest.java | 5 +- .../edu/harvard/iq/dataverse/DatasetTest.java | 18 +++--- .../harvard/iq/dataverse/api/AccessIT.java | 10 ++-- .../edu/harvard/iq/dataverse/api/AdminIT.java | 2 +- .../iq/dataverse/api/AuxiliaryFilesIT.java | 2 +- .../harvard/iq/dataverse/api/DatasetsIT.java | 14 ++--- .../iq/dataverse/api/DownloadFilesIT.java | 2 +- .../harvard/iq/dataverse/api/EditDDIIT.java | 2 +- .../iq/dataverse/api/ExternalToolsIT.java | 2 +- .../edu/harvard/iq/dataverse/api/FilesIT.java | 16 +++--- .../iq/dataverse/api/HarvestingClientsIT.java | 2 +- .../iq/dataverse/api/HarvestingServerIT.java | 48 +++++++--------- .../iq/dataverse/api/InReviewWorkflowIT.java | 2 +- .../harvard/iq/dataverse/api/SearchIT.java | 4 +- .../edu/harvard/iq/dataverse/api/SwordIT.java | 4 +- .../harvard/iq/dataverse/api/TabularIT.java | 2 +- .../edu/harvard/iq/dataverse/api/UsersIT.java | 2 +- .../groups/GroupServiceBeanTest.java | 4 +- .../impl/ipaddress/ip/IPv6AddressTest.java | 48 ++++++++-------- .../impl/ipaddress/ip/IpAddressRangeTest.java | 2 +- .../users/AuthenticatedUserTest.java | 20 +++---- .../impl/CreateDataverseCommandTest.java | 4 +- .../command/impl/CreateRoleCommandTest.java | 2 +- ...estPublishedDatasetVersionCommandTest.java | 12 ++-- .../externaltools/ExternalToolTest.java | 14 ++--- .../impl/plugins/csv/CSVFileReaderTest.java | 20 +++---- .../harvard/iq/dataverse/util/BitSetTest.java | 8 +-- .../iq/dataverse/util/LruCacheTest.java | 18 +++--- .../dataverse/util/json/JsonParserTest.java | 6 +- .../util/shapefile/ShapefileHandlerTest.java | 56 +++++++++---------- 30 files changed, 167 insertions(+), 184 deletions(-) diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetFieldValidatorTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetFieldValidatorTest.java index e9296b431dc..659e42a68c4 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DatasetFieldValidatorTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DatasetFieldValidatorTest.java @@ -45,6 +45,7 @@ public void tearDown() { /** * Test of isValid method, of class DatasetFieldValidator. + * TODO: this should be converted into one or two ParameterizedTest methods, potentially including a DisplayNameGenerator */ @Test public void testIsValid() { @@ -85,7 +86,7 @@ private void testPrimitiveDatasetField(String test, boolean required, String val testDatasetField.setSingleValue(value); DatasetFieldValidator datasetFieldValidator = new DatasetFieldValidator(); - assertEquals( test, expectedOutcome, datasetFieldValidator.isValid(testDatasetField, constraintValidatorContext)); + assertEquals(expectedOutcome, datasetFieldValidator.isValid(testDatasetField, constraintValidatorContext), test); } @@ -121,7 +122,7 @@ private void testCompoundDatasetField(String test, boolean requiredParent, boole DatasetFieldValidator datasetFieldValidator = new DatasetFieldValidator(); - assertEquals( test, expectedOutcome, datasetFieldValidator.isValid(child1DatasetField, constraintValidatorContext)); + assertEquals(expectedOutcome, datasetFieldValidator.isValid(child1DatasetField, constraintValidatorContext), test); } @Test diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetTest.java index cd5186e6a87..2153a336303 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DatasetTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DatasetTest.java @@ -24,38 +24,38 @@ public class DatasetTest { @Test public void testIsLockedFor() { Dataset sut = new Dataset(); - assertFalse( "Initially verify that the dataset is not locked because data being ingested", sut.isLockedFor(DatasetLock.Reason.Ingest) ); + assertFalse(sut.isLockedFor(DatasetLock.Reason.Ingest), "Initially verify that the dataset is not locked because data being ingested"); DatasetLock dl = new DatasetLock(DatasetLock.Reason.Ingest, MocksFactory.makeAuthenticatedUser("jane", "doe")); sut.addLock(dl); - assertTrue( "Verify that the dataset now has an ingest lock", sut.isLockedFor(DatasetLock.Reason.Ingest) ); - assertFalse( "Verify that the dataset does not have a workflow lock", sut.isLockedFor(DatasetLock.Reason.Workflow) ); + assertTrue(sut.isLockedFor(DatasetLock.Reason.Ingest), "Verify that the dataset now has an ingest lock"); + assertFalse(sut.isLockedFor(DatasetLock.Reason.Workflow), "Verify that the dataset does not have a workflow lock"); } @Test public void testLocksManagement() { Dataset sut = new Dataset(); - assertFalse( "Initially verify that the dataset is not locked", sut.isLocked() ); + assertFalse(sut.isLocked(), "Initially verify that the dataset is not locked"); DatasetLock dlIngest = new DatasetLock(DatasetLock.Reason.Ingest, MocksFactory.makeAuthenticatedUser("jane", "doe")); dlIngest.setId(MocksFactory.nextId()); sut.addLock(dlIngest); - assertTrue( "After adding an ingest lock, verify that the dataset is locked", sut.isLocked() ); + assertTrue(sut.isLocked(), "After adding an ingest lock, verify that the dataset is locked"); final DatasetLock dlInReview = new DatasetLock(DatasetLock.Reason.InReview, MocksFactory.makeAuthenticatedUser("jane", "doe")); dlInReview.setId(MocksFactory.nextId()); sut.addLock(dlInReview); - assertEquals( "After adding a review lock, verify that the dataset is locked by two locks", 2, sut.getLocks().size() ); + assertEquals(2, sut.getLocks().size(), "After adding a review lock, verify that the dataset is locked by two locks"); DatasetLock retrievedDl = sut.getLockFor(DatasetLock.Reason.Ingest); assertEquals( dlIngest, retrievedDl ); sut.removeLock(dlIngest); - assertNull( "After removing the ingest lock, verify that the dataset does not have any ingest locks", sut.getLockFor(DatasetLock.Reason.Ingest) ); + assertNull(sut.getLockFor(DatasetLock.Reason.Ingest), "After removing the ingest lock, verify that the dataset does not have any ingest locks"); - assertTrue( "After removing the ingest lock, verify that the dataset is still locked (review lock)", sut.isLocked() ); + assertTrue(sut.isLocked(), "After removing the ingest lock, verify that the dataset is still locked (review lock)"); sut.removeLock(dlInReview); - assertFalse( "After removing the review lock, verify that the dataset is not locked anymore", sut.isLocked() ); + assertFalse(sut.isLocked(), "After removing the review lock, verify that the dataset is not locked anymore"); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java b/src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java index c3a0de04c8d..eab49e33d5c 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java @@ -124,7 +124,7 @@ public static void setUp() throws InterruptedException { tabFile2NameConvert = tabFile2Name.substring(0, tabFile2Name.indexOf(".dta")) + ".tab"; String tab2PathToFile = "scripts/search/data/tabular/" + tabFile2Name; - assertTrue("Failed test if Ingest Lock exceeds max duration " + tabFile2Name, UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + tabFile2Name); Response tab2AddResponse = UtilIT.uploadFileViaNative(datasetId.toString(), tab2PathToFile, apiToken); tabFile2Id = JsonPath.from(tab2AddResponse.body().asString()).getInt("data.files[0].dataFile.id"); @@ -133,13 +133,13 @@ public static void setUp() throws InterruptedException { tabFile3NameRestrictedConvert = tabFile3NameRestricted.substring(0, tabFile3NameRestricted.indexOf(".dta")) + ".tab"; String tab3PathToFile = "scripts/search/data/tabular/" + tabFile3NameRestricted; - assertTrue("Failed test if Ingest Lock exceeds max duration " + tabFile3NameRestricted , UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + tabFile3NameRestricted); Response tab3AddResponse = UtilIT.uploadFileViaNative(datasetId.toString(), tab3PathToFile, apiToken); tabFile3IdRestricted = JsonPath.from(tab3AddResponse.body().asString()).getInt("data.files[0].dataFile.id"); - assertTrue("Failed test if Ingest Lock exceeds max duration " + tabFile3NameRestricted , UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + tabFile3NameRestricted); Response restrictResponse = UtilIT.restrictFile(tabFile3IdRestricted.toString(), true, apiToken); restrictResponse.prettyPrint(); @@ -158,7 +158,7 @@ public static void setUp() throws InterruptedException { String tab4PathToFile = "scripts/search/data/tabular/" + tabFile4NameUnpublished; Response tab4AddResponse = UtilIT.uploadFileViaNative(datasetId.toString(), tab4PathToFile, apiToken); tabFile4IdUnpublished = JsonPath.from(tab4AddResponse.body().asString()).getInt("data.files[0].dataFile.id"); - assertTrue("Failed test if Ingest Lock exceeds max duration " + tabFile2Name, UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + tabFile2Name); } @@ -484,7 +484,7 @@ public void testRequestAccess() throws InterruptedException { Response tab3AddResponse = UtilIT.uploadFileViaNative(datasetIdNew.toString(), tab3PathToFile, apiToken); Integer tabFile3IdRestrictedNew = JsonPath.from(tab3AddResponse.body().asString()).getInt("data.files[0].dataFile.id"); - assertTrue("Failed test if Ingest Lock exceeds max duration " + tab3PathToFile , UtilIT.sleepForLock(datasetIdNew.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetIdNew.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + tab3PathToFile); Response restrictResponse = UtilIT.restrictFile(tabFile3IdRestrictedNew.toString(), true, apiToken); restrictResponse.prettyPrint(); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/AdminIT.java b/src/test/java/edu/harvard/iq/dataverse/api/AdminIT.java index 7f3a6d70252..3685627df3d 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/AdminIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/AdminIT.java @@ -605,7 +605,7 @@ public void testRecalculateDataFileHash() { String superuserUsername = UtilIT.getUsernameFromResponse(createSuperuser); UtilIT.makeSuperUser(superuserUsername); - assertTrue("Failed test if Ingest Lock exceeds max duration " + origFileId, UtilIT.sleepForLock(datasetId.longValue(), "Ingest", superuserApiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", superuserApiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + origFileId); //Bad file id Response computeDataFileHashResponse = UtilIT.computeDataFileHashValue("BadFileId", DataFile.ChecksumType.MD5.toString(), superuserApiToken); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/AuxiliaryFilesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/AuxiliaryFilesIT.java index 3c77be56810..5f32d655f4f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/AuxiliaryFilesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/AuxiliaryFilesIT.java @@ -62,7 +62,7 @@ public void testUploadAuxFiles() throws IOException { Long fileId = JsonPath.from(uploadFile.body().asString()).getLong("data.files[0].dataFile.id"); - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToDataFile, UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToDataFile); Response restrictFile = UtilIT.restrictFile(fileId.toString(), true, apiToken); restrictFile.prettyPrint(); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java index 990bac7cfe0..c03a1cc0935 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java @@ -1970,7 +1970,7 @@ public void testDatasetLocksApi() { break; } } - assertTrue("Lock missing from the output of /api/datasets/locks", lockListedCorrectly); + assertTrue(lockListedCorrectly, "Lock missing from the output of /api/datasets/locks"); // Try the same, but with an api token of a random, non-super user // (this should get rejected): @@ -2000,7 +2000,7 @@ public void testDatasetLocksApi() { break; } } - assertTrue("Lock missing from the output of /api/datasets/locks?type=Ingest", lockListedCorrectly); + assertTrue(lockListedCorrectly, "Lock missing from the output of /api/datasets/locks?type=Ingest"); // Try to list locks of an invalid type: @@ -2314,7 +2314,7 @@ public void testUnrestrictedFileExportDdi() throws IOException { String fileId = JsonPath.from(uploadFile.body().asString()).getString("data.files[0].dataFile.id"); - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFile, UtilIT.sleepForLock(datasetId.longValue(), "Ingest", authorApiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", authorApiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToFile); Response publishDataverse = UtilIT.publishDataverseViaNativeApi(dataverseAlias, authorApiToken); publishDataverse.then().assertThat().statusCode(OK.getStatusCode()); @@ -2386,7 +2386,7 @@ public void testRestrictFileExportDdi() throws IOException { String fileId = JsonPath.from(uploadFile.body().asString()).getString("data.files[0].dataFile.id"); - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFile, UtilIT.sleepForLock(datasetId.longValue(), "Ingest", authorApiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", authorApiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToFile); Response restrictFile = UtilIT.restrictFile(fileId, true, authorApiToken); restrictFile.prettyPrint(); @@ -2804,7 +2804,7 @@ public void testCuratePublishedDatasetVersionCommand() throws IOException { // Give file time to ingest - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFileThatGoesThroughIngest , UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToFileThatGoesThroughIngest); Response origXml = UtilIT.getFileMetadata(origFileId, null, apiToken); assertEquals(200, origXml.getStatusCode()); @@ -2944,7 +2944,7 @@ public void testRestrictFileTermsOfUseAndAccess() throws IOException { String fileId = JsonPath.from(uploadFile.body().asString()).getString("data.files[0].dataFile.id"); - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFile, UtilIT.sleepForLock(datasetId.longValue(), "Ingest", authorApiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", authorApiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToFile); Response restrictFile = UtilIT.restrictFile(fileId, true, authorApiToken); restrictFile.prettyPrint(); @@ -3014,7 +3014,7 @@ public void testRestrictFilesWORequestAccess() throws IOException { String fileId = JsonPath.from(uploadFile.body().asString()).getString("data.files[0].dataFile.id"); - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFile, UtilIT.sleepForLock(datasetId.longValue(), "Ingest", authorApiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", authorApiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToFile); Response restrictFile = UtilIT.restrictFile(fileId, true, authorApiToken); restrictFile.prettyPrint(); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/DownloadFilesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/DownloadFilesIT.java index 0ce93da2666..66281558b5f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/DownloadFilesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/DownloadFilesIT.java @@ -356,7 +356,7 @@ public void downloadAllFilesTabular() throws IOException { .body("data.files[0].label", equalTo("50by1000.dta")); // UtilIT.MAXIMUM_INGEST_LOCK_DURATION is 3 but not long enough. - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFile, UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION + 3)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION + 3), "Failed test if Ingest Lock exceeds max duration " + pathToFile); Response downloadFiles1 = UtilIT.downloadFiles(datasetPid, apiToken); downloadFiles1.then().assertThat() diff --git a/src/test/java/edu/harvard/iq/dataverse/api/EditDDIIT.java b/src/test/java/edu/harvard/iq/dataverse/api/EditDDIIT.java index d443b22442f..827221dcbb4 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/EditDDIIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/EditDDIIT.java @@ -80,7 +80,7 @@ public void testUpdateVariableMetadata() throws InterruptedException { // Give file time to ingest - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFileThatGoesThroughIngest , UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToFileThatGoesThroughIngest); Response origXml = UtilIT.getFileMetadata(origFileId, null, apiToken); assertEquals(200, origXml.getStatusCode()); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/ExternalToolsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/ExternalToolsIT.java index 3244dffd8a8..b35c6837ae0 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/ExternalToolsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/ExternalToolsIT.java @@ -89,7 +89,7 @@ public void testFileLevelTool1() { uploadTabularFile.then().assertThat() .statusCode(OK.getStatusCode()); - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToTabularFile, UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToTabularFile); Integer tabularFileId = JsonPath.from(uploadTabularFile.getBody().asString()).getInt("data.files[0].dataFile.id"); JsonObjectBuilder job = Json.createObjectBuilder(); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java index 0e7ae69688d..54c44128442 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java @@ -502,7 +502,7 @@ public void test_006_ReplaceFileGoodTabular() throws InterruptedException { // give file time to ingest // sleep(10000); - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFile , UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToFile); Response ddi = UtilIT.getFileMetadata(origFileId.toString(), "ddi", apiToken); // ddi.prettyPrint(); @@ -1203,7 +1203,7 @@ public void testUningestFileViaApi() throws InterruptedException { assertNotNull(origFileId); // If checkOut fails, display message // sleep(10000); - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFile , UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToFile); Response uningestFileResponse = UtilIT.uningestFile(origFileId, apiToken); assertEquals(200, uningestFileResponse.getStatusCode()); } @@ -1237,7 +1237,7 @@ public void testFileMetaDataGetUpdateRoundTrip() throws InterruptedException { Long origFileId = JsonPath.from(addResponse.body().asString()).getLong("data.files[0].dataFile.id"); //sleep(2000); //ensure tsv is consumed - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFile , UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToFile); msg("Publish dataverse and dataset"); Response publishDataversetResp = UtilIT.publishDataverseViaSword(dataverseAlias, apiToken); publishDataversetResp.then().assertThat() @@ -1335,7 +1335,7 @@ public void testDataSizeInDataverse() throws InterruptedException { .statusCode(OK.getStatusCode()); // wait for it to ingest... - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFile , UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, 5)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, 5), "Failed test if Ingest Lock exceeds max duration " + pathToFile); // sleep(10000); Response publishDataversetResp = UtilIT.publishDataverseViaSword(dataverseAlias, apiToken); @@ -1477,7 +1477,7 @@ public void testValidateDDI_issue6027() throws InterruptedException { .statusCode(OK.getStatusCode()); // give file time to ingest - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFile , UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToFile); // sleep(10000); Response ddi = UtilIT.getFileMetadata(origFileId.toString(), "ddi", apiToken); @@ -1732,7 +1732,7 @@ public void testRange() throws IOException { Integer fileIdCsv = JsonPath.from(uploadFileCsv.body().asString()).getInt("data.files[0].dataFile.id"); - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToCsv, UtilIT.sleepForLock(datasetId.longValue(), "Ingest", authorApiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", authorApiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToCsv); // Just the tabular file, not the original, no byte range. Vanilla. Response downloadFileNoArgs = UtilIT.downloadFile(fileIdCsv, null, null, null, authorApiToken); @@ -1865,7 +1865,7 @@ public void testAddFileToDatasetSkipTabIngest() throws IOException, InterruptedE logger.info(r.prettyPrint()); assertEquals(200, r.getStatusCode()); - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFile, UtilIT.sleepForLock(datasetIdInt, "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetIdInt, "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToFile); Long dataFileId = JsonPath.from(r.body().asString()).getLong("data.files[0].dataFile.id"); Response fileMeta = UtilIT.getDataFileMetadataDraft(dataFileId, apiToken); @@ -1878,7 +1878,7 @@ public void testAddFileToDatasetSkipTabIngest() throws IOException, InterruptedE logger.info(rTabIngest.prettyPrint()); assertEquals(200, rTabIngest.getStatusCode()); - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFile, UtilIT.sleepForLock(datasetIdInt, "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetIdInt, "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToFile); Long ingDataFileId = JsonPath.from(rTabIngest.body().asString()).getLong("data.files[0].dataFile.id"); Response ingFileMeta = UtilIT.getDataFileMetadataDraft(ingDataFileId, apiToken); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/HarvestingClientsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/HarvestingClientsIT.java index 9c9022a95dd..67d8e8dd668 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/HarvestingClientsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/HarvestingClientsIT.java @@ -214,7 +214,7 @@ public void testHarvestingClientRun() throws InterruptedException { assertEquals(OK.getStatusCode(), getClientResponse.getStatusCode()); JsonPath responseJsonPath = getClientResponse.body().jsonPath(); - assertNotNull("Invalid JSON in GET client response", responseJsonPath); + assertNotNull(responseJsonPath, "Invalid JSON in GET client response"); assertEquals(ApiConstants.STATUS_OK, responseJsonPath.getString("status")); String clientStatus = responseJsonPath.getString("data.status"); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/HarvestingServerIT.java b/src/test/java/edu/harvard/iq/dataverse/api/HarvestingServerIT.java index 174f6a63da7..4f84f47af69 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/HarvestingServerIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/HarvestingServerIT.java @@ -376,10 +376,10 @@ public void testSetEditAPIandOAIlistSets() { List listSets = responseXmlPath.getList("OAI-PMH.ListSets.set.list().findAll{it.setName=='"+setName+"'}", Node.class); // 2a. Confirm that our set is listed: - assertNotNull("Unexpected response from ListSets", listSets); - assertTrue("Newly-created set isn't properly listed by the OAI server", listSets.size() == 1); + assertNotNull(listSets, "Unexpected response from ListSets"); + assertEquals(1, listSets.size(), "Newly-created set isn't properly listed by the OAI server"); // 2b. Confirm that the set entry contains the updated description: - assertEquals("Incorrect description in the ListSets entry", newDescription, listSets.get(0).getPath("setDescription.metadata.element.field", String.class)); + assertEquals(newDescription, listSets.get(0).getPath("setDescription.metadata.element.field", String.class), "Incorrect description in the ListSets entry"); // ok, the xml record looks good! @@ -606,12 +606,11 @@ public void testMultiRecordOaiSet() throws InterruptedException { // Validate the payload of the ListIdentifiers response: // 1a) There should be 2 items listed: - assertEquals("Wrong number of items on the first ListIdentifiers page", - 2, ret.size()); + assertEquals(2, ret.size(), "Wrong number of items on the first ListIdentifiers page"); // 1b) The response contains a resumptionToken for the next page of items: String resumptionToken = responseXmlPath.getString("OAI-PMH.ListIdentifiers.resumptionToken"); - assertNotNull("No resumption token in the ListIdentifiers response (has the jvm option dataverse.oai.server.maxidentifiers been configured?)", resumptionToken); + assertNotNull(resumptionToken, "No resumption token in the ListIdentifiers response (has the jvm option dataverse.oai.server.maxidentifiers been configured?)"); // 1c) The total number of items in the set (5) is listed correctly: assertEquals(5, responseXmlPath.getInt("OAI-PMH.ListIdentifiers.resumptionToken.@completeListSize")); @@ -653,12 +652,11 @@ public void testMultiRecordOaiSet() throws InterruptedException { // Validate the payload of the ListIdentifiers response: // 2a) There should still be 2 items listed: - assertEquals("Wrong number of items on the second ListIdentifiers page", - 2, ret.size()); + assertEquals(2, ret.size(), "Wrong number of items on the second ListIdentifiers page"); // 2b) The response should contain a resumptionToken for the next page of items: resumptionToken = responseXmlPath.getString("OAI-PMH.ListIdentifiers.resumptionToken"); - assertNotNull("No resumption token in the ListIdentifiers response", resumptionToken); + assertNotNull(resumptionToken, "No resumption token in the ListIdentifiers response"); // 2c) The total number of items in the set (5) is listed correctly: assertEquals(5, responseXmlPath.getInt("OAI-PMH.ListIdentifiers.resumptionToken.@completeListSize")); @@ -693,13 +691,12 @@ public void testMultiRecordOaiSet() throws InterruptedException { // Validate the payload of the ListIdentifiers response: // 3a) There should be only 1 item listed: - assertEquals("Wrong number of items on the final ListIdentifiers page", - 1, ret.size()); + assertEquals(1, ret.size(), "Wrong number of items on the final ListIdentifiers page"); // 3b) The response contains a resumptionToken for the next page of items: resumptionToken = responseXmlPath.getString("OAI-PMH.ListIdentifiers.resumptionToken"); - assertNotNull("No resumption token in the final ListIdentifiers response", resumptionToken); - assertTrue("Non-empty resumption token in the final ListIdentifiers response", "".equals(resumptionToken)); + assertNotNull(resumptionToken, "No resumption token in the final ListIdentifiers response"); + assertEquals("", resumptionToken, "Non-empty resumption token in the final ListIdentifiers response"); // 3c) The total number of items in the set (5) is still listed correctly: assertEquals(5, responseXmlPath.getInt("OAI-PMH.ListIdentifiers.resumptionToken.@completeListSize")); @@ -720,8 +717,7 @@ public void testMultiRecordOaiSet() throws InterruptedException { allDatasetsListed = allDatasetsListed && persistentIdsInListIdentifiers.contains(persistentId); } - assertTrue("Control datasets not properly listed in the paged ListIdentifiers response", - allDatasetsListed); + assertTrue(allDatasetsListed, "Control datasets not properly listed in the paged ListIdentifiers response"); // OK, it is safe to assume ListIdentifiers works as it should in page mode. @@ -746,12 +742,11 @@ public void testMultiRecordOaiSet() throws InterruptedException { // Validate the payload of the ListRecords response: // 4a) There should be 2 items listed: - assertEquals("Wrong number of items on the first ListRecords page", - 2, ret.size()); + assertEquals(2, ret.size(), "Wrong number of items on the first ListRecords page"); // 4b) The response contains a resumptionToken for the next page of items: resumptionToken = responseXmlPath.getString("OAI-PMH.ListRecords.resumptionToken"); - assertNotNull("No resumption token in the ListRecords response (has the jvm option dataverse.oai.server.maxrecords been configured?)", resumptionToken); + assertNotNull(resumptionToken, "No resumption token in the ListRecords response (has the jvm option dataverse.oai.server.maxrecords been configured?)"); // 4c) The total number of items in the set (5) is listed correctly: assertEquals(5, responseXmlPath.getInt("OAI-PMH.ListRecords.resumptionToken.@completeListSize")); @@ -787,12 +782,11 @@ public void testMultiRecordOaiSet() throws InterruptedException { // Validate the payload of the ListRecords response: // 4a) There should still be 2 items listed: - assertEquals("Wrong number of items on the second ListRecords page", - 2, ret.size()); + assertEquals(2, ret.size(), "Wrong number of items on the second ListRecords page"); // 4b) The response should contain a resumptionToken for the next page of items: resumptionToken = responseXmlPath.getString("OAI-PMH.ListRecords.resumptionToken"); - assertNotNull("No resumption token in the ListRecords response", resumptionToken); + assertNotNull(resumptionToken, "No resumption token in the ListRecords response"); // 4c) The total number of items in the set (5) is listed correctly: assertEquals(5, responseXmlPath.getInt("OAI-PMH.ListRecords.resumptionToken.@completeListSize")); @@ -827,13 +821,12 @@ public void testMultiRecordOaiSet() throws InterruptedException { // Validate the payload of the ListRecords response: // 6a) There should be only 1 item listed: - assertEquals("Wrong number of items on the final ListRecords page", - 1, ret.size()); + assertEquals(1, ret.size(), "Wrong number of items on the final ListRecords page"); // 6b) The response contains a resumptionToken for the next page of items: resumptionToken = responseXmlPath.getString("OAI-PMH.ListRecords.resumptionToken"); - assertNotNull("No resumption token in the final ListRecords response", resumptionToken); - assertTrue("Non-empty resumption token in the final ListRecords response", "".equals(resumptionToken)); + assertNotNull(resumptionToken, "No resumption token in the final ListRecords response"); + assertEquals("", resumptionToken, "Non-empty resumption token in the final ListRecords response"); // 6c) The total number of items in the set (5) is still listed correctly: assertEquals(5, responseXmlPath.getInt("OAI-PMH.ListRecords.resumptionToken.@completeListSize")); @@ -854,8 +847,7 @@ public void testMultiRecordOaiSet() throws InterruptedException { allDatasetsListed = allDatasetsListed && persistentIdsInListRecords.contains(persistentId); } - assertTrue("Control datasets not properly listed in the paged ListRecords response", - allDatasetsListed); + assertTrue(allDatasetsListed, "Control datasets not properly listed in the paged ListRecords response"); // OK, it is safe to assume ListRecords works as it should in page mode // as well. @@ -866,7 +858,7 @@ public void testMultiRecordOaiSet() throws InterruptedException { .header(UtilIT.API_TOKEN_HTTP_HEADER, adminUserAPIKey) .delete(setPath); logger.info("deleteResponse.getStatusCode(): " + deleteResponse.getStatusCode()); - assertEquals("Failed to delete the control multi-record set", 200, deleteResponse.getStatusCode()); + assertEquals(200, deleteResponse.getStatusCode(), "Failed to delete the control multi-record set"); } // TODO: diff --git a/src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java b/src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java index 736aadd9931..020a9e5dff3 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/InReviewWorkflowIT.java @@ -237,7 +237,7 @@ public void testCuratorSendsCommentsToAuthor() throws InterruptedException { // because the dataset is still locked when we try to edit it, // a few lines down. -- L.A. Oct. 2018 // Changes to test for ingest lock and 3 seconds duration SEK 09/2019 #6128 - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFileThatGoesThroughIngest , UtilIT.sleepForLock(datasetId, "Ingest", curatorApiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId, "Ingest", curatorApiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToFileThatGoesThroughIngest); // Thread.sleep(10000); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java b/src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java index 18c3b3a318e..7d335bc39f3 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java @@ -105,7 +105,7 @@ public void testSearchPermisions() throws InterruptedException { assertEquals(200, grantUser2AccessOnDataset.getStatusCode()); String searchPart = "id:dataset_" + datasetId1 + "_draft"; - assertTrue("Failed test if search exceeds max duration " + searchPart , UtilIT.sleepForSearch(searchPart, apiToken2, "", UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForSearch(searchPart, apiToken2, "", UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if search exceeds max duration " + searchPart); Response shouldBeVisibleToUser2 = UtilIT.search("id:dataset_" + datasetId1 + "_draft", apiToken2); shouldBeVisibleToUser2.prettyPrint(); @@ -915,7 +915,7 @@ public void testCuratorCardDataversePopulation() throws InterruptedException { String searchPart = "*"; Response searchPublishedSubtreeSuper = UtilIT.search(searchPart, apiTokenSuper, "&subtree="+parentDataverseAlias); - assertTrue("Failed test if search exceeds max duration " + searchPart , UtilIT.sleepForSearch(searchPart, apiToken, "&subtree="+parentDataverseAlias, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForSearch(searchPart, apiToken, "&subtree="+parentDataverseAlias, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if search exceeds max duration " + searchPart); searchPublishedSubtreeSuper.prettyPrint(); searchPublishedSubtreeSuper.then().assertThat() .statusCode(OK.getStatusCode()) diff --git a/src/test/java/edu/harvard/iq/dataverse/api/SwordIT.java b/src/test/java/edu/harvard/iq/dataverse/api/SwordIT.java index 686670d8b3e..9a059e7e6ee 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/SwordIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/SwordIT.java @@ -73,7 +73,7 @@ public static void setUpClass() { Response checkRootDataverse = UtilIT.listDatasetsViaSword(rootDataverseAlias, apitoken); //checkRootDataverse.prettyPrint(); checkRootDataverse.then().assertThat().statusCode(OK.getStatusCode()); - assumeTrue(rootDvNotPublished, checkRootDataverse.getBody().xmlPath().getBoolean("feed.dataverseHasBeenReleased")); + assumeTrue(checkRootDataverse.getBody().xmlPath().getBoolean("feed.dataverseHasBeenReleased"), rootDvNotPublished); // check that root dataverse has permissions for any user set to dataverse + dataset creator (not admin, not curator!) checkRootDataverse = UtilIT.getRoleAssignmentsOnDataverse(rootDataverseAlias, apiTokenSuperuser); @@ -88,7 +88,7 @@ public static void setUpClass() { break; } } - assumeTrue(rootDvLackPermissions, properPermissionsSet); + assumeTrue(properPermissionsSet, rootDvLackPermissions); } diff --git a/src/test/java/edu/harvard/iq/dataverse/api/TabularIT.java b/src/test/java/edu/harvard/iq/dataverse/api/TabularIT.java index 1a5e3a7e7f0..28b2ac59ac4 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/TabularIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/TabularIT.java @@ -61,7 +61,7 @@ public void testTabularFile() throws InterruptedException { // Give file time to ingest - assertTrue("Failed test if Ingest Lock exceeds max duration " + pathToFileThatGoesThroughIngest , UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetId.longValue(), "Ingest", apiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + pathToFileThatGoesThroughIngest); // Thread.sleep(10000); Response fileMetadataNoFormat = UtilIT.getFileMetadata(fileIdAsString, null, apiToken); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/UsersIT.java b/src/test/java/edu/harvard/iq/dataverse/api/UsersIT.java index be1ea5b9fd6..e1696cdce4f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/UsersIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/UsersIT.java @@ -162,7 +162,7 @@ public void testMergeAccounts(){ Integer tabFile3IdRestrictedNew = JsonPath.from(tab3AddResponse.body().asString()).getInt("data.files[0].dataFile.id"); //Sleep while dataset locked for ingest - assertTrue("Failed test if Ingest Lock exceeds max duration " + tabFile3NameRestrictedNew , UtilIT.sleepForLock(datasetIdNew.longValue(), "Ingest", superuserApiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION)); + assertTrue(UtilIT.sleepForLock(datasetIdNew.longValue(), "Ingest", superuserApiToken, UtilIT.MAXIMUM_INGEST_LOCK_DURATION), "Failed test if Ingest Lock exceeds max duration " + tabFile3NameRestrictedNew); Response restrictResponse = UtilIT.restrictFile(tabFile3IdRestrictedNew.toString(), true, superuserApiToken); restrictResponse.prettyPrint(); diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/GroupServiceBeanTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/GroupServiceBeanTest.java index 7c0c09d6f39..27927c33420 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/GroupServiceBeanTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/GroupServiceBeanTest.java @@ -64,10 +64,10 @@ public void testFlattenGroupsCollection() throws GroupException { List result = sut.flattenGroupsCollection(grps).collect(toList()); - assertEquals( "Groups should appear only once", result.size(), new HashSet<>(result).size() ); + assertEquals(result.size(), new HashSet<>(result).size(), "Groups should appear only once"); grps.addAll( listOf(gAa, gAb, gAstar, AuthenticatedUsers.get()) ); - assertEquals( "All groups should appear", grps, new HashSet<>(result) ); + assertEquals(grps, new HashSet<>(result), "All groups should appear"); } diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv6AddressTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv6AddressTest.java index 2f43bc64ce8..77618e558ec 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv6AddressTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IPv6AddressTest.java @@ -38,15 +38,15 @@ public void testValueOfWithExpansion() { int[] expected = new int[]{0x2001, 0xdb8, 0x85a3, 0x0, 0, 0x8a2e, 0x370, 0x7334}; IPv6Address adr = IPv6Address.valueOf("2001:db8:85a3::8a2e:370:7334"); for (int i = 0; i < 8; i++) { - assertEquals("At index " + i + ": expecting " + expected[i] + ", got " + adr.get(i), - expected[i], adr.get(i)); + assertEquals(expected[i], adr.get(i), + "At index " + i + ": expecting " + expected[i] + ", got " + adr.get(i)); } expected = new int[]{0x2001, 0xdb8, 0x0, 0x0, 0x0, 0x0, 0x370, 0x7334}; adr = IPv6Address.valueOf("2001:db8::370:7334"); for (int i = 0; i < 8; i++) { - assertEquals("At index " + i + ": expecting " + expected[i] + ", got " + adr.get(i), - expected[i], adr.get(i)); + assertEquals(expected[i], adr.get(i), + "At index " + i + ": expecting " + expected[i] + ", got " + adr.get(i)); } } @@ -55,16 +55,16 @@ public void testValueOfWithExpansionZerosAtStart() { int[] expected = new int[]{0, 0, 0, 0, 0, 0x8a2e, 0x370, 0x7334}; IPv6Address adr = IPv6Address.valueOf("::8a2e:370:7334"); for (int i = 0; i < 8; i++) { - assertEquals("At index " + i + ": expecting " + expected[i] + ", got " + adr.get(i), - expected[i], adr.get(i)); + assertEquals(expected[i], adr.get(i), + "At index " + i + ": expecting " + expected[i] + ", got " + adr.get(i)); } expected = new int[]{0, 0, 0, 0, 0, 0, 0, 0x7334}; adr = IPv6Address.valueOf("::7334"); System.out.println("adr = " + adr); for (int i = 0; i < 8; i++) { - assertEquals("At index " + i + ": expecting " + expected[i] + ", got " + adr.get(i), - expected[i], adr.get(i)); + assertEquals(expected[i], adr.get(i), + "At index " + i + ": expecting " + expected[i] + ", got " + adr.get(i)); } } @@ -73,15 +73,15 @@ public void testValueOfWithExpansionZerosAtEnd() { int[] expected = new int[]{0x2001, 0x8a2e, 0, 0, 0, 0, 0, 0}; IPv6Address adr = IPv6Address.valueOf("2001:8a2e::"); for (int i = 0; i < 8; i++) { - assertEquals("At index " + i + ": expecting " + expected[i] + ", got " + adr.get(i), - expected[i], adr.get(i)); + assertEquals(expected[i], adr.get(i), + "At index " + i + ": expecting " + expected[i] + ", got " + adr.get(i)); } expected = new int[]{0x1337, 0, 0, 0, 0, 0, 0, 0}; adr = IPv6Address.valueOf("1337::"); for (int i = 0; i < 8; i++) { - assertEquals("At index " + i + ": expecting " + expected[i] + ", got " + adr.get(i), - expected[i], adr.get(i)); + assertEquals(expected[i], adr.get(i), + "At index " + i + ": expecting " + expected[i] + ", got " + adr.get(i)); } } @@ -91,15 +91,15 @@ public void testValueOfWithExpansionSpecialCases() { IPv6Address adr = IPv6Address.valueOf("::"); System.out.println("adr = " + adr); for (int i = 0; i < 8; i++) { - assertEquals("At index " + i + ": expecting " + expected[i] + ", got " + adr.get(i), - expected[i], adr.get(i)); + assertEquals(expected[i], adr.get(i), + "At index " + i + ": expecting " + expected[i] + ", got " + adr.get(i)); } expected = new int[]{0, 0, 0, 0, 0, 0, 0, 1}; adr = IPv6Address.valueOf("::1"); for (int i = 0; i < 8; i++) { - assertEquals("At index " + i + ": expecting " + expected[i] + ", got " + adr.get(i), - expected[i], adr.get(i)); + assertEquals(expected[i], adr.get(i), + "At index " + i + ": expecting " + expected[i] + ", got " + adr.get(i)); } } @@ -151,8 +151,7 @@ public void testLongRoundTrips() { "fe80::8358:c945:7094:2e6c", "fe80::60d0:6eff:fece:7713", "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")) { IPv6Address addr = IPv6Address.valueOf(s); - assertEquals("Bad roundtrip on address: " + s, - addr, new IPv6Address(addr.toLongArray())); + assertEquals(addr, new IPv6Address(addr.toLongArray()), "Bad roundtrip on address: " + s); } } @@ -166,11 +165,9 @@ public void testInclusionAbove() { "dd:a:a:a:a:a:b:a", "dd:a:a:a:a:a:a:b")) { IPv6Address ipv6 = IPv6Address.valueOf(addr); assertFalse(r.contains(ipv6)); - assertTrue("for address " + ipv6, above(ipv6.toLongArray(), - r.getTop().toLongArray())); - assertFalse("for address " + ipv6, between(r.getBottom().toLongArray(), - r.getTop().toLongArray(), - ipv6.toLongArray())); + assertTrue(above(ipv6.toLongArray(), r.getTop().toLongArray()), "for address " + ipv6); + assertFalse(between(r.getBottom().toLongArray(), r.getTop().toLongArray(), ipv6.toLongArray()), + "for address " + ipv6); } } @@ -189,9 +186,8 @@ public void testInclusionBelow() { long[] bottomArr = r.getBottom().toLongArray(); long[] addrArr = ipv6.toLongArray(); - assertTrue("for address " + ipv6, above(bottomArr, addrArr)); - assertFalse("for address " + ipv6, between(bottomArr, - r.getTop().toLongArray(), addrArr)); + assertTrue(above(bottomArr, addrArr), "for address " + ipv6); + assertFalse(between(bottomArr, r.getTop().toLongArray(), addrArr), "for address " + ipv6); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IpAddressRangeTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IpAddressRangeTest.java index fe2bde06482..e3134dedaef 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IpAddressRangeTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/groups/impl/ipaddress/ip/IpAddressRangeTest.java @@ -83,7 +83,7 @@ public void testSingleAddress() { public void testRange( Boolean expected, IpAddressRange range, IpAddress... addresses ) { for ( IpAddress ipa : addresses ) { - assertEquals( "Testing " + ipa + " in " + range, expected, range.contains(ipa)); + assertEquals(expected, range.contains(ipa), "Testing " + ipa + " in " + range); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/authorization/users/AuthenticatedUserTest.java b/src/test/java/edu/harvard/iq/dataverse/authorization/users/AuthenticatedUserTest.java index 6c430d0a09a..7bd802b3b02 100644 --- a/src/test/java/edu/harvard/iq/dataverse/authorization/users/AuthenticatedUserTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/authorization/users/AuthenticatedUserTest.java @@ -364,14 +364,14 @@ public void testMutingInJson() { JsonObject jObject = testUser.toJson().build(); Set mutedEmails = new HashSet<>(jObject.getJsonArray("mutedEmails").getValuesAs(JsonString::getString)); - assertTrue("Set contains two elements", mutedEmails.size() == 2); - assertTrue("Set contains REVOKEROLE", mutedEmails.contains("REVOKEROLE")); - assertTrue("Set contains ASSIGNROLE", mutedEmails.contains("ASSIGNROLE")); + assertTrue(mutedEmails.size() == 2, "Set contains two elements"); + assertTrue(mutedEmails.contains("REVOKEROLE"), "Set contains REVOKEROLE"); + assertTrue(mutedEmails.contains("ASSIGNROLE"), "Set contains ASSIGNROLE"); Set mutedNotifications = new HashSet<>(jObject.getJsonArray("mutedNotifications").getValuesAs(JsonString::getString)); - assertTrue("Set contains two elements", mutedNotifications.size() == 2); - assertTrue("Set contains REVOKEROLE", mutedNotifications.contains("REVOKEROLE")); - assertTrue("Set contains ASSIGNROLE", mutedNotifications.contains("ASSIGNROLE")); + assertTrue(mutedNotifications.size() == 2, "Set contains two elements"); + assertTrue(mutedNotifications.contains("REVOKEROLE"), "Set contains REVOKEROLE"); + assertTrue(mutedNotifications.contains("ASSIGNROLE"), "Set contains ASSIGNROLE"); } @Test @@ -401,10 +401,10 @@ public void testTypeTokenizer() { Type.tokenizeToSet(" ASSIGNROLE , CREATEDV,REVOKEROLE ") ) ); - assertTrue("typeSet contains 3 elements", typeSet.size() == 3); - assertTrue("typeSet contains ASSIGNROLE", typeSet.contains(Type.ASSIGNROLE)); - assertTrue("typeSet contains CREATEDV", typeSet.contains(Type.CREATEDV)); - assertTrue("typeSet contains REVOKEROLE", typeSet.contains(Type.REVOKEROLE)); + assertTrue(typeSet.size() == 3, "typeSet contains 3 elements"); + assertTrue(typeSet.contains(Type.ASSIGNROLE), "typeSet contains ASSIGNROLE"); + assertTrue(typeSet.contains(Type.CREATEDV), "typeSet contains CREATEDV"); + assertTrue(typeSet.contains(Type.REVOKEROLE), "typeSet contains REVOKEROLE"); } @Test diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDataverseCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDataverseCommandTest.java index a52c06edf5e..7e84cf19e6b 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDataverseCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateDataverseCommandTest.java @@ -233,8 +233,8 @@ public void testDefaultOptions() throws CommandException { // The following is a pretty wierd way to test that the create date defaults to // now, but it works across date changes. - assertTrue( "When the supplied creation date is null, date shuld default to command execution time", - Math.abs(System.currentTimeMillis() - result.getCreateDate().toInstant().toEpochMilli()) < 1000 ); + assertTrue(Math.abs(System.currentTimeMillis() - result.getCreateDate().toInstant().toEpochMilli()) < 1000, + "When the supplied creation date is null, date should default to command execution time"); assertTrue( result.isPermissionRoot() ); assertTrue( result.isThemeRoot() ); diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateRoleCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateRoleCommandTest.java index b1b1636f8e2..533a9ed6bbd 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateRoleCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/CreateRoleCommandTest.java @@ -89,7 +89,7 @@ public void testSuperUsersAddRoles() throws CommandException { CreateRoleCommand sut = new CreateRoleCommand(dvr, new DataverseRequest(normalUser,IpAddress.valueOf("89.17.33.33")), dv); engine.submit(sut); - assertTrue( "CreateRoleCommand did not call save on the created role.", saveCalled ); + assertTrue(saveCalled, "CreateRoleCommand did not call save on the created role."); } diff --git a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/GetLatestPublishedDatasetVersionCommandTest.java b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/GetLatestPublishedDatasetVersionCommandTest.java index 935da493c35..2c9f050b92f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/GetLatestPublishedDatasetVersionCommandTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/engine/command/impl/GetLatestPublishedDatasetVersionCommandTest.java @@ -29,9 +29,9 @@ public void testLatestPublishedNoDraft() throws CommandException { List versions = make10Versions(ds); ds.setVersions(versions); - assertEquals( 10l, engine.submit(new GetLatestPublishedDatasetVersionCommand(makeRequest(), ds)).getVersionNumber().longValue() ); - assertTrue( "Published datasets should require no permissions to view", - engine.getReqiredPermissionsForObjects().get(ds).isEmpty() ); + assertEquals(10L, engine.submit(new GetLatestPublishedDatasetVersionCommand(makeRequest(), ds)).getVersionNumber().longValue()); + assertTrue(engine.getReqiredPermissionsForObjects().get(ds).isEmpty(), + "Published datasets should require no permissions to view"); } @Test @@ -42,9 +42,9 @@ public void testLatestPublishedWithDraft() throws CommandException { versions.add( MocksFactory.makeDatasetVersion(ds.getCategories()) ); ds.setVersions(versions); - assertEquals( 10l, engine.submit(new GetLatestPublishedDatasetVersionCommand(makeRequest(), ds)).getVersionNumber().longValue() ); - assertTrue( "Published datasets should require no permissions to view", - engine.getReqiredPermissionsForObjects().get(ds).isEmpty() ); + assertEquals(10L, engine.submit(new GetLatestPublishedDatasetVersionCommand(makeRequest(), ds)).getVersionNumber().longValue()); + assertTrue(engine.getReqiredPermissionsForObjects().get(ds).isEmpty(), + "Published datasets should require no permissions to view"); } @Test diff --git a/src/test/java/edu/harvard/iq/dataverse/externaltools/ExternalToolTest.java b/src/test/java/edu/harvard/iq/dataverse/externaltools/ExternalToolTest.java index 4cec93581c2..ea8613b70bf 100644 --- a/src/test/java/edu/harvard/iq/dataverse/externaltools/ExternalToolTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/externaltools/ExternalToolTest.java @@ -29,13 +29,13 @@ public void testToJson() { externalTool.setId(42l); JsonObject jsonObject = externalTool.toJson().build(); System.out.println("result: " + jsonObject); - assertEquals("testToJson() with ExternalTool.DISPLAY_NAME", "myDisplayName", jsonObject.getString(ExternalTool.DISPLAY_NAME)); - assertEquals("testToJson() with ExternalTool.TOOL_NAME", "explorer", jsonObject.getString(ExternalTool.TOOL_NAME)); - assertEquals("testToJson() with ExternalTool.DESCRIPTION", "myDescription", jsonObject.getString(ExternalTool.DESCRIPTION)); - assertEquals("testToJson() with ExternalTool.TYPES", "explore", jsonObject.getJsonArray(ExternalTool.TYPES).getString(0)); - assertEquals("testToJson() with ExternalTool.TOOL_URL", "http://example.com", jsonObject.getString(ExternalTool.TOOL_URL)); - assertEquals("testToJson() with ExternalTool.TOOL_PARAMETERS", "{}", jsonObject.getString(ExternalTool.TOOL_PARAMETERS)); - assertEquals("testToJson() with ExternalTool.CONTENT_TYPE", DataFileServiceBean.MIME_TYPE_TSV_ALT, jsonObject.getString(ExternalTool.CONTENT_TYPE)); + assertEquals("myDisplayName", jsonObject.getString(ExternalTool.DISPLAY_NAME), "testToJson() with ExternalTool.DISPLAY_NAME"); + assertEquals("explorer", jsonObject.getString(ExternalTool.TOOL_NAME), "testToJson() with ExternalTool.TOOL_NAME"); + assertEquals("myDescription", jsonObject.getString(ExternalTool.DESCRIPTION), "testToJson() with ExternalTool.DESCRIPTION"); + assertEquals("explore", jsonObject.getJsonArray(ExternalTool.TYPES).getString(0), "testToJson() with ExternalTool.TYPES"); + assertEquals("http://example.com", jsonObject.getString(ExternalTool.TOOL_URL), "testToJson() with ExternalTool.TOOL_URL"); + assertEquals("{}", jsonObject.getString(ExternalTool.TOOL_PARAMETERS), "testToJson() with ExternalTool.TOOL_PARAMETERS"); + assertEquals(DataFileServiceBean.MIME_TYPE_TSV_ALT, jsonObject.getString(ExternalTool.CONTENT_TYPE), "testToJson() with ExternalTool.CONTENT_TYPE"); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/csv/CSVFileReaderTest.java b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/csv/CSVFileReaderTest.java index 0d9f7d7ccce..fc066ef195e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/csv/CSVFileReaderTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/ingest/tabulardata/impl/plugins/csv/CSVFileReaderTest.java @@ -68,7 +68,7 @@ public void testRead() { } catch (IOException ex) { fail(); } - assertEquals("Error on line " + line, expLine, foundLine); + assertEquals(expLine, foundLine, "Error on line " + line); line++; } @@ -122,15 +122,15 @@ public void testVariables() { // OK, let's go through the individual variables: for (int i = 0; i < result.getVarQuantity(); i++) { - assertEquals("variable " + i + ":", expectedVariableNames[i], result.getDataVariables().get(i).getName()); + assertEquals(expectedVariableNames[i], result.getDataVariables().get(i).getName(), "variable " + i + ":"); - assertEquals("variable " + i + ":", expectedVariableTypes[i], result.getDataVariables().get(i).getType()); + assertEquals(expectedVariableTypes[i], result.getDataVariables().get(i).getType(), "variable " + i + ":"); - assertEquals("variable " + i + ":", expectedVariableIntervals[i], result.getDataVariables().get(i).getInterval()); + assertEquals(expectedVariableIntervals[i], result.getDataVariables().get(i).getInterval(), "variable " + i + ":"); - assertEquals("variable " + i + ":", expectedVariableFormatCategories[i], result.getDataVariables().get(i).getFormatCategory()); + assertEquals(expectedVariableFormatCategories[i], result.getDataVariables().get(i).getFormatCategory(), "variable " + i + ":"); - assertEquals("variable " + i + ":", expectedVariableFormats[i], result.getDataVariables().get(i).getFormat()); + assertEquals(expectedVariableFormats[i], result.getDataVariables().get(i).getFormat(), "variable " + i + ":"); } } @@ -197,7 +197,7 @@ public void testSubset() { Double[] columnVector = TabularSubsetGenerator.subsetDoubleVector(generatedTabInputStream, i, generatedDataTable.getCaseQuantity().intValue()); - assertArrayEquals("column " + i + ":", floatVectors[vectorCount++], columnVector); + assertArrayEquals(floatVectors[vectorCount++], columnVector, "column " + i + ":"); } // Discrete Numerics (aka, integers): @@ -231,7 +231,7 @@ public void testSubset() { Long[] columnVector = TabularSubsetGenerator.subsetLongVector(generatedTabInputStream, i, generatedDataTable.getCaseQuantity().intValue()); - assertArrayEquals("column " + i + ":", longVectors[vectorCount++], columnVector); + assertArrayEquals(longVectors[vectorCount++], columnVector, "column " + i + ":"); } // And finally, Strings: @@ -258,7 +258,7 @@ public void testSubset() { String[] columnVector = TabularSubsetGenerator.subsetStringVector(generatedTabInputStream, i, generatedDataTable.getCaseQuantity().intValue()); - assertArrayEquals("column " + i + ":", stringVectors[vectorCount++], columnVector); + assertArrayEquals(stringVectors[vectorCount++], columnVector, "column " + i + ":"); } } @@ -388,7 +388,7 @@ public void testVariableUNFs() { } } - assertEquals("Variable number " + i + ":", expectedUNFs[i], unf); + assertEquals(expectedUNFs[i], unf, "Variable number " + i + ":"); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/util/BitSetTest.java b/src/test/java/edu/harvard/iq/dataverse/util/BitSetTest.java index 445c61e1857..475d986b63c 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/BitSetTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/BitSetTest.java @@ -117,9 +117,9 @@ public void testIntersect() { sut = sut1.copy().intersect(sut2); for ( short i : BitSet.allIndices() ) { if ( sut.isSet(i) ) { - assertTrue( "expected true at idx " + i, sut1.isSet(i) && sut2.isSet(i) ); + assertTrue(sut1.isSet(i) && sut2.isSet(i), "expected true at idx " + i); } else { - assertFalse( "expected false at idx " + i, sut1.isSet(i) && sut2.isSet(i) ); + assertFalse(sut1.isSet(i) && sut2.isSet(i), "expected false at idx " + i); } } } @@ -134,9 +134,9 @@ public void testXor() { sut = sut1.copy().xor(sut2); for ( short i : BitSet.allIndices() ) { if ( sut.isSet(i) ) { - assertTrue( "expected true at idx " + i, sut1.isSet(i) ^ sut2.isSet(i) ); + assertTrue(sut1.isSet(i) ^ sut2.isSet(i), "expected true at idx " + i); } else { - assertFalse( "expected false at idx " + i, sut1.isSet(i) ^ sut2.isSet(i) ); + assertFalse(sut1.isSet(i) ^ sut2.isSet(i), "expected false at idx " + i); } } } diff --git a/src/test/java/edu/harvard/iq/dataverse/util/LruCacheTest.java b/src/test/java/edu/harvard/iq/dataverse/util/LruCacheTest.java index 122cf39e2c3..697e4853c3f 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/LruCacheTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/LruCacheTest.java @@ -76,14 +76,14 @@ public void testInvalidateWholeCache() { // prepare cache Long key = 0l; String value = "x"; - assertEquals("put value", value, sut.put(key, value)); - assertEquals("get value", value, sut.get(key)); + assertEquals(value, sut.put(key, value), "put value"); + assertEquals(value, sut.get(key), "get value"); // invalidate cache sut.invalidate(); // verify invalidation - assertEquals("verify that value is no longer here", null, sut.get(key)); + assertNull(sut.get(key), "verify that value is no longer here"); } @Test @@ -91,19 +91,19 @@ public void testInvalidateOneKeyOfCache() { // prepare cache Long key1 = 0l; String value1 = "x"; - assertEquals("put value 1", value1, sut.put(key1, value1)); - assertEquals("get value 1", value1, sut.get(key1)); + assertEquals(value1, sut.put(key1, value1), "put value 1"); + assertEquals(value1, sut.get(key1), "get value 1"); Long key2 = 1l; String value2 = "y"; - assertEquals("put value 2", value2, sut.put(key2, value2)); - assertEquals("get value 2", value2, sut.get(key2)); + assertEquals(value2, sut.put(key2, value2), "put value 2"); + assertEquals(value2, sut.get(key2), "get value 2"); // invalidate cache sut.invalidate(key1); // verify invalidation - assertEquals("verify that value 1 is no longer here", null, sut.get(key1)); - assertEquals("verify that value 2 still exists", value2, sut.get(key2)); + assertNull(sut.get(key1), "verify that value 1 is no longer here"); + assertEquals(value2, sut.get(key2), "verify that value 2 still exists"); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/util/json/JsonParserTest.java b/src/test/java/edu/harvard/iq/dataverse/util/json/JsonParserTest.java index 6576c1cfd84..972fc9c41cd 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/json/JsonParserTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/json/JsonParserTest.java @@ -711,8 +711,8 @@ public void testEnum() throws JsonParseException { arr.add(entry.name()); } Set typesSet = new HashSet<>(JsonParser.parseEnumsFromArray(arr.build(), Type.class)); - assertTrue("Set contains two elements", typesSet.size() == 2); - assertTrue("Set contains REVOKEROLE", typesSet.contains(Type.REVOKEROLE)); - assertTrue("Set contains ASSIGNROLE", typesSet.contains(Type.ASSIGNROLE)); + assertEquals(2, typesSet.size(), "Set contains two elements"); + assertTrue(typesSet.contains(Type.REVOKEROLE), "Set contains REVOKEROLE"); + assertTrue(typesSet.contains(Type.ASSIGNROLE), "Set contains ASSIGNROLE"); } } diff --git a/src/test/java/edu/harvard/iq/dataverse/util/shapefile/ShapefileHandlerTest.java b/src/test/java/edu/harvard/iq/dataverse/util/shapefile/ShapefileHandlerTest.java index 482981264c4..b93028b6365 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/shapefile/ShapefileHandlerTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/shapefile/ShapefileHandlerTest.java @@ -130,17 +130,14 @@ public void testCreateZippedNonShapefile() throws IOException{ shp_handler.DEBUG= true; // Contains shapefile? - assertEquals(shp_handler.containsShapefile(), false); + assertFalse(shp_handler.containsShapefile()); // get file_groups Map Map> file_groups = shp_handler.getFileGroups(); - assertEquals("verify that the dict is not empty", file_groups.isEmpty(), false); - assertEquals("verify key existance", file_groups.containsKey("not-quite-a-shape"), true); - assertEquals("verify value of key", file_groups.get("not-quite-a-shape"), Arrays.asList("shp", "shx", "dbf", "pdf")); - - this.showFilesInTempFolder(this.tempFolder.getRoot().getAbsolutePath()); - + assertFalse(file_groups.isEmpty(), "verify that the dict is not empty"); + assertTrue(file_groups.containsKey("not-quite-a-shape"), "verify key existance"); + assertEquals(List.of("shp", "shx", "dbf", "pdf"), file_groups.get("not-quite-a-shape"), "verify value of key"); // Delete .zip zipfile_obj.delete(); @@ -166,8 +163,8 @@ public void testZippedTwoShapefiles() throws IOException{ ShapefileHandler shp_handler = new ShapefileHandler(new FileInputStream(zipfile_obj)); shp_handler.DEBUG= true; - assertEquals("verify shapefile existance", shp_handler.containsShapefile(), true); - assertEquals("verify that no error was found", shp_handler.errorFound, false); + assertTrue(shp_handler.containsShapefile(), "verify shapefile existance"); + assertFalse(shp_handler.errorFound, "verify that no error was found"); shp_handler.showFileGroups(); // if (true){ @@ -176,18 +173,15 @@ public void testZippedTwoShapefiles() throws IOException{ // get file_groups Map Map> file_groups = shp_handler.getFileGroups(); - assertEquals("verify that the dict is not empty", file_groups.isEmpty(), false); + assertFalse(file_groups.isEmpty(), "verify that the dict is not empty"); // Verify the keys - assertEquals("verify key existance of 'shape1'", file_groups.containsKey("shape1"), true); - assertEquals("verify key existance of 'shape2'", file_groups.containsKey("shape2"), true); + assertTrue(file_groups.containsKey("shape1"), "verify key existance of 'shape1'"); + assertTrue(file_groups.containsKey("shape2"), "verify key existance of 'shape2'"); // Verify the values - assertEquals("verify value of key 'shape1'", file_groups.get("shape1"), Arrays.asList("shp", "shx", "dbf", "prj", "fbn", "fbx")); - assertEquals("verify value of key 'shape2'", file_groups.get("shape2"), Arrays.asList("shp", "shx", "dbf", "prj", "txt", "pdf", ShapefileHandler.BLANK_EXTENSION)); - - this.showFilesInTempFolder(this.tempFolder.getRoot().getAbsolutePath()); - + assertEquals(file_groups.get("shape1"), Arrays.asList("shp", "shx", "dbf", "prj", "fbn", "fbx"), "verify value of key 'shape1'"); + assertEquals(file_groups.get("shape2"), Arrays.asList("shp", "shx", "dbf", "prj", "txt", "pdf", ShapefileHandler.BLANK_EXTENSION), "verify value of key 'shape2'"); // Rezip/Reorder the files File test_unzip_folder = Files.createDirectory(this.tempFolder.resolve("test_unzip")).toFile(); @@ -199,9 +193,9 @@ public void testZippedTwoShapefiles() throws IOException{ List rezipped_filenames = new ArrayList<>(); rezipped_filenames.addAll(Arrays.asList(test_unzip_folder.list())); msg("rezipped_filenames: " + rezipped_filenames); - List expected_filenames = Arrays.asList("shape1.zip", "shape2.zip", "shape2.txt", "shape2.pdf", "shape2", "README.MD", "shp_dictionary.xls", "notes"); - - assertEquals("verify that all files exist", rezipped_filenames.containsAll(rezipped_filenames), true); + List expected_filenames = Arrays.asList("shape1.zip", "shape2.zip", "shape2.txt", "shape2.pdf", "shape2", "README.MD", "shp_dictionary.xls", "notes"); + + assertTrue(rezipped_filenames.containsAll(expected_filenames), "verify that all files exist"); // Delete .zip zipfile_obj.delete(); @@ -221,21 +215,21 @@ public void testZippedShapefileWithExtraFiles() throws IOException{ // Pass the .zip to the ShapefileHandler ShapefileHandler shp_handler = new ShapefileHandler(new FileInputStream(zipfile_obj)); shp_handler.DEBUG= true; - - assertEquals("verify shapefile existance", shp_handler.containsShapefile(), true); + + assertTrue(shp_handler.containsShapefile(), "verify shapefile existance"); // get file_groups Map Map> file_groups = shp_handler.getFileGroups(); - - assertEquals("verify that the dict is not empty", file_groups.isEmpty(), false); + + assertFalse(file_groups.isEmpty(), "verify that the dict is not empty"); // Verify the keys - assertEquals("verify key existance of 'shape1'", file_groups.containsKey("shape1"), true); + assertTrue(file_groups.containsKey("shape1"), "verify key existance of 'shape1'"); // Verify the values - assertEquals("verify value of key 'shape1'", file_groups.get("shape1"), Arrays.asList("shp", "shx", "dbf", "prj", "pdf", "cpg", SHP_XML_EXTENSION)); - assertEquals("verify value of key 'README'", file_groups.get("README"), Arrays.asList("md")); - assertEquals("verify value of key 'shape_notes'", file_groups.get("shape_notes"), Arrays.asList("txt")); + assertEquals(List.of("shp", "shx", "dbf", "prj", "pdf", "cpg", SHP_XML_EXTENSION), file_groups.get("shape1"), "verify value of key 'shape1'"); + assertEquals(List.of("md"), file_groups.get("README"), "verify value of key 'README'"); + assertEquals(List.of("txt"), file_groups.get("shape_notes"), "verify value of key 'shape_notes'"); File unzip2Folder = Files.createDirectory(this.tempFolder.resolve("test_unzip2")).toFile(); // Rezip/Reorder the files @@ -248,9 +242,9 @@ public void testZippedShapefileWithExtraFiles() throws IOException{ rezipped_filenames.addAll(Arrays.asList(unzip2Folder.list())); msg("rezipped_filenames: " + rezipped_filenames); - List expected_filenames = Arrays.asList("shape1.zip", "scratch-for-unzip-12345", "shape1.pdf", "README.md", "shape_notes.txt"); - - assertEquals("verify that all files exist", expected_filenames.containsAll(rezipped_filenames), true); + List expected_filenames = Arrays.asList("shape1.zip", "scratch-for-unzip-12345", "shape1.pdf", "README.md", "shape_notes.txt"); + + assertTrue(expected_filenames.containsAll(rezipped_filenames), "verify that all files exist"); // Delete .zip zipfile_obj.delete(); From 7587b95eb67d5cc8b6f52e43a2e1d1b32397ba57 Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Fri, 18 Aug 2023 18:22:52 +0200 Subject: [PATCH 11/17] doc(test): migrate testing guide to JUnit5 #9782 --- .../source/developers/testing.rst | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/doc/sphinx-guides/source/developers/testing.rst b/doc/sphinx-guides/source/developers/testing.rst index f788719c9c6..0f2eca84b62 100755 --- a/doc/sphinx-guides/source/developers/testing.rst +++ b/doc/sphinx-guides/source/developers/testing.rst @@ -47,12 +47,14 @@ Writing Unit Tests with JUnit ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We are aware that there are newer testing tools such as TestNG, but we use `JUnit `_ because it's tried and true. -We support both (legacy) JUnit 4.x tests (forming the majority of our tests) and -newer JUnit 5 based testing. +We support JUnit 5 based testing and require new tests written with it. +(Since Dataverse 6.0, we migrated all of our tests formerly based on JUnit 4.) -NOTE: When adding new tests, you should give JUnit 5 a go instead of adding more dependencies to JUnit 4.x. - -If writing tests is new to you, poke around existing unit tests which all end in ``Test.java`` and live under ``src/test``. Each test is annotated with ``@Test`` and should have at least one assertion which specifies the expected result. In Netbeans, you can run all the tests in it by clicking "Run" -> "Test File". From the test file, you should be able to navigate to the code that's being tested by right-clicking on the file and clicking "Navigate" -> "Go to Test/Tested class". Likewise, from the code, you should be able to use the same "Navigate" menu to go to the tests. +If writing tests is new to you, poke around existing unit tests which all end in ``Test.java`` and live under ``src/test``. +Each test is annotated with ``@Test`` and should have at least one assertion which specifies the expected result. +In Netbeans, you can run all the tests in it by clicking "Run" -> "Test File". +From the test file, you should be able to navigate to the code that's being tested by right-clicking on the file and clicking "Navigate" -> "Go to Test/Tested class". +Likewise, from the code, you should be able to use the same "Navigate" menu to go to the tests. NOTE: Please remember when writing tests checking possibly localized outputs to check against ``en_US.UTF-8`` and ``UTC`` l10n strings! @@ -62,22 +64,24 @@ Refactoring Code to Make It Unit-Testable Existing code is not necessarily written in a way that lends itself to easy testing. Generally speaking, it is difficult to write unit tests for both JSF "backing" beans (which end in ``Page.java``) and "service" beans (which end in ``Service.java``) because they require the database to be running in order to test them. If service beans can be exercised via API they can be tested with integration tests (described below) but a good technique for making the logic testable it to move code to "util beans" (which end in ``Util.java``) that operate on Plain Old Java Objects (POJOs). ``PrivateUrlUtil.java`` is a good example of moving logic from ``PrivateUrlServiceBean.java`` to a "util" bean to make the code testable. -Parameterized Tests and JUnit Theories -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Parameterized Tests +^^^^^^^^^^^^^^^^^^^ + Often times you will want to test a method multiple times with similar values. In order to avoid test bloat (writing a test for every data combination), JUnit offers Data-driven unit tests. This allows a test to be run for each set of defined data values. -JUnit 4 uses ``Parameterized.class`` and ``Theories.class``. For reference, take a look at issue https://github.com/IQSS/dataverse/issues/5619. - -JUnit 5 doesn't offer theories (see `jqwik `_ for this), but -greatly extended parameterized testing. Some guidance how to write those: +JUnit 5 offers great parameterized testing. Some guidance how to write those: - https://junit.org/junit5/docs/current/user-guide/#writing-tests-parameterized-tests - https://www.baeldung.com/parameterized-tests-junit-5 - https://blog.codefx.org/libraries/junit-5-parameterized-tests/ -- See also some examples in our codebase. +- See also many examples in our codebase. + +Note that JUnit 5 also offers support for custom test parameter resolvers. This enables keeping tests cleaner, +as preparation might happen within some extension and the test code is more focused on the actual testing. +See https://junit.org/junit5/docs/current/user-guide/#extensions-parameter-resolution for more information. JUnit 5 Test Helper Extensions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -116,11 +120,14 @@ In addition, there is a writeup on "The Testable Command" at https://github.com/ Running Non-Essential (Excluded) Unit Tests ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -You should be aware that some unit tests have been deemed "non-essential" and have been annotated with ``@Category(NonEssentialTests.class)`` and are excluded from the "dev" Maven profile, which is the default profile. All unit tests (that have not been annotated with ``@Ignore``), including these non-essential tests, are run from continuous integration systems such as Jenkins and GitHub Actions with the following ``mvn`` command that invokes a non-default profile: +You should be aware that some unit tests have been deemed "non-essential" and have been annotated with ``@Tag(Tags.NOT_ESSENTIAL_UNITTESTS)`` and are excluded from the "dev" Maven profile, which is the default profile. +All unit tests (that have not been annotated with ``@Disable``), including these non-essential tests, are run from continuous integration systems such as Jenkins and GitHub Actions with the following ``mvn`` command that invokes a non-default profile: ``mvn test -P all-unit-tests`` -Generally speaking, unit tests have been flagged as non-essential because they are slow or because they require an Internet connection. You should not feel obligated to run these tests continuously but you can use the ``mvn`` command above to run them. To iterate on the unit test in Netbeans and execute it with "Run -> Test File", you must temporarily comment out the annotation flagging the test as non-essential. +Generally speaking, unit tests have been flagged as non-essential because they are slow or because they require an Internet connection. +You should not feel obligated to run these tests continuously but you can use the ``mvn`` command above to run them. +To iterate on the unit test in Netbeans and execute it with "Run -> Test File", you must temporarily comment out the annotation flagging the test as non-essential. Integration Tests ----------------- From 3ecca8657ab6c67a53a220588949cdd2d8fabffe Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Mon, 21 Aug 2023 13:02:55 +0200 Subject: [PATCH 12/17] build(test): fix overlooked assertEquals arg flips in HarvestingClientIT #9782 --- .../edu/harvard/iq/dataverse/api/HarvestingClientsIT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/edu/harvard/iq/dataverse/api/HarvestingClientsIT.java b/src/test/java/edu/harvard/iq/dataverse/api/HarvestingClientsIT.java index 67d8e8dd668..7a3e779eb8a 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/HarvestingClientsIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/HarvestingClientsIT.java @@ -228,10 +228,10 @@ public void testHarvestingClientRun() throws InterruptedException { + getClientResponse.prettyPrint()); // Check the values in the response: // a) Confirm that the harvest has completed: - assertEquals("Unexpected client status: "+clientStatus, "inActive", clientStatus); + assertEquals("inActive", clientStatus, "Unexpected client status: "+clientStatus); // b) Confirm that it has actually succeeded: - assertEquals("Last harvest not reported a success (took "+i+" seconds)", "SUCCESS", responseJsonPath.getString("data.lastResult")); + assertEquals("SUCCESS", responseJsonPath.getString("data.lastResult"), "Last harvest not reported a success (took "+i+" seconds)"); String harvestTimeStamp = responseJsonPath.getString("data.lastHarvest"); assertNotNull(harvestTimeStamp); From db07e9415423380accf5dc6a82dfa4203de9b7a1 Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Mon, 21 Aug 2023 15:50:39 +0200 Subject: [PATCH 13/17] doc(test): add release note about JUnit5 migration #9782 --- doc/release-notes/9782-juni5-transition.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 doc/release-notes/9782-juni5-transition.md diff --git a/doc/release-notes/9782-juni5-transition.md b/doc/release-notes/9782-juni5-transition.md new file mode 100644 index 00000000000..b7ffcc0de0d --- /dev/null +++ b/doc/release-notes/9782-juni5-transition.md @@ -0,0 +1,7 @@ +# Migrating all test to JUnit 5 +With this release, we transition all of our test cases (see `src/test/`) to use JUnit 5 only. +Moving forward from JUnit 4 will allow writing tests in more concise and easier ways. +The tests themselves have not been altered, but updated to match JUnit 5 ways. +They have not been extended or dropped coverage; this is mostly a preparation of things to come in the future. +If you are writing tests in JUnit 4 in your feature branches, you need to migrate. +The development guides section of testing has been updated as well. From 0b9170061bea38115ed99be111095d69a195d989 Mon Sep 17 00:00:00 2001 From: Oliver Bertuch Date: Mon, 21 Aug 2023 22:04:59 +0200 Subject: [PATCH 14/17] build(parent): add Maven enforcer rules to ban JUnit 4 #9782 --- modules/dataverse-parent/pom.xml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/modules/dataverse-parent/pom.xml b/modules/dataverse-parent/pom.xml index d0a3dd2d926..c321d688eaa 100644 --- a/modules/dataverse-parent/pom.xml +++ b/modules/dataverse-parent/pom.xml @@ -191,6 +191,7 @@ 3.2.1 3.4.1 1.3.0 + 3.3.0 3.1.2 1.6.13 @@ -253,6 +254,11 @@ maven-failsafe-plugin ${maven-failsafe-plugin.version} + + org.apache.maven.plugins + maven-enforcer-plugin + ${maven-enforcer-plugin.version} + org.apache.maven.plugins maven-checkstyle-plugin @@ -312,6 +318,32 @@ + + + org.apache.maven.plugins + maven-enforcer-plugin + + + no-junit4 + generate-test-resources + + enforce + + + + + + junit:junit:*:*:test + org.junit:junit:*:*:test + org.junit.vintage:*:*:*:test + + + + + + + +