From 644e2cb28e290835d1ab153d1f771801a457d387 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Tue, 9 Jul 2024 11:55:25 -0500 Subject: [PATCH] SCRUM-4185 update tests --- ...ceTargetingReagentBulkUploadFmsITCase.java | 41 +++++++++++++++---- .../curation_api/base/BaseITCase.java | 10 +++-- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/test/java/org/alliancegenome/curation_api/SequenceTargetingReagentBulkUploadFmsITCase.java b/src/test/java/org/alliancegenome/curation_api/SequenceTargetingReagentBulkUploadFmsITCase.java index b3bade7ef..8939c04a8 100644 --- a/src/test/java/org/alliancegenome/curation_api/SequenceTargetingReagentBulkUploadFmsITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/SequenceTargetingReagentBulkUploadFmsITCase.java @@ -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(). @@ -67,16 +67,41 @@ 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 + ); } @@ -84,7 +109,7 @@ public void sqtrBulkUploadEmptyRequiredFields() throws Exception { @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(). @@ -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(). @@ -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(). diff --git a/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java b/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java index 1ef4c4cb1..42c239537 100644 --- a/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java @@ -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(). @@ -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 {