generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Po 57 serenity automation for api testing (#85)
* implementation of serenity for backend int tests * Apply smoke/functional tasks for Serenity * Upgrade jackson * Checkstyle fixes * Artifact test reports * cleaning up unnecessary config and files --------- Co-authored-by: Dan Lysiak <danlysiak@hotmail.com>
- Loading branch information
1 parent
c1a4e1e
commit bf6becd
Showing
17 changed files
with
176 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
src/functionalTest/java/uk/gov/hmcts/opal/BaseFunctionalTest.java
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/functionalTest/java/uk/gov/hmcts/opal/Junit5RunnerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package uk.gov.hmcts.opal; | ||
|
||
import org.junit.platform.suite.api.IncludeEngines; | ||
import org.junit.platform.suite.api.SelectClasspathResource; | ||
import org.junit.platform.suite.api.Suite; | ||
|
||
@Suite | ||
@IncludeEngines("cucumber") | ||
@SelectClasspathResource("features") | ||
public class Junit5RunnerTest { | ||
|
||
} |
40 changes: 0 additions & 40 deletions
40
src/functionalTest/java/uk/gov/hmcts/opal/controllers/SampleFunctionalTest.java
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
src/functionalTest/java/uk/gov/hmcts/opal/steps/BaseStepDef.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package uk.gov.hmcts.opal.steps; | ||
|
||
public class BaseStepDef { | ||
|
||
private static final String TEST_URL = System.getenv().getOrDefault("TEST_URL", "http://localhost:4550"); | ||
|
||
protected String getTestUrl() { | ||
return TEST_URL; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/functionalTest/java/uk/gov/hmcts/opal/steps/HealthApiStepDef.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package uk.gov.hmcts.opal.steps; | ||
|
||
import io.cucumber.java.PendingException; | ||
import io.cucumber.java.en.And; | ||
import io.cucumber.java.en.Then; | ||
import net.serenitybdd.rest.SerenityRest; | ||
import org.hamcrest.Matchers; | ||
|
||
public class HealthApiStepDef extends BaseStepDef { | ||
|
||
@Then("I check the health of the fines api") | ||
public void checkHealthOfFinesApi() { | ||
System.out.println("Test URL: " + getTestUrl()); | ||
SerenityRest.when().get(getTestUrl() + "/health"); | ||
SerenityRest.then().assertThat().statusCode(200).and().body("status", Matchers.is("UP")); | ||
} | ||
|
||
@And("this test is todo") | ||
public void thisStepIsTodo() { | ||
//TODO step is todo | ||
throw new PendingException(); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/functionalTest/java/uk/gov/hmcts/opal/steps/NotesApiStepDef.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package uk.gov.hmcts.opal.steps; | ||
|
||
import io.cucumber.datatable.DataTable; | ||
import io.cucumber.java.en.When; | ||
import net.serenitybdd.rest.SerenityRest; | ||
import org.hamcrest.Matchers; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.util.Map; | ||
|
||
import static net.serenitybdd.rest.SerenityRest.then; | ||
|
||
public class NotesApiStepDef extends BaseStepDef { | ||
|
||
@When("I post the following data to the notes API") | ||
public void postToNotesApi(DataTable notesFields) throws JSONException { | ||
Map<String, String> dataToPost = notesFields.asMap(String.class, String.class); | ||
|
||
JSONObject body = new JSONObject(); | ||
body.put("associatedRecordId", dataToPost.get("recordId")); | ||
body.put("associatedRecordType", dataToPost.get("recordType")); | ||
body.put("noteText", dataToPost.get("noteText")); | ||
body.put("noteType", dataToPost.get("noteType")); | ||
body.put("postedBy", dataToPost.get("postedBy")); | ||
body.put("postedDate", dataToPost.get("postedDate")); | ||
if (dataToPost.get("noteId") != null) { | ||
body.put("noteId", dataToPost.get("noteId")); | ||
} | ||
SerenityRest.given() | ||
.accept("*/*") | ||
.contentType("application/json") | ||
.body(body.toString()) | ||
.when() | ||
.post(getTestUrl() + "/api/notes"); | ||
then().assertThat() | ||
.statusCode(201) | ||
.body("associatedRecordId", Matchers.equalTo(dataToPost.get("recordId"))) | ||
.body("associatedRecordType", Matchers.equalTo(dataToPost.get("recordType"))) | ||
.body("noteText", Matchers.equalTo(dataToPost.get("noteText"))) | ||
.body("noteType", Matchers.equalTo(dataToPost.get("noteType"))) | ||
.body("postedBy", Matchers.equalTo(dataToPost.get("postedBy"))); | ||
//.body("postedDate", equalTo(dataToPost.get("postedDate"))); | ||
} | ||
|
||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@Smoke | ||
Feature: test the application health API | ||
Scenario: I query the status of the health API | ||
Then I check the health of the fines api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@Smoke | ||
Feature: Notes API tests | ||
Scenario: I post some data to the Notes API and the response contains the correct Data - null noteID | ||
Given I post the following data to the notes API | ||
|recordId |123123 | | ||
|recordType |def_account | | ||
|noteText |Auto Test Note | | ||
|noteType |NT | | ||
|postedBy |Auto Test | | ||
|postedDate |2023-12-07T11:21:48.677Z | | ||
|noteID | | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
cucumber.execution.parallel.enabled=true | ||
cucumber.execution.parallel.config.strategy=dynamic | ||
|
||
cucumber.plugin=io.cucumber.core.plugin.SerenityReporterParallel,pretty,json:target/cucumber.json,timeline:target/test-results/timeline | ||
cucumber.snippet-type=camelcase | ||
cucumber.publish.enabled=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
serenity{ | ||
project.name=Opal Automation | ||
reports.show.step.details=true | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.