Search in sources :

Example 1 with TextualResponse

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

the class ResponseFactoryExecutorTest method shouldReturnImplementationForTextualResponse.

@Test
void shouldReturnImplementationForTextualResponse() {
    TextualResponse textualResponse = TextualResponse.builder().responseBody("{'message': 'Hello World!'}").build();
    Mock textualResponseMock = Mock.builder().textualResponse(textualResponse).binaryResponse(null).build();
    ResponseFactory responseFactory = responseFactoryExecutor.responseFactory(textualResponseMock);
    assertEquals(TextualResponseImpl.class, responseFactory.getClass());
    assertEquals(textualResponse.getResponseBody(), responseFactory.responseBody());
}
Also used : TextualResponse(com.arbindo.mimock.entities.TextualResponse) Mock(com.arbindo.mimock.entities.Mock) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with TextualResponse

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

the class DomainModelMapperTest method shouldReturnModelWithTextResponseFactory.

@Test
void shouldReturnModelWithTextResponseFactory() {
    ResponseContentType responseContentType = ResponseContentType.builder().contentType("application/json").build();
    TextualResponse textualResponse = TextualResponse.builder().responseBody("{'message': 'Hello World!'}").build();
    Mock testMock = Mock.builder().responseContentType(responseContentType).statusCode(200).textualResponse(textualResponse).binaryResponse(null).build();
    DomainModelForMock mappedModel = domainModelMapper.mappedModel(testMock);
    assertEquals("{'message': 'Hello World!'}", mappedModel.getResponseBody());
    assertEquals(200, mappedModel.getStatusCode());
    assertEquals("application/json", mappedModel.getResponseContentType());
    assertEquals(TypeOfResponse.TEXTUAL_RESPONSE, mappedModel.getTypeOfResponse());
}
Also used : DomainModelForMock(com.arbindo.mimock.generic.model.DomainModelForMock) TextualResponse(com.arbindo.mimock.entities.TextualResponse) 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 TextualResponse

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

the class DomainModelMapperTest method shouldReturnModelWithTextResponseFactoryWhenResponseHeaderIsNotNull.

@Test
void shouldReturnModelWithTextResponseFactoryWhenResponseHeaderIsNotNull() {
    ResponseContentType responseContentType = ResponseContentType.builder().contentType("application/json").build();
    TextualResponse textualResponse = TextualResponse.builder().responseBody("{'message': 'Hello World!'}").build();
    Mock testMock = Mock.builder().responseContentType(responseContentType).statusCode(200).textualResponse(textualResponse).responseHeaders(MocksGenerator.generateResponseHeader()).binaryResponse(null).build();
    DomainModelForMock mappedModel = domainModelMapper.mappedModel(testMock);
    assertEquals("{'message': 'Hello World!'}", mappedModel.getResponseBody());
    assertEquals(200, mappedModel.getStatusCode());
    assertEquals("application/json", mappedModel.getResponseContentType());
    assertEquals(TypeOfResponse.TEXTUAL_RESPONSE, mappedModel.getTypeOfResponse());
    assertNotNull(mappedModel.getResponseHeaders());
}
Also used : DomainModelForMock(com.arbindo.mimock.generic.model.DomainModelForMock) TextualResponse(com.arbindo.mimock.entities.TextualResponse) 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 4 with TextualResponse

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

the class DomainModelMapperTest method shouldReturnModelWithTextResponseFactoryWhenResponseContentTypeIsNull.

@Test
void shouldReturnModelWithTextResponseFactoryWhenResponseContentTypeIsNull() {
    TextualResponse textualResponse = TextualResponse.builder().responseBody("{'message': 'Hello World!'}").build();
    Mock testMock = Mock.builder().statusCode(200).textualResponse(textualResponse).responseHeaders(MocksGenerator.generateResponseHeader()).binaryResponse(null).build();
    DomainModelForMock mappedModel = domainModelMapper.mappedModel(testMock);
    assertEquals("{'message': 'Hello World!'}", mappedModel.getResponseBody());
    assertEquals(200, mappedModel.getStatusCode());
    assertEquals(TypeOfResponse.TEXTUAL_RESPONSE, mappedModel.getTypeOfResponse());
    assertNotNull(mappedModel.getResponseHeaders());
}
Also used : DomainModelForMock(com.arbindo.mimock.generic.model.DomainModelForMock) TextualResponse(com.arbindo.mimock.entities.TextualResponse) 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 5 with TextualResponse

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

the class ResponseFactoryExecutorTest method shouldReturnImplementationForTextualResponse.

@Test
void shouldReturnImplementationForTextualResponse() {
    TextualResponse textualResponse = TextualResponse.builder().responseBody("{'message': 'Hello World!'}").build();
    Mock textualResponseMock = Mock.builder().textualResponse(textualResponse).binaryResponse(null).build();
    ResponseFactory responseFactory = responseFactoryExecutor.responseFactory(textualResponseMock);
    assertEquals(TextualResponseImpl.class, responseFactory.getClass());
    assertEquals(textualResponse.getResponseBody(), responseFactory.responseBody());
}
Also used : TextualResponse(com.arbindo.mimock.entities.TextualResponse) Mock(com.arbindo.mimock.entities.Mock) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

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