Created
February 28, 2018 19:16
-
-
Save sayems/f8298fbcc5dffbafd2ff5b91832e55a6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| public class Rec87 { | |
| private PropertiesUtil factory; | |
| private List<String> listX; | |
| private List<String> listY; | |
| private String userIdX; | |
| private String locationNameX; | |
| private String userNameX; | |
| private String userUuidX; | |
| private String locationUuidX; | |
| private String userEmailX; | |
| private String userIdY; | |
| private String locationNameY; | |
| private String userNameY; | |
| private String userUuidY; | |
| private String locationUuidY; | |
| private String userEmailY; | |
| private String eUuidX; | |
| private String jWTX; | |
| private String eUuidY; | |
| // private String postContentX; | |
| private String postUuidX; | |
| // private String featureIdX; | |
| private String targetContentX; | |
| private String targetPostUuidX; | |
| @Parameters("properties") | |
| public Rec87(@Optional(Repository.PROPERTIES) String properties) throws IOException { | |
| factory = PropertiesUtil.create(properties); | |
| } | |
| @BeforeClass | |
| public void beforeClass() throws SQLException, ClassNotFoundException, IOException { | |
| RecApiUtil recApiUtil = new RecApiUtil(Repository.PROPERTIES); | |
| // getUserXYTestData | |
| listX = RedshiftUtil.getValidUserX(); | |
| userIdX = listX.get(0); | |
| System.out.println("Valid User Id X"); | |
| System.out.println(userIdX); | |
| userUuidX = listX.get(1); | |
| System.out.println("Valid User UUID X"); | |
| System.out.println(userUuidX); | |
| userNameX = listX.get(2); | |
| System.out.println("Valid User Name X"); | |
| System.out.println(userNameX); | |
| locationUuidX = listX.get(3); | |
| System.out.println("Valid User Location UUID X"); | |
| System.out.println(locationUuidX); | |
| locationNameX = listX.get(4); | |
| System.out.println("Valid User Location Name X"); | |
| System.out.println(locationNameX); | |
| RedshiftUtil.disconnectX(); | |
| listY = RedshiftUtil.getValidUserY(); | |
| userIdY = listY.get(0); | |
| System.out.println("Valid User Id Y"); | |
| System.out.println(userIdY); | |
| userUuidY = listY.get(1); | |
| System.out.println("Valid User UUID Y"); | |
| System.out.println(userUuidY); | |
| userNameY = listY.get(2); | |
| System.out.println("Valid User Name Y"); | |
| System.out.println(userNameY); | |
| locationUuidY = listY.get(3); | |
| System.out.println("Valid User Location UUID Y"); | |
| System.out.println(locationUuidY); | |
| locationNameY = listY.get(4); | |
| System.out.println("Valid User Location Name Y"); | |
| System.out.println(locationNameY); | |
| RedshiftUtil.disconnectY(); | |
| userEmailX = RedshiftUtil.getUserEmailX(userIdX); | |
| System.out.println("Valid User Email X"); | |
| System.out.println(userEmailX); | |
| RedshiftUtil.disconnectUserEmailX(); | |
| userEmailY = RedshiftUtil.getUserEmailY(userIdY); | |
| System.out.println("Valid User Email Y"); | |
| System.out.println(userEmailY); | |
| RedshiftUtil.disconnectUserEmailY(); | |
| // getUserEuuidX | |
| RestAssured.baseURI = factory.data(Repository.WE_AUTH_URL); | |
| String request = recApiUtil.getUserEuuid(userEmailX); | |
| JsonPath response = recApiUtil.postRequest(request, "/api/sessions"); | |
| Assert.assertNotNull(response); | |
| eUuidX = response.getString("result.session.encrypted_user_uuid"); | |
| System.out.println("EUUID"); | |
| System.out.println(eUuidX); | |
| // getJwtX | |
| RestAssured.baseURI = factory.data(Repository.WE_AUTH_URL); | |
| request = Json.createObjectBuilder() | |
| .add("api_key", factory.data(Repository.WE_AUTH_API_KEY)) | |
| .add("encrypted_user_uuid", eUuidX) | |
| .build().toString(); | |
| response = given().contentType("application/json") | |
| .contentType("application/json") | |
| .body(request) | |
| .expect() | |
| .statusCode(200) | |
| .when() | |
| .post("/api/tokens").jsonPath(); | |
| Assert.assertNotNull(response); | |
| jWTX = response.getString("result.jwt"); | |
| System.out.println("WE AUTH JWT"); | |
| System.out.println(jWTX); | |
| // getUserEuuidY | |
| RestAssured.baseURI = factory.data(Repository.WE_AUTH_URL); | |
| request = Json.createObjectBuilder() | |
| .add("api_key", factory.data(Repository.WE_AUTH_API_KEY)) | |
| .add("username", userEmailY) | |
| .add("password", factory.data(Repository.MASTER_PASSWORD)) | |
| .add("include_encrypted_user_uuid", "true") | |
| .build().toString(); | |
| response = given().contentType("application/json") | |
| .contentType("application/json") | |
| .body(request) | |
| .expect() | |
| .statusCode(200) | |
| .when() | |
| .post("/api/sessions").jsonPath(); | |
| Assert.assertNotNull(response); | |
| eUuidY = response.getString("result.session.encrypted_user_uuid"); | |
| System.out.println("EUUID Y"); | |
| System.out.println(eUuidY); | |
| RestAssured.baseURI = factory.data(Repository.MENA_ENDPOINT_V5); | |
| request = Json.createObjectBuilder() | |
| .add("encrypted_user_uuid", eUuidX) | |
| .add("photo_url", "") | |
| .add("post_content", "Feature_87 recs_qa_auto_testing NEW POST TEXT/X1/TEST") | |
| .build().toString(); | |
| JsonPath res = given().contentType("application/json") | |
| .header("authorization", "Bearer " + jWTX) | |
| .body(request) | |
| .expect() | |
| .statusCode(200) | |
| .when() | |
| .post("/posts").jsonPath(); | |
| assertNotNull(res); | |
| // postContentX = res.getString("content"); | |
| postUuidX = res.getString("uuid"); | |
| // System.out.println("Post Content"); | |
| // System.out.println(postContentX); | |
| System.out.println("Post UUID"); | |
| System.out.println(postUuidX); | |
| // likePostY | |
| RestAssured.baseURI = factory.data(Repository.MENA_ENDPOINT_V4); | |
| res = given().contentType("application/json") | |
| .queryParam("encrypted_user_uuid", eUuidY) | |
| .expect() | |
| .statusCode(200) | |
| .when() | |
| .post("/posts/" + postUuidX + "/like?encrypted_user_uuid=" + eUuidY).jsonPath(); | |
| assertNotNull(res); | |
| // post2ToFeedX87 | |
| RestAssured.baseURI = factory.data(Repository.MENA_ENDPOINT_V5); | |
| request = Json.createObjectBuilder() | |
| .add("encrypted_user_uuid", eUuidX) | |
| .add("photo_url", "") | |
| .add("post_content", "Feature_87 recs_qa_auto_testing NEW POST TEXT/X2/TEST") | |
| .build().toString(); | |
| res = given().contentType("application/json") | |
| .header("authorization", "Bearer " + jWTX) | |
| .body(request) | |
| .expect() | |
| .statusCode(200) | |
| .when() | |
| .post("/posts").jsonPath(); | |
| assertNotNull(res); | |
| targetContentX = res.getString("content"); | |
| targetPostUuidX = res.getString("uuid"); | |
| // featureIdX = res.getString("feature_id"); | |
| System.out.println("Post Content"); | |
| System.out.println(targetContentX); | |
| System.out.println("Post UUID"); | |
| System.out.println(targetPostUuidX); | |
| // System.out.println("Feature ID"); | |
| // System.out.println(featureIdX); | |
| // addXToSplit | |
| RestAssured.baseURI = factory.data(Repository.SPLIT_URL); | |
| String req = "[{\"op\": \"add\", \"path\": \"/treatments/0/keys/1\", \"value\": \"" + userUuidX + "\"}]"; | |
| res = given().contentType("application/json") | |
| .header("Authorization", "Bearer " + factory.data(Repository.SPLIT_ADMIN_API_KEY)) | |
| .body(req) | |
| .expect() | |
| .statusCode(200) | |
| .when() | |
| .patch() | |
| .jsonPath(); | |
| assertNotNull(res); | |
| // addYToSplit | |
| RestAssured.baseURI = factory.data(Repository.SPLIT_URL); | |
| req = "[{\"op\": \"add\", \"path\": \"/treatments/0/keys/1\", \"value\": \"" + userUuidY + "\"}]"; | |
| res = given().contentType("application/json") | |
| .header("Authorization", "Bearer " + factory.data(Repository.SPLIT_ADMIN_API_KEY)) | |
| .body(req) | |
| .expect() | |
| .statusCode(200) | |
| .when() | |
| .patch() | |
| .jsonPath(); | |
| assertNotNull(res); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment