Skip to content

Commit

Permalink
fix the tests: DataversesIT and MetadataBlocksIT
Browse files Browse the repository at this point in the history
  • Loading branch information
ffritze committed Dec 18, 2024
1 parent cd3f0ef commit b2e271a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,8 @@ public void testListMetadataBlocks() {
.body("data.size()", equalTo(1))
.body("data[0].name", is("citation"))
.body("data[0].fields.title.displayOnCreate", equalTo(true))
.body("data[0].fields.size()", is(28));
.body("data[0].fields.size()", is(10))
.body("data[0].fields.author.childFields.size()", is(4));

Check failure on line 931 in src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java

View workflow job for this annotation

GitHub Actions / Checkstyle job

[reviewdog] reported by reviewdog 🐶 File contains tab characters (this is the first instance). Raw Output: /github/workspace/./src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java:931:9: error: File contains tab characters (this is the first instance). (com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck)

Response setMetadataBlocksResponse = UtilIT.setMetadataBlocks(dataverseAlias, Json.createArrayBuilder().add("citation").add("astrophysics"), apiToken);
setMetadataBlocksResponse.then().assertThat().statusCode(OK.getStatusCode());
Expand Down
15 changes: 11 additions & 4 deletions src/test/java/edu/harvard/iq/dataverse/api/MetadataBlocksIT.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.harvard.iq.dataverse.api;

import io.restassured.RestAssured;

import io.restassured.response.Response;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -9,6 +10,7 @@
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.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
Expand Down Expand Up @@ -42,22 +44,27 @@ void testListMetadataBlocks() {

// returnDatasetFieldTypes=true
listMetadataBlocksResponse = UtilIT.listMetadataBlocks(false, true);
int expectedNumberOfMetadataFields = 80;
int expectedNumberOfMetadataFields = 35;
listMetadataBlocksResponse.prettyPrint();
listMetadataBlocksResponse.then().assertThat()
.statusCode(OK.getStatusCode())
.body("data[0].fields", not(equalTo(null)))
.body("data[0].fields.size()", equalTo(expectedNumberOfMetadataFields))
.body("data.size()", equalTo(expectedDefaultNumberOfMetadataBlocks));
.body("data.size()", equalTo(expectedDefaultNumberOfMetadataBlocks))
.body("data[1].fields.geographicCoverage.childFields.size()", is(4))
.body("data[0].fields.publication.childFields.size()", is(5));

// onlyDisplayedOnCreate=true and returnDatasetFieldTypes=true
listMetadataBlocksResponse = UtilIT.listMetadataBlocks(true, true);
expectedNumberOfMetadataFields = 28;
listMetadataBlocksResponse.prettyPrint();
expectedNumberOfMetadataFields = 10;
listMetadataBlocksResponse.then().assertThat()
.statusCode(OK.getStatusCode())
.body("data[0].fields", not(equalTo(null)))
.body("data[0].fields.size()", equalTo(expectedNumberOfMetadataFields))
.body("data[0].displayName", equalTo("Citation Metadata"))
.body("data.size()", equalTo(expectedOnlyDisplayedOnCreateNumberOfMetadataBlocks));
.body("data.size()", equalTo(expectedOnlyDisplayedOnCreateNumberOfMetadataBlocks))
.body("data[0].fields.author.childFields.size()", is(4));

Check failure on line 67 in src/test/java/edu/harvard/iq/dataverse/api/MetadataBlocksIT.java

View workflow job for this annotation

GitHub Actions / Checkstyle job

[reviewdog] reported by reviewdog 🐶 File contains tab characters (this is the first instance). Raw Output: /github/workspace/./src/test/java/edu/harvard/iq/dataverse/api/MetadataBlocksIT.java:67:9: error: File contains tab characters (this is the first instance). (com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck)
}

@Test
Expand Down

0 comments on commit b2e271a

Please sign in to comment.