Skip to content

Commit

Permalink
Address the review
Browse files Browse the repository at this point in the history
  • Loading branch information
Thevakumar-Luheerathan committed Apr 30, 2024
1 parent 7e03313 commit 8717340
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,28 +319,26 @@ function testWelcomeEmployee() {
// Stubbing to return a specific value in general
test:prepare(empClient).whenResource("employee/welcome/:id").onMethod("get").thenReturn("Stub_1");
// Stubbing to return a specific value on a specific path parameter
// Stubbing to return a specific value on specific path parameter
test:prepare(empClient).whenResource("employee/welcome/:id").onMethod("get").withPathParameters({id: "path1"}).thenReturn("Stub_2");
// Stubbing to return a specific value on a specific method arguments
// Stubbing to return a specific value on specific method arguments
test:prepare(empClient).whenResource("employee/welcome/:id").onMethod("get").withArguments("arg1", "arg2").thenReturn("Stub_3");
// Stubbing to return a specific value on a specific path parameter and method arguments
// Stubbing to return a specific value on specific path parameter and method arguments
test:prepare(empClient).whenResource("employee/welcome/:id").onMethod("get").withPathParameters({id: "path1"}).withArguments("arg1", "arg2").thenReturn("Stub_4");
// Specific path parameter and method arguments should take precedence over general stubbing
// Precedence is given to more specific stubbing over more general stubbing when a call is made to the resource with a particular set of path parameters, arguments, or both.
string result = empClient->/employee/welcome/["path1"].get(firstName = "arg1", lastName = "arg2");
test:assertEquals(result, "Stub_4");
// Specific method arguments should take precedence over general stubbing
result = empClient->/employee/welcome/["emp001"].get(firstName = "arg1", lastName = "arg2");
test:assertEquals(result, "Stub_3");
// Specific path parameter should take precedence over general stubbing
result = empClient->/employee/welcome/["path1"].get(firstName = "John", lastName = "Kibert");
test:assertEquals(result, "Stub_2");
// General stubbing should be used when no specific stubbing is available
result = empClient->/employee/welcome/["emp001"].get(firstName = "John", lastName = "Kibert");
test:assertEquals(result, "Stub_1");
}
Expand Down

0 comments on commit 8717340

Please sign in to comment.