use of com.arbindo.mimock.entities.ResponseContentType in project mimock by neel1996.
the class ResponseContentTypesRepositoryTest method shouldReturnNullForInvalidMultipartType.
@ParameterizedTest
@ValueSource(strings = { "multipart/mixed", "multipart/alternative", "multipart/related", "multipart/form-data" })
void shouldReturnNullForInvalidMultipartType(String multiPartResponseType) {
// Act
ResponseContentType responseType = responseContentTypesRepository.findByContentType(multiPartResponseType);
// Assert
assertNull(responseType);
}
use of com.arbindo.mimock.entities.ResponseContentType in project mimock by neel1996.
the class ResponseContentTypesRepositoryTest method shouldReturnNullForInvalidApplicationType.
@ParameterizedTest
@ValueSource(strings = { "application/EDI-X12", "application/EDIFACT", "application/javascript", "application/xhtm,xml", "application/l,json", "application/excel", "application/x-www-form-urlencoded" })
void shouldReturnNullForInvalidApplicationType(String applicationResponseType) {
// Act
ResponseContentType responseType = responseContentTypesRepository.findByContentType(applicationResponseType);
// Assert
assertNull(responseType);
}
use of com.arbindo.mimock.entities.ResponseContentType in project mimock by neel1996.
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());
}
use of com.arbindo.mimock.entities.ResponseContentType in project mimock by neel1996.
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());
}
use of com.arbindo.mimock.entities.ResponseContentType 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());
}
Aggregations