Skip to content

Commit

Permalink
Merge pull request #50 from ProjectEKA/addcarecontext
Browse files Browse the repository at this point in the history
[Haripriya] Add care context api test automation
  • Loading branch information
msharma-tw authored Apr 19, 2021
2 parents 12e06d9 + de621b5 commit e647b4a
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/test/java/tests/apitests/gateway/TestBuilders.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package tests.apitests.gateway;

import tests.apitests.gateway.models.*;
import tests.apitests.gateway.models.addCareContext.AddCareContextPayLoad;
import tests.apitests.gateway.models.addCareContext.CareContextAdd;
import tests.apitests.gateway.models.addCareContext.Link;
import tests.apitests.gateway.models.addCareContext.PatientCarecontext;
import tests.apitests.helpers.PropertiesCache;

import java.time.LocalDateTime;
Expand All @@ -11,6 +15,8 @@
import static tests.apitests.helpers.TestDataLiterals.DATE_FORMAT;

public class TestBuilders {
private static final String ACCESSTOKEN = "eyJhbGciOiJSUzUxMiJ9.eyJzdWIiOiI2Ny02MjA2LTA2MDctMjUzMSIsInJlcXVlc3RlclR5cGUiOiJISVAiLCJyZXF1ZXN0ZXJJZCI6IlRFU1RfQlJJREdFX1FBIiwicGF0aWVudElkIjoiNjctNjIwNi0wNjA3LTI1MzEiLCJzZXNzaW9uSWQiOiJmMzAyZmQyNC1kMWEwLTRmYWQtYTViMi1lYTljZjFhNjg2M2IiLCJleHAiOjE2MTg2NDI5MDIsImlhdCI6MTYxODU1NjUwMn0.Cuqs4e55il86lf8JTOM9LhQhbxN0fUP7lD7LpnPag6Y_xRLUi7QoYyJfU8WMnC0fHGnMXeCwO3hgORsgatzWq_RfpL2580d9mRps1ZeYtdfddYzvxG6de_FxM_soClqb5rA8vLcpHOqO0H-5E4GFDN4W-VyWH2tZmftoyArJb6qE21s89-PpiYxI72TXJrPn4euZ3NWoh-09c09tRMrMlOUcnKnwvGuASFO_zxXnAtQUvW3WZIwS9ELcqqOprT4o-fAY1m7TexGYClvTcV7piSvD-dqWJmcRxlSiy-_GxXEH5tZbnhYoAEeLCa3kulVIpUVkicTkwbQ2a8Mb59hE4w";

public static LoginPayLoad gatewayPayload() {
return LoginPayLoad.builder()
.clientId("TEST_BRIDGE_QA")
Expand All @@ -26,12 +32,26 @@ public static AuthRequestPayload authRequestPayload() {
.requestId(uid)
.timestamp(date)
.query(AuthQuery.builder().id(PropertiesCache.getInstance().getProperty("username"))
.purpose("KYC")
.purpose("KYC_AND_LINK")
.authMode("DIRECT")
.requester(AuthRequester.builder().type("HEALTH_LOCKER").id("10000010").build()).build())
.requester(AuthRequester.builder().type("HIP").id("TEST_BRIDGE_QA").build()).build())
.build();
}

public static AddCareContextPayLoad addCareContextPayLoad(){
return AddCareContextPayLoad.builder()
.requestId(generateUUID())
.timestamp(dateFormatter())
.link(Link.builder()
.accessToken(ACCESSTOKEN)
.patient(PatientCarecontext.builder()
.referenceNumber("001")
.display("001")
.careContexts(List.of(CareContextAdd.builder()
.referenceNumber("1")
.display("1").build())).build()).build()).build();
}

public static SubscriptionRequestPayLoad subscriptionRequestPayLoad() {
String uid = generateUUID();
String date = dateFormatter();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package tests.apitests.gateway.models.addCareContext;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class AddCareContextPayLoad {
String requestId;
String timestamp;
Link link;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package tests.apitests.gateway.models.addCareContext;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class CareContextAdd {
String referenceNumber;
String display;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package tests.apitests.gateway.models.addCareContext;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class Link {
String accessToken;
PatientCarecontext patient;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package tests.apitests.gateway.models.addCareContext;

import lombok.Builder;
import lombok.Data;

import java.util.List;

@Data
@Builder
public class PatientCarecontext {
String referenceNumber;
String display;
List<CareContextAdd> careContexts;
}
35 changes: 35 additions & 0 deletions src/test/java/tests/apitests/gateway/tests/AddCareContext.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package tests.apitests.gateway.tests;

import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import tests.apitests.helpers.utils.Login;

import static tests.apitests.gateway.TestBuilders.addCareContextPayLoad;

public class AddCareContext {
String authToken;
RequestSpecification request;
JsonPath jsonPathEvaluator;

@BeforeClass
public void setup() {
authToken = new Login().getGatewayAuthToken();
}

@Test
public void addCareContext() {
request = RestAssured.given();
request.header("Authorization", authToken);
request.header("X-CM-ID", "ndhm");
Response response = request.body(addCareContextPayLoad()).post("/v0.5/links/link/add-contexts");
jsonPathEvaluator = response.jsonPath();
response.prettyPrint();
Assert.assertEquals(response.getStatusCode(), 202);
}

}

0 comments on commit e647b4a

Please sign in to comment.