Search in sources :

Example 1 with MockResponse

use of com.sequenceiq.it.cloudbreak.testcase.mock.response.MockResponse in project cloudbreak by hortonworks.

the class DefaultResponseConfigure method thenReturn.

public T thenReturn(R retValue, String message, int statusCode, int times, String clss) {
    if (!parameters.isEmpty()) {
        throw new TestFailException("Mock thenReturn will not take into account url parameters.");
    }
    String crn = testDto.getCrn();
    if (crn != null) {
        pathVariable("mockUuid", crn);
    }
    String retType = clss;
    if (retType == null && retValue != null) {
        retType = retValue.getClass().getName();
    }
    MockResponse body = new MockResponse(retValue, message, getMethod().getHttpMethod().name(), getPath(), times, statusCode, retType);
    executeQuery.executeConfigure(pathVariables(), body);
    return testDto;
}
Also used : MockResponse(com.sequenceiq.it.cloudbreak.testcase.mock.response.MockResponse) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Example 2 with MockResponse

use of com.sequenceiq.it.cloudbreak.testcase.mock.response.MockResponse in project cloudbreak by hortonworks.

the class ExecuteQueryToMockInfrastructure method executeConfigure.

public void executeConfigure(Map<String, String> pathVariables, Function<WebTarget, WebTarget> decorateWebTarget, MockResponse body) {
    String configuredPath = body.getPath();
    for (Map.Entry<String, String> entry : pathVariables.entrySet()) {
        configuredPath = configuredPath.replace("{" + entry.getKey() + "}", entry.getValue());
    }
    Invocation.Builder invocation = buildWebTarget("/configure", decorateWebTarget).request();
    body.setPath(configuredPath);
    try (Response ignore = invocation.post(Entity.json(body))) {
    }
}
Also used : MockResponse(com.sequenceiq.it.cloudbreak.testcase.mock.response.MockResponse) Response(javax.ws.rs.core.Response) Invocation(javax.ws.rs.client.Invocation) Map(java.util.Map)

Aggregations

MockResponse (com.sequenceiq.it.cloudbreak.testcase.mock.response.MockResponse)2 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)1 Map (java.util.Map)1 Invocation (javax.ws.rs.client.Invocation)1 Response (javax.ws.rs.core.Response)1