I'm starting with API Automation Tests, so I'm in doubt how can I use the Cucumbers Steps to validate the API response.
I create a feature to cucumber with this steps:
    @criarConta
        Scenario Outline: Criar uma conta valida
            Given que realizo a chamada no <ambiente> da <api> informando <token_admin> e um email e <senha> novos
            Then devera retornar <status code> 
            And no response devera retornar um valor de "ID" ou "Message" 
On my "dataMap" class, I'm doing the fallow request and validate:
public void criarConta(String srtAmbiente, String srtAPI, String srtToken, String srtSenha) {
            String uriBase = srtAmbiente;
            RequestSpecification apiRequest = RestAssured.given().contentType(ContentType.JSON);
            int length = 15;
            String email = generateRandomEmail(length);
            System.out.println(email);
            Map<String, String> emailContent = new HashMap<String,String>();
            emailContent.put("email", email);
            Map<String, Object> postContent = new HashMap<String,Object>();
            postContent.put("customer", emailContent);
            postContent.put("password", srtSenha);
            apiRequest.header("Authorization", "Bearer "+srtToken).with().body(postContent);
            Response response = apiRequest.post(uriBase+srtAPI).prettyPeek();
            ResponseBody body = response.getBody();
            String bodyStringValue = body.asString();
            Assert.assertTrue(bodyStringValue.contains("id"));
            JsonPath jsonPathEvaluator = response.jsonPath();
            String responseEmail = jsonPathEvaluator.get("email");
            Assert.assertTrue(responseEmail.equalsIgnoreCase(email));
        }
But on my "steps" class I need to call the cucumber steps, and my request and validate code is on the same method. How can I call the request in a Method and the response in another to use the Cucumbers Steps? Thanks!
 
     
    