From 69cd26cc195340c05cbc0061f4431c70fe48553b Mon Sep 17 00:00:00 2001 From: Paul Harrison Date: Mon, 25 Mar 2024 15:52:55 +0000 Subject: [PATCH 1/4] make the unit tests work after the example updates Hopefully! --- .github/workflows/gradle.yml | 2 +- .../pst/apiimpl/rest/PersonResourceTest.java | 6 +++--- .../pst/apiimpl/rest/ProposalResourceTest.java | 18 +++++++++--------- .../pst/apiimpl/rest/UseCasePiTest.java | 10 +++++----- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 14fab35..6379962 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -53,7 +53,7 @@ jobs: cache-overwrite-existing: true - name: Run Gradle build working-directory: ./main - run: ./gradlew -U --info build + run: ./gradlew -U build - name: Upload interface definition uses: actions/upload-artifact@v3.1.3 diff --git a/src/test/java/org/orph2020/pst/apiimpl/rest/PersonResourceTest.java b/src/test/java/org/orph2020/pst/apiimpl/rest/PersonResourceTest.java index 5deef06..f43dfd6 100644 --- a/src/test/java/org/orph2020/pst/apiimpl/rest/PersonResourceTest.java +++ b/src/test/java/org/orph2020/pst/apiimpl/rest/PersonResourceTest.java @@ -24,7 +24,7 @@ void testGetPeople() { void testFilterPeople() { given() .when() - .param("name","PI") + .param("name","John Flamsteed") .get("people") .then() .statusCode(200) @@ -39,7 +39,7 @@ void testGetPerson() { Integer personId = given() .when() - .param("name","PI") + .param("name","John Flamsteed") .get("people") .then() .statusCode(200) @@ -54,7 +54,7 @@ void testGetPerson() { .then() .statusCode(200) .body( - containsString("\"fullName\":\"PI\"") + containsString("\"fullName\":\"John Flamsteed\"") ); } } diff --git a/src/test/java/org/orph2020/pst/apiimpl/rest/ProposalResourceTest.java b/src/test/java/org/orph2020/pst/apiimpl/rest/ProposalResourceTest.java index 22cb008..a149901 100644 --- a/src/test/java/org/orph2020/pst/apiimpl/rest/ProposalResourceTest.java +++ b/src/test/java/org/orph2020/pst/apiimpl/rest/ProposalResourceTest.java @@ -20,7 +20,7 @@ import static org.hamcrest.Matchers.*; @QuarkusTest -@TestSecurity(user = "pi", roles = "default-roles-orppst") +@TestSecurity(user="John Flamsteed", roles = "default-roles-orppst") public class ProposalResourceTest { String JSON_UTF16 = "application/json; charset=UTF-16"; @Inject @@ -36,7 +36,7 @@ void setup() { })); proposalId = given() .when() - .param("title", "%title") + .param("title", "Observing the stars") .get("proposals") .then() .statusCode(200) @@ -48,7 +48,7 @@ void setup() { Integer coiInvestigatorId = given() .when() - .param("fullName", "CO-I") + .param("fullName", "George Airy") .get("people") .then() .body( @@ -75,7 +75,7 @@ void testGetObservingProposal() { .then() .statusCode(200) .body( - containsString("\"title\":\"the proposal title\",") + containsString("\"title\":\"Observing the stars\",") ) ; @@ -97,7 +97,7 @@ void testListSpecificProposal() Integer relatedProposalId = given() .when() - .param("title","the proposal title") + .param("title","Observing the stars") .get("proposals") .then() .statusCode(200) @@ -132,14 +132,14 @@ void testReplaceJustification() throws JsonProcessingException { void testReplaceTitle() { //replace title with another given() - .body("replacement title") + .body("Observing something else") .header("Content-Type", MediaType.TEXT_PLAIN) .when() .put("proposals/"+proposalId+"/title") .then() .statusCode(201) .body( - containsString("replacement title") + containsString("Observing something else") ) ; @@ -147,13 +147,13 @@ void testReplaceTitle() { @Test - void testAddPersonAsInvestigator() { + void testUpdateCoInvestigator() { Investigator coiInvestigator = new Investigator(InvestigatorKind.COI, true, person); //first get the DB id of the newly added COI Investigator Integer coiInvestigatorId = given() .when() - .param("fullName", "CO-I") + .param("fullName", "George Airy") .get("proposals/"+proposalId+"/investigators") .then() .body( diff --git a/src/test/java/org/orph2020/pst/apiimpl/rest/UseCasePiTest.java b/src/test/java/org/orph2020/pst/apiimpl/rest/UseCasePiTest.java index 4685fe1..e252f39 100644 --- a/src/test/java/org/orph2020/pst/apiimpl/rest/UseCasePiTest.java +++ b/src/test/java/org/orph2020/pst/apiimpl/rest/UseCasePiTest.java @@ -82,7 +82,7 @@ void testCreateProposal() throws JsonProcessingException { //find the PI int personid = given() .when() - .param("name","PI") + .param("name","John Flamsteed") .get("people") .then() .statusCode(200) @@ -99,7 +99,7 @@ void testCreateProposal() throws JsonProcessingException { .then() .statusCode(200) .body( - "fullName", equalTo("PI") + "fullName", equalTo("John Flamsteed") ).extract().as(Person.class, raObjectMapper); @@ -138,7 +138,7 @@ void testCreateProposal() throws JsonProcessingException { int coiPersonId = given() .when() - .param("name","CO-I") + .param("name","George Airy") .get("people") .then() .statusCode(200) @@ -155,7 +155,7 @@ void testCreateProposal() throws JsonProcessingException { .then() .statusCode(200) .body( - "fullName", equalTo("CO-I") + "fullName", equalTo("George Airy") ).extract().as(Person.class, raObjectMapper); //create a new Investigator @@ -231,7 +231,7 @@ void testCreateProposal() throws JsonProcessingException { Integer relatedProposalId = given() .when() - .param("title","%title%") // note only searching for title in part as other tests change this + .param("title","%Observing%") // note only searching for title in part as other tests change this .get("proposals") .then() .statusCode(200) From 1e43f0a8378b54777cf825869651cdf86067fe36 Mon Sep 17 00:00:00 2001 From: Paul Harrison Date: Mon, 25 Mar 2024 16:30:20 +0000 Subject: [PATCH 2/4] try to publish test result summary --- .github/workflows/gradle.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 6379962..e9b4f99 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -67,4 +67,10 @@ jobs: working-directory: ./main run: ./gradlew --info test - + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + files: | + main/build/test-results/**/*.xml + From e7f10ace8808869f5df7df97328bdc74d49bd848 Mon Sep 17 00:00:00 2001 From: Paul Harrison Date: Mon, 25 Mar 2024 16:47:41 +0000 Subject: [PATCH 3/4] try to publish test result summary increase permissions --- .github/workflows/gradle.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index e9b4f99..010d101 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -15,12 +15,13 @@ on: permissions: contents: read + checks: write + pull-requests: write jobs: build: runs-on: ubuntu-latest - steps: - name: Checkout this repo uses: actions/checkout@v4 From 7fb4b205bee60cac67429e66db1cd703c18b2288 Mon Sep 17 00:00:00 2001 From: Paul Harrison Date: Mon, 25 Mar 2024 16:59:01 +0000 Subject: [PATCH 4/4] try to publish test result summary separate build and test --- .github/workflows/gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 010d101..bc5f4c1 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -54,7 +54,7 @@ jobs: cache-overwrite-existing: true - name: Run Gradle build working-directory: ./main - run: ./gradlew -U build + run: ./gradlew -U build -x test - name: Upload interface definition uses: actions/upload-artifact@v3.1.3