Skip to content

Commit

Permalink
Add a complex test case
Browse files Browse the repository at this point in the history
  • Loading branch information
dilanSachi committed Jun 13, 2023
1 parent a09dfa2 commit b528cb0
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void testUrlTemplateWithMultipleQueryParamWithURIEncodeCharacterDispatchi
}

@Test(description = "Test dispatching with query params.")
public void testUrlTemplateWithMultipleQueryParamWithoutURIEncode() {
public void testUrlTemplateWithQueryParamWithoutURIEncode() {
String path = "/ecommerceservice/productsQueryParam?products={%22p1%22:%22name1%22%2C%22p2%22:%22name2%22}";
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage(path, "GET");
HttpCarbonMessage response = Services.invoke(TEST_EP_PORT, cMsg);
Expand All @@ -191,6 +191,20 @@ public void testUrlTemplateWithMultipleQueryParamWithoutURIEncode() {
"{\"p1\":\"name1\",\"p2\":\"name2\"}", "ProductID variable not set properly.");
}

@Test(description = "Test dispatching with nested json query params.")
public void testUrlTemplateWithNestedJsonQueryParamWithoutURIEncode() {
String path = "/ecommerceservice/productsQueryParam?products={%22products%22:[{%22productOneOf%22:" +
"{%22productId%22:%220123456789%22%2C%22productCategory%22:%22LargeProduct%22}}]}";
HTTPTestRequest cMsg = MessageUtils.generateHTTPMessage(path, "GET");
HttpCarbonMessage response = Services.invoke(TEST_EP_PORT, cMsg);
Assert.assertNotNull(response, "Response message not found");
//Expected Json message : {"Products":{"p1":"name1","p2":"name2"}}
BValue bJson = JsonParser.parse(new HttpMessageDataStreamer(response).getInputStream());
Assert.assertEquals(((BMap<String, BValue>) bJson).get("Products").stringValue(),
"{\"products\":[{\"productOneOf\":{\"productId\":\"0123456789\",\"productCategory\":\"LargeProduct\"}}]}",
"ProductID variable not set properly.");
}

@DataProvider(name = "validUrl")
public static Object[][] validUrl() {
return new Object[][]{
Expand Down

0 comments on commit b528cb0

Please sign in to comment.