-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
Feature/add dynamic path param support #1808
Merged
MahmoudElSharkawy
merged 15 commits into
ShaftHQ:main
from
KyrillosNageh:feature/add-dynamic-pathParam-support
Dec 12, 2024
Merged
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e0562fb
Add dynamic path parameter support with overloaded setPathParam methods
57cce59
Add dynamic path parameter support with overloaded setPathParam methods
77a6f5c
Add setPathParamValues method for path parameter value substitution
a3bafc2
Add support for PATH parameters in setParameters method
b67a20f
Add support for PATH parameters in setParameters method
5415455
Add support for PATH parameters in setParameters method
86d1635
Adjust it to contains 2 methods to set path Parameters
88e3c14
Add dynamic path parameter support with Map and ordered values
bd0b82a
Add dynamic path parameter support with Map and ordered values
0fcc119
Add dynamic path parameter support with Map and ordered values
b2e9143
Add dynamic path parameter support with Map and ordered values
c5d3633
Add dynamic path parameter support with Map and ordered values
dc3022e
Add dynamic path parameter support with Map and ordered values
4e2f01d
Add dynamic path parameter support with Map and ordered values
1e4d450
Add dynamic path parameter support with Map and ordered values
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.shaft.api; | ||
|
||
import com.shaft.driver.SHAFT; | ||
import org.testng.annotations.*; | ||
import java.util.*; | ||
|
||
|
||
public class PathParamTest { | ||
// Initialize SHAFT.API with the base URI | ||
SHAFT.API api = new SHAFT.API("https://petstore.swagger.io/v2"); | ||
public static final String GET_USER_BY_USERNAME = "/user/{username}"; // Get user by username | ||
|
||
@Test | ||
public void GetUserByUsernameMap() { | ||
|
||
Map<String, Object> parameters = Map.of( | ||
"username", "string"); | ||
// Perform the GET request | ||
api.get(GET_USER_BY_USERNAME) // Endpoint with a placeholder | ||
.setPathParameters(parameters) // Substitute the placeholder dynamically | ||
.setTargetStatusCode(200) // Expected status code | ||
.perform(); // Execute the request | ||
|
||
SHAFT.Report.log(">>>>>> Response Body:" + api.getResponseBody()); | ||
} | ||
|
||
@Test | ||
public void GetUserByUsernameValue() { | ||
// Perform the GET request | ||
api.get("/user/{username}") // Endpoint with a placeholder | ||
.setPathParameters( "string") // Pass the value for the placeholder | ||
.setContentType("application/json") | ||
.setTargetStatusCode(200) | ||
.perform(); | ||
|
||
SHAFT.Report.log(">>>>>> Response Body:" + api.getResponseBody()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add assertion to validate the response. |
||
} | ||
|
||
@Test | ||
public void N_GetUserByUsernameTest3() { | ||
api.get("/{resource}/{username}") | ||
.setContentType("application/json") | ||
.setPathParameters("user", "string") | ||
.setTargetStatusCode(200) | ||
.perform(); | ||
|
||
SHAFT.Report.log("Response Body: " + api.getResponseBody()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add assertion to validate the response. |
||
} | ||
} |
Oops, something went wrong.
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.
please add assertion to validate the response.