Search in sources :

Example 1 with BinaryResponse

use of com.arbindo.mimock.entities.BinaryResponse in project mimock by arbindo.

the class ResponseFactoryExecutorTest method shouldReturnImplementationForBinaryResponse.

@Test
void shouldReturnImplementationForBinaryResponse() {
    byte[] bytes = "Test string".getBytes(StandardCharsets.UTF_8);
    BinaryResponse binaryResponse = BinaryResponse.builder().responseFile(bytes).build();
    Mock binaryResponseMock = Mock.builder().textualResponse(null).binaryResponse(binaryResponse).build();
    ResponseFactory responseFactory = responseFactoryExecutor.responseFactory(binaryResponseMock);
    assertEquals(BinaryResponseImpl.class, responseFactory.getClass());
    assertEquals(binaryResponse.getResponseFile(), responseFactory.responseBody());
}
Also used : BinaryResponse(com.arbindo.mimock.entities.BinaryResponse) Mock(com.arbindo.mimock.entities.Mock) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with BinaryResponse

use of com.arbindo.mimock.entities.BinaryResponse in project mimock by arbindo.

the class DomainModelMapperTest method shouldReturnModelWithBinaryResponseFactory.

@Test
void shouldReturnModelWithBinaryResponseFactory() {
    ResponseContentType responseContentType = ResponseContentType.builder().contentType("application/json").build();
    byte[] bytes = "Test string".getBytes(StandardCharsets.UTF_8);
    BinaryResponse binaryResponse = BinaryResponse.builder().responseFile(bytes).build();
    Mock testMock = Mock.builder().responseContentType(responseContentType).statusCode(200).textualResponse(null).binaryResponse(binaryResponse).build();
    DomainModelForMock mappedModel = domainModelMapper.mappedModel(testMock);
    assertEquals(bytes, mappedModel.getResponseBody());
    assertEquals(200, mappedModel.getStatusCode());
    assertEquals(TypeOfResponse.BINARY_RESPONSE, mappedModel.getTypeOfResponse());
    assertEquals("application/json", mappedModel.getResponseContentType());
}
Also used : BinaryResponse(com.arbindo.mimock.entities.BinaryResponse) DomainModelForMock(com.arbindo.mimock.generic.model.DomainModelForMock) ResponseContentType(com.arbindo.mimock.entities.ResponseContentType) DomainModelForMock(com.arbindo.mimock.generic.model.DomainModelForMock) Mock(com.arbindo.mimock.entities.Mock) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with BinaryResponse

use of com.arbindo.mimock.entities.BinaryResponse in project mimock by neel1996.

the class ResponseFactoryExecutorTest method shouldReturnImplementationForBinaryResponse.

@Test
void shouldReturnImplementationForBinaryResponse() {
    byte[] bytes = "Test string".getBytes(StandardCharsets.UTF_8);
    BinaryResponse binaryResponse = BinaryResponse.builder().responseFile(bytes).build();
    Mock binaryResponseMock = Mock.builder().textualResponse(null).binaryResponse(binaryResponse).build();
    ResponseFactory responseFactory = responseFactoryExecutor.responseFactory(binaryResponseMock);
    assertEquals(BinaryResponseImpl.class, responseFactory.getClass());
    assertEquals(binaryResponse.getResponseFile(), responseFactory.responseBody());
}
Also used : BinaryResponse(com.arbindo.mimock.entities.BinaryResponse) Mock(com.arbindo.mimock.entities.Mock) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with BinaryResponse

use of com.arbindo.mimock.entities.BinaryResponse in project mimock by neel1996.

the class DomainModelMapperTest method shouldReturnModelWithBinaryResponseFactory.

@Test
void shouldReturnModelWithBinaryResponseFactory() {
    ResponseContentType responseContentType = ResponseContentType.builder().contentType("application/json").build();
    byte[] bytes = "Test string".getBytes(StandardCharsets.UTF_8);
    BinaryResponse binaryResponse = BinaryResponse.builder().responseFile(bytes).build();
    Mock testMock = Mock.builder().responseContentType(responseContentType).statusCode(200).textualResponse(null).binaryResponse(binaryResponse).build();
    DomainModelForMock mappedModel = domainModelMapper.mappedModel(testMock);
    assertEquals(bytes, mappedModel.getResponseBody());
    assertEquals(200, mappedModel.getStatusCode());
    assertEquals(TypeOfResponse.BINARY_RESPONSE, mappedModel.getTypeOfResponse());
    assertEquals("application/json", mappedModel.getResponseContentType());
}
Also used : BinaryResponse(com.arbindo.mimock.entities.BinaryResponse) DomainModelForMock(com.arbindo.mimock.generic.model.DomainModelForMock) ResponseContentType(com.arbindo.mimock.entities.ResponseContentType) DomainModelForMock(com.arbindo.mimock.generic.model.DomainModelForMock) Mock(com.arbindo.mimock.entities.Mock) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

BinaryResponse (com.arbindo.mimock.entities.BinaryResponse)4 Mock (com.arbindo.mimock.entities.Mock)4 Test (org.junit.jupiter.api.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 ResponseContentType (com.arbindo.mimock.entities.ResponseContentType)2 DomainModelForMock (com.arbindo.mimock.generic.model.DomainModelForMock)2