Skip to content

Commit

Permalink
build(test): migrate Before, After and Ignore to JUnit 5 equivalents #…
Browse files Browse the repository at this point in the history
  • Loading branch information
poikilotherm committed Aug 18, 2023
1 parent 2ca734e commit 955bc36
Show file tree
Hide file tree
Showing 109 changed files with 222 additions and 221 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class AuxiliaryFileServiceBeanTest {
List<String> types;
DataFile dataFile;

@Before
@BeforeEach
public void setup() {
svc = new AuxiliaryFileServiceBean();
svc.em = mock(EntityManager.class);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/edu/harvard/iq/dataverse/CartTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public DataFileServiceBeanTest() {
private DataFileServiceBean dataFileServiceBean;


@Before
@BeforeEach
public void setUp() {
fileWoContentType = createDataFile(null);
fileWithBogusContentType = createDataFile("foo/bar");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/edu/harvard/iq/dataverse/DatasetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -94,7 +94,7 @@ public void before() {
this.releasedVersion.setVersionState(VersionState.RELEASED);
}

@After
@AfterEach
public void after() {
this.archivedVersion = null;
this.deaccessionedVersion = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/edu/harvard/iq/dataverse/DataverseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class DataverseTest {
private Dataverse OWNER;
private List<DataverseMetadataBlockFacet> OWNER_METADATABLOCKFACETS;

@Before
@BeforeEach
public void beforeEachTest() {
OWNER = new Dataverse();
OWNER.setId(MocksFactory.nextId());
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/edu/harvard/iq/dataverse/GlobalIdTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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");

Expand All @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class PersistentIdentifierServiceBeanTest {

CommandContext ctxt;

@Before
@BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
ctxt = new TestCommandContext(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public class RoleAssignmentTest {
private Dataset dataset;
private String privateUrlToken;

@Before
@BeforeEach
public void before() {
this.dataverseRole = new DataverseRole();
this.roleAssignee = GuestUser.get();
this.dataset = new Dataset();
this.privateUrlToken = "some-token";
}

@After
@AfterEach
public void after() {
this.dataverseRole = null;
this.roleAssignee = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -25,7 +25,7 @@ public void setUp() {
this.referenceRecord.setInfo("info1");
}

@After
@AfterEach
public void tearDwon() {
this.referenceRecord = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class AbstractApiBeanTest {

AbstractApiBeanImpl sut;

@Before
@BeforeEach
public void before() {
sut = new AbstractApiBeanImpl();
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/edu/harvard/iq/dataverse/api/AccessIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class AccessIT {
private static String testFileFromZipUploadWithFoldersChecksum3 = "00433ccb20111f9d40f0e5ab6fa8396f";


@BeforeClass
@BeforeAll
public static void setUp() throws InterruptedException {
RestAssured.baseURI = UtilIT.getRestAssuredBaseUri();

Expand Down Expand Up @@ -162,7 +162,7 @@ public static void setUp() throws InterruptedException {

}

@AfterClass
@AfterAll
public static void tearDown() {

Response publishDataset = UtilIT.publishDatasetViaNativeApi(datasetId, "major", apiToken);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/edu/harvard/iq/dataverse/api/AdminIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class AdminIT {

private final String testNonSuperuserApiToken = createTestNonSuperuserApiToken();

@BeforeClass
@BeforeAll
public static void setUp() {
RestAssured.baseURI = UtilIT.getRestAssuredBaseUri();
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class AuxiliaryFilesIT {

@BeforeClass
@BeforeAll
public static void setUp() {
RestAssured.baseURI = UtilIT.getRestAssuredBaseUri();
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/edu/harvard/iq/dataverse/api/BagIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class BagIT {

@BeforeClass
@BeforeAll
public static void setUpClass() {

RestAssured.baseURI = UtilIT.getRestAssuredBaseUri();
Expand Down Expand Up @@ -65,7 +65,7 @@ public void testBagItExport() {

}

@AfterClass
@AfterAll
public static void tearDownClass() {

// Not checking if delete happened. Hopefully, it did.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class BatchImportIT {
public BatchImportIT() {
}

@BeforeClass
@BeforeAll
public static void setUpClass() {
RestAssured.baseURI = UtilIT.getRestAssuredBaseUri();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

public class DataRetrieverApiIT {

@BeforeClass
@BeforeAll
public static void setUpClass() {
RestAssured.baseURI = UtilIT.getRestAssuredBaseUri();
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public class DatasetsIT {



@BeforeClass
@BeforeAll
public static void setUpClass() {


Expand Down Expand Up @@ -129,7 +129,7 @@ public static void setUpClass() {
*/
}

@AfterClass
@AfterAll
public static void afterClass() {

Response removeIdentifierGenerationStyle = UtilIT.deleteSetting(SettingsServiceBean.Key.IdentifierGenerationStyle);
Expand Down Expand Up @@ -1852,7 +1852,7 @@ public void testCreateDeleteDatasetLink() {
}

@Test
@Ignore
@Disabled
public void testApiErrors() {

/*
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class DeactivateUsersIT {

@BeforeClass
@BeforeAll
public static void setUp() {
RestAssured.baseURI = UtilIT.getRestAssuredBaseUri();
}
Expand Down

0 comments on commit 955bc36

Please sign in to comment.