-
Notifications
You must be signed in to change notification settings - Fork 0
Create smoke tests #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Pradhumn-1
wants to merge
8
commits into
master
Choose a base branch
from
create-smoke-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9aebc5f
rest api framework
168992c
Merge branch 'master' into create-smoke-tests
aef3845
updated delete method and urls
6bb5984
updated formatting
c1f831f
updated the changes you asked
5b3d320
updated pom file
861de67
updated pom file with .version
4825c59
did the changes you asked except one
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
64 changes: 64 additions & 0 deletions
64
tests/smoke-tests/src/main/java/com/techorgx/api/CustomerServiceTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| package com.techorgx.api; | ||
|
|
||
| import com.github.javafaker.Faker; | ||
| import com.techorgx.api.endpoints.UserEndPoints; | ||
| import com.techorgx.api.payload.User; | ||
| import io.restassured.response.Response; | ||
| import org.apache.http.HttpStatus; | ||
| import org.testng.annotations.BeforeClass; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| public class CustomerServiceTest { | ||
| Faker faker; | ||
| User userPayload; | ||
|
|
||
| @BeforeClass | ||
| public void setupData() { | ||
| faker = new Faker(); | ||
| userPayload = new User(); | ||
| userPayload.setUsername(faker.name().username()); | ||
| userPayload.setFirstName(faker.name().firstName()); | ||
| userPayload.setLastName(faker.name().lastName()); | ||
| userPayload.setAddress(faker.address().streetAddress()); | ||
| userPayload.setCity(faker.address().city()); | ||
| userPayload.setPincode(faker.address().zipCode()); | ||
| userPayload.setEmail(faker.internet().safeEmailAddress()); | ||
| } | ||
|
|
||
| @Test(priority = 1) | ||
| public void testPostUser() { | ||
| Response response = UserEndPoints.createUser(userPayload); | ||
| response.then().log().all() | ||
| .statusCode(HttpStatus.SC_ACCEPTED); | ||
| } | ||
|
|
||
| @Test(priority = 2) | ||
| public void testGetUserByName() { | ||
| Response response = UserEndPoints.readUser(this.userPayload.getUsername()); | ||
| response.then().log().all() | ||
| .statusCode(HttpStatus.SC_OK); | ||
| } | ||
|
|
||
| @Test(priority = 3) | ||
| public void testUpdateUser() { | ||
|
|
||
| userPayload.setFirstName(faker.name().firstName()); | ||
| userPayload.setLastName(faker.name().lastName()); | ||
|
|
||
| Response response = UserEndPoints.updateUser(this.userPayload.getUsername(), userPayload); | ||
| response.then().log().all() | ||
| .statusCode(HttpStatus.SC_OK); | ||
|
|
||
| //Checking data after update | ||
| Response responseAfterUpdation=UserEndPoints.readUser (this.userPayload.getUsername()); | ||
| responseAfterUpdation.then().log().all() | ||
| .statusCode(HttpStatus.SC_OK); | ||
| } | ||
|
|
||
| @Test(priority = 4) | ||
| public void testDeleteUserByName() { | ||
| Response response = UserEndPoints.deleteUser(this.userPayload.getUsername()); | ||
| response.then().log().all() | ||
| .statusCode(HttpStatus.SC_OK); | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
tests/smoke-tests/src/main/java/com/techorgx/api/endpoints/Routes.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.techorgx.api.endpoints; | ||
|
|
||
| //Base url: http://localhost:7979/v1/customer-service | ||
| //Create user(POST) : http://localhost:7979/v1/customer-service/add-customer | ||
| //Get User (GET): http://localhost:7979/v1/customer-service/get-customer?id= | ||
| public class Routes { | ||
| public final static String BASE_URL = "http://localhost:7979/v1/customer-service"; | ||
| public final static String POST_URL = BASE_URL + "/add-customer"; | ||
| public final static String GET_URL = BASE_URL + "/get-customer"; | ||
| public static String UPDATE_URL = BASE_URL + "/update-customer"; | ||
| public static String DELETE_URL = BASE_URL + "/delete-customer"; | ||
| } |
55 changes: 55 additions & 0 deletions
55
tests/smoke-tests/src/main/java/com/techorgx/api/endpoints/UserEndPoints.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package com.techorgx.api.endpoints; | ||
|
|
||
| // UserEndPints.java | ||
| // Created for perform Create, Read, Update, Delete requests t the user API | ||
| import com.techorgx.api.payload.User; | ||
| import io.restassured.http.ContentType; | ||
| import io.restassured.response.Response; | ||
| import static io.restassured.RestAssured.given; | ||
| public class UserEndPoints { | ||
|
|
||
| private final static String CLIENT_ID = "test"; | ||
| public static Response createUser(User payload) { | ||
| Response response = given() | ||
| .contentType(ContentType.JSON) | ||
| .accept(ContentType.JSON) | ||
| .header("client-id", CLIENT_ID) | ||
| .body(payload) | ||
| .when() | ||
| .post(Routes.POST_URL); | ||
| return response; | ||
| } | ||
| public static Response readUser(String username) { | ||
| System.out.println("readUser " + username); | ||
| String id = username; | ||
| Response response = given() | ||
| .queryParam("id", username) | ||
| .header("client-id", CLIENT_ID) | ||
| .when() | ||
| .get(Routes.GET_URL); | ||
| return response; | ||
| } | ||
| public static Response updateUser (String username, User payload) | ||
| { | ||
| Response response=given() | ||
| .contentType(ContentType.JSON) | ||
| .accept(ContentType.JSON) | ||
| .queryParam("id" , username) | ||
| .header("client-id", CLIENT_ID) | ||
| .body (payload) | ||
| .when() | ||
| .put(Routes.UPDATE_URL); | ||
| return response; | ||
| } | ||
| public static Response deleteUser (String username) | ||
| { | ||
| Response response=given() | ||
| .contentType(ContentType.JSON) | ||
| .accept(ContentType.JSON) | ||
| .queryParam("id" , username) | ||
| .header("client-id", CLIENT_ID) | ||
| .when() | ||
| .delete(Routes.DELETE_URL); | ||
| return response; | ||
| } | ||
| } |
54 changes: 54 additions & 0 deletions
54
tests/smoke-tests/src/main/java/com/techorgx/api/payload/User.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package com.techorgx.api.payload; | ||
|
|
||
| public class User { | ||
| private String city; | ||
| private String pincode; | ||
| private String email; | ||
| private String username; | ||
| private String firstName; | ||
| private String lastName; | ||
| private String address; | ||
|
|
||
| public String getUsername() { | ||
|
Pradhumn-1 marked this conversation as resolved.
|
||
| return username; | ||
| } | ||
| public void setUsername(String username) { | ||
| this.username = username; | ||
| } | ||
| public String getFirstName() { | ||
| return firstName; | ||
| } | ||
| public void setFirstName(String firstName) { | ||
| this.firstName = firstName; | ||
| } | ||
| public String getLastName() { | ||
| return lastName; | ||
| } | ||
| public void setLastName(String lastName) { | ||
| this.lastName = lastName; | ||
| } | ||
| public String getAddress() { | ||
| return address; | ||
| } | ||
| public void setAddress(String address) { | ||
| this.address = address; | ||
| } | ||
| public String getCity() { | ||
| return city; | ||
| } | ||
| public void setCity(String city) { | ||
| this.city = city; | ||
| } | ||
| public String getPincode() { | ||
| return pincode; | ||
| } | ||
| public void setPincode(String pincode) { | ||
| this.pincode = pincode; | ||
| } | ||
| public String getEmail() { | ||
| return email; | ||
| } | ||
| public void setEmail(String email) { | ||
| this.email = email; | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are still using version directly on this line, use property instead.
You defined properties on line 28 for this then don't use 5.3.1 directly here, refer to line 99 to understand how to use properties.