0

I have 2 classes

class APIDriver 

    protected RequestSpecification generateCommonReqSpecJsonWithQueryParams(Map<String, Object> params)
    {
        return given().accept(ContentType.JSON).queryParams(params);
    }
public class Demo extends APIDriver{
    @Test (groups = "sanity", description = "first API test")
    public void givenUserDoesNotExists_whenUserInfoIsRetrieved_then404IsReceived()
    throws Exception {
        ExtentTestManager.getTest().log(LogStatus.INFO, "Test started");
        String name = RandomStringUtils.randomAlphabetic( 8 );
        String url = "https://api.github.com/users/" + name;
        RequestSpecification spec = generateCommonReqSpecJsonWithQueryParams(//);
        Response resp = RestOperationUtils.get(url, spec, null);
        APIResponse apiResp = new APIResponse(resp);
        assert apiResp.getStatusCode()==404;

How do i pass the following parameters and its value over here along with the request?

param1
(key--->1234)
param2
(loc--->34.56)
Andreas
  • 154,647
  • 11
  • 152
  • 247
icantcode
  • 167
  • 15
  • 2
    Please format (indent) the code for human readability. – Andreas Apr 20 '19 at 15:58
  • Apologies. I did use the formatter to highlight the code. What else i am missing? Can you help me format it? I need to get an answer for the same urgently. – icantcode Apr 20 '19 at 16:04
  • Since the method needs a `Map` as parameter, you create a `Map`, add the key/value mappings you want, and then pass that. Since you likely don't care about order (JSON doesn't), you should create a `HashMap`. --- I'm curious though. When you **researched** this, how did you manage to avoid finding answers like [Create Map in Java](https://stackoverflow.com/q/14743516/5221149)? – Andreas Apr 20 '19 at 16:04

0 Answers0