Skip to content

Commit

Permalink
SCRUM-4185 update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgibs committed Jul 9, 2024
1 parent dcb3aac commit 644e2cb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void init() {
@Order(1)
public void sqtrBulkUploadCheckFields() throws Exception {

checkSuccessfulBulkLoad(sqtrBulkPostEndpoint, sqtrTestFilePath + "AF_01_all_fields.json");
checkSuccessfulBulkLoad(sqtrBulkPostEndpoint, sqtrTestFilePath + "AF_01_all_fields.json", 2);

RestAssured.given().
when().
Expand All @@ -67,24 +67,49 @@ public void sqtrBulkUploadCheckFields() throws Exception {
@Order(2)
public void sqtrBulkUploadMissingRequiredFields() throws Exception {

checkFailedBulkLoad(sqtrBulkPostEndpoint, sqtrTestFilePath + "MR_01_no_name.json");
checkFailedBulkLoad(sqtrBulkPostEndpoint, sqtrTestFilePath + "MR_02_no_taxon.json");
checkFailedBulkLoad(
sqtrBulkPostEndpoint,
sqtrTestFilePath + "MR_01_no_name.json",
2,
1,
1
);
checkFailedBulkLoad(
sqtrBulkPostEndpoint,
sqtrTestFilePath + "MR_02_no_taxon.json",
2,
1,
1
);
}

@Test
@Order(3)
public void sqtrBulkUploadEmptyRequiredFields() throws Exception {

checkFailedBulkLoad(sqtrBulkPostEndpoint, sqtrTestFilePath + "ER_01_empty_name.json");
checkFailedBulkLoad(sqtrBulkPostEndpoint, sqtrTestFilePath + "ER_02_empty_taxon.json");
checkFailedBulkLoad(
sqtrBulkPostEndpoint,
sqtrTestFilePath + "ER_01_empty_name.json",
2,
1,
1
);

checkFailedBulkLoad(
sqtrBulkPostEndpoint,
sqtrTestFilePath + "ER_02_empty_taxon.json",
2,
1,
1
);

}

@Test
@Order(4)
public void sqtrBulkUploadUpdateMissingNonRequiredFields() throws Exception {

checkSuccessfulBulkLoad(sqtrBulkPostEndpoint, sqtrTestFilePath + "UM_01_update_no_non_required_fields.json");
checkSuccessfulBulkLoad(sqtrBulkPostEndpoint, sqtrTestFilePath + "UM_01_update_no_non_required_fields.json", 2);

RestAssured.given().
when().
Expand All @@ -104,7 +129,7 @@ public void sqtrBulkUploadUpdateMissingNonRequiredFields() throws Exception {
@Order(5)
public void sqtrBulkUploadUpdateEmptyNonRequiredFields() throws Exception {

checkSuccessfulBulkLoad(sqtrBulkPostEndpoint, sqtrTestFilePath + "AF_01_all_fields.json");
checkSuccessfulBulkLoad(sqtrBulkPostEndpoint, sqtrTestFilePath + "AF_01_all_fields.json", 2);

RestAssured.given().
when().
Expand All @@ -122,7 +147,7 @@ public void sqtrBulkUploadUpdateEmptyNonRequiredFields() throws Exception {
body("results[0]" , hasKey("synonyms")).
body("results[0]" , hasKey("secondaryIdentifiers"));

checkSuccessfulBulkLoad(sqtrBulkPostEndpoint, sqtrTestFilePath + "UE_01_update_empty_non_required_fields.json");
checkSuccessfulBulkLoad(sqtrBulkPostEndpoint, sqtrTestFilePath + "UE_01_update_empty_non_required_fields.json", 2);

RestAssured.given().
when().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ public VocabularyTerm addVocabularyTermToSet(String setName, String termName, Vo
}

public void checkFailedBulkLoad(String endpoint, String filePath) throws Exception {
checkFailedBulkLoad(endpoint, filePath, 1, 1, 0);
}

public void checkFailedBulkLoad(String endpoint, String filePath, int expectedTotalRecords, int expectedFailedRecords, int expectedCompletedRecords) throws Exception {
String content = Files.readString(Path.of(filePath));

RestAssured.given().
Expand All @@ -106,9 +110,9 @@ public void checkFailedBulkLoad(String endpoint, String filePath) throws Excepti
post(endpoint).
then().
statusCode(200).
body("history.totalRecords", is(1)).
body("history.failedRecords", is(1)).
body("history.completedRecords", is(0));
body("history.totalRecords", is(expectedTotalRecords)).
body("history.failedRecords", is(expectedFailedRecords)).
body("history.completedRecords", is(expectedCompletedRecords));
}

public void checkSuccessfulBulkLoad(String endpoint, String filePath) throws Exception {
Expand Down

0 comments on commit 644e2cb

Please sign in to comment.