use of com.sequenceiq.mock.spi.MockResponse in project cloudbreak by hortonworks.
the class ResponseModifierServiceTest method testEvaluateResponseSamePathFirstReturnOKNextFailed.
@Test
public void testEvaluateResponseSamePathFirstReturnOKNextFailed() throws Throwable {
MockResponse mockResponse1 = createMockResponse(1, 200, "/path1", "get", "message1", "result");
MockResponse mockResponse3 = createMockResponse(1, 400, "/path1", "get", "message2");
underTest.addResponse(mockResponse1);
underTest.addResponse(mockResponse3);
String assertPath = "get_/path1";
String actualPost = underTest.evaluateResponse("get_/path1", String.class, () -> "OK");
assertEquals(actualPost, "result");
assertException(assertPath, "400 message2", HttpStatus.BAD_REQUEST);
}
use of com.sequenceiq.mock.spi.MockResponse in project cloudbreak by hortonworks.
the class ResponseModifierServiceTest method createMockResponse.
private MockResponse createMockResponse(int times, int code, String path, String method, String message, Object obj, Class clss) {
MockResponse mockResponse = new MockResponse();
mockResponse.setTimes(times);
mockResponse.setStatusCode(code);
mockResponse.setPath(path);
mockResponse.setHttpMethod(method);
mockResponse.setMessage(message);
if (obj != null) {
mockResponse.setClss(clss.getName());
mockResponse.setResponse(obj);
}
return mockResponse;
}
use of com.sequenceiq.mock.spi.MockResponse in project cloudbreak by hortonworks.
the class ResponseModifierServiceTest method testEvaluateResponseNoPreDefinedResponse.
@Test
public void testEvaluateResponseNoPreDefinedResponse() throws Throwable {
MockResponse mockResponse1 = createMockResponse(0, 200, "/path1", "get", "message1");
underTest.addResponse(mockResponse1);
String actualPost = underTest.evaluateResponse("get_/path2", String.class, () -> "OK");
assertEquals(actualPost, "OK");
}
use of com.sequenceiq.mock.spi.MockResponse in project cloudbreak by hortonworks.
the class ResponseModifierServiceTest method testEvaluateResponseWhenResponseEntity.
@Test
public void testEvaluateResponseWhenResponseEntity() throws Throwable {
MockResponse mockResponse1 = createMockResponse(0, 200, "/path1", "get", null, "result");
underTest.addResponse(mockResponse1);
ResponseEntity<String> actualPost = underTest.evaluateResponse("get_/path1", ResponseEntity.class, () -> null);
assertEquals(actualPost.getBody(), "result");
}
use of com.sequenceiq.mock.spi.MockResponse in project cloudbreak by hortonworks.
the class ResponseModifierServiceTest method testEvaluateResponseSamePathSameCodesButDifferentMessageAndTimes.
@Test
public // matter the order of the responses with the same path. Can add the response with the same code.
void testEvaluateResponseSamePathSameCodesButDifferentMessageAndTimes() {
MockResponse mockResponse1 = createMockResponse(2, 400, "/path1", "get", "message1");
MockResponse mockResponse3 = createMockResponse(1, 400, "/path1", "get", "message2");
underTest.addResponse(mockResponse1);
underTest.addResponse(mockResponse3);
String assertPath = "get_/path1";
assertException(assertPath, "400 message1", HttpStatus.BAD_REQUEST);
assertException(assertPath, "400 message1", HttpStatus.BAD_REQUEST);
assertException(assertPath, "400 message2", HttpStatus.BAD_REQUEST);
List<MockResponse> actualResponses = underTest.getResponse(assertPath);
assertNull(actualResponses);
}
Aggregations