Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Oct 25, 2024
1 parent f4266b5 commit 9dcdbce
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions src/test/java/edu/harvard/iq/dataverse/api/DatasetTypesIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.UUID;
import org.hamcrest.CoreMatchers;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasItemInArray;
Expand Down Expand Up @@ -273,7 +274,7 @@ public void testAddAndDeleteDatasetType() {
}

@Test
public void testSoftwareCodemeta() {
public void testUpdateMetadataBlockDatasetTypeAssociations() {
Response createUser = UtilIT.createRandomUser();
createUser.then().assertThat().statusCode(OK.getStatusCode());
String username = UtilIT.getUsernameFromResponse(createUser);
Expand All @@ -295,44 +296,46 @@ public void testSoftwareCodemeta() {
typeAdded.prettyPrint();
typeAdded.then().assertThat().statusCode(OK.getStatusCode());


Long typeId = JsonPath.from(typeAdded.getBody().asString()).getLong("data.id");

System.out.println("id of type: " + typeId);
Response getTypeById = UtilIT.getDatasetType(typeId.toString());
getTypeById.prettyPrint();
getTypeById.then().assertThat().statusCode(OK.getStatusCode());

// if (true) return;


String updateToTheseTypes = Json.createArrayBuilder()
// FIXME: put this back
.add(randomName)
.build().toString();

Response associateGeospatialWithDatasetType1 = UtilIT.updateMetadataBlockDatasetTypeAssociations("geospatial", updateToTheseTypes, apiToken);
String metadataBlockToAssociateDatasetTypeWith = "geospatial";

Response associateGeospatialWithDatasetType1 = UtilIT.updateMetadataBlockDatasetTypeAssociations(metadataBlockToAssociateDatasetTypeWith, updateToTheseTypes, apiToken);
associateGeospatialWithDatasetType1.prettyPrint();
associateGeospatialWithDatasetType1.then().assertThat().
statusCode(OK.getStatusCode())
.body("data.associatedDatasetTypes.after[0]", CoreMatchers.is(randomName));

Response getGeospatialBlock = UtilIT.getMetadataBlock("geospatial");
Response getGeospatialBlock = UtilIT.getMetadataBlock(metadataBlockToAssociateDatasetTypeWith);
getGeospatialBlock.prettyPrint();
getGeospatialBlock.then().assertThat()
.statusCode(OK.getStatusCode());
// .body("data.associatedDatasetTypes.before[0]", CoreMatchers.is(randomName))
// .body("data.associatedDatasetTypes", CoreMatchers.containsString(randomName));
// TODO: get this assertion working!
// TODO: get this assertion working!
// .body("data.associatedDatasetTypes[0]", CoreMatchers.is(randomName));

Response createDataverse = UtilIT.createRandomDataverse(apiToken);
createDataverse.then().assertThat().statusCode(CREATED.getStatusCode());

String dataverseAlias = UtilIT.getAliasFromResponse(createDataverse);
Integer dataverseId = UtilIT.getDataverseIdFromResponse(createDataverse);

Response listBlocks = UtilIT.listMetadataBlocks(dataverseAlias, true, false, randomName, apiToken);
listBlocks.prettyPrint();
listBlocks.then().assertThat().statusCode(OK.getStatusCode());
listBlocks.then().assertThat()
.statusCode(OK.getStatusCode())
.body("data[0].name", is("citation"))
.body("data[1].name", is(metadataBlockToAssociateDatasetTypeWith));
}

@Test
Expand Down Expand Up @@ -360,14 +363,11 @@ public void testSetMetadataBlocks() {
listBlocks = UtilIT.listMetadataBlocks(dataverseAlias, false, false, apiToken);
listBlocks.prettyPrint();
listBlocks.then().assertThat().statusCode(OK.getStatusCode());
if (true) return;








if (true) {
return;
}

String[] testInputLevelNames = {"geographicCoverage", "country", "city", "notesText"};
boolean[] testRequiredInputLevels = {false, true, false, false};
boolean[] testIncludedInputLevels = {false, true, true, false};
Expand Down Expand Up @@ -404,8 +404,10 @@ public void testSetMetadataBlocks() {
assertThat(expectedAllMetadataBlockDisplayNames, hasItemInArray(actualMetadataBlockDisplayName1));
assertThat(expectedAllMetadataBlockDisplayNames, hasItemInArray(actualMetadataBlockDisplayName2));
assertThat(expectedAllMetadataBlockDisplayNames, hasItemInArray(actualMetadataBlockDisplayName3));

if (true) return;

if (true) {
return;
}

// Existent dataverse and onlyDisplayedOnCreate=true
String[] expectedOnlyDisplayedOnCreateMetadataBlockDisplayNames = {"Citation Metadata", "Geospatial Metadata"};
Expand Down Expand Up @@ -527,5 +529,5 @@ public void testSetMetadataBlocks() {
.body("data[0].fields", not(equalTo(null)))
.body("data.size()", equalTo(1));
}

}

0 comments on commit 9dcdbce

Please sign in to comment.