Skip to content

Commit

Permalink
refactor(tests): modernize DatasetVersionTest with JUnit5 + make atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
poikilotherm committed Jul 28, 2021
1 parent 2ee8fbf commit 8ea5df5
Showing 1 changed file with 17 additions and 28 deletions.
45 changes: 17 additions & 28 deletions src/test/java/edu/harvard/iq/dataverse/DatasetVersionTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.harvard.iq.dataverse;

import edu.harvard.iq.dataverse.branding.BrandingUtilTest;
import edu.harvard.iq.dataverse.mocks.MocksFactory;
import edu.harvard.iq.dataverse.util.json.JsonUtil;
import java.io.StringReader;
Expand All @@ -10,44 +11,32 @@
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.logging.Logger;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.json.JsonReader;
import org.junit.After;
import org.junit.AfterClass;
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.BeforeClass;
import org.junit.Test;
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 org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;

/**
*
* @author michael
*/
public class DatasetVersionTest {

public DatasetVersionTest() {
}

@BeforeClass
public static void setUpClass() {
}
private static final Logger logger = Logger.getLogger(DatasetVersion.class.getCanonicalName());

@AfterClass
public static void tearDownClass() {
@BeforeAll
public static void setUp() {
BrandingUtilTest.setupMocks();
}

@Before
public void setUp() {
@AfterAll
public static void tearDown() {
BrandingUtilTest.setupMocks();
}

@After
public void tearDown() {
}

@Test
public void testComparator() {
DatasetVersion ds1_0 = new DatasetVersion();
Expand Down Expand Up @@ -123,7 +112,7 @@ public void testGetJsonLd() throws ParseException {
terms.setLicense(TermsOfUseAndAccess.License.CC0);
datasetVersion.setTermsOfUseAndAccess(terms);
String jsonLd = datasetVersion.getJsonLd();
System.out.println("jsonLd: " + JsonUtil.prettyPrint(jsonLd));
logger.fine("jsonLd: " + JsonUtil.prettyPrint(jsonLd));
JsonReader jsonReader = Json.createReader(new StringReader(jsonLd));
JsonObject obj = jsonReader.readObject();
assertEquals("http://schema.org", obj.getString("@context"));
Expand Down Expand Up @@ -180,7 +169,7 @@ public void testGetJsonLdNonCC0License() throws ParseException {
datasetVersion.setTermsOfUseAndAccess(terms);

String jsonLd = datasetVersion.getJsonLd();
System.out.println("jsonLd: " + JsonUtil.prettyPrint(jsonLd));
logger.fine("jsonLd: " + JsonUtil.prettyPrint(jsonLd));
JsonReader jsonReader = Json.createReader(new StringReader(jsonLd));
JsonObject obj = jsonReader.readObject();
assertEquals("http://schema.org", obj.getString("@context"));
Expand Down

0 comments on commit 8ea5df5

Please sign in to comment.