Search in sources :

Example 26 with ResponseContentType

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

the class ResponseContentTypesRepositoryTest method shouldReturnResponseContentTypeForValidVideoType.

@ParameterizedTest
@ValueSource(strings = { "video/mpeg", "video/mp4", "video/x-msvideo", "video/webm" })
void shouldReturnResponseContentTypeForValidVideoType(String videoResponseType) {
    // Act
    ResponseContentType responseType = responseContentTypesRepository.findByContentType(videoResponseType);
    // Assert
    assertNotNull(responseType);
    assertEquals(videoResponseType, responseType.getContentType());
}
Also used : ResponseContentType(com.arbindo.mimock.entities.ResponseContentType) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 27 with ResponseContentType

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

the class ResponseContentTypesRepositoryTest method shouldReturnResponseContentTypeForValidTextType.

@ParameterizedTest
@ValueSource(strings = { "text/css", "text/csv", "text/html", "text/javascript", "text/plain" })
void shouldReturnResponseContentTypeForValidTextType(String textResponseType) {
    // Act
    ResponseContentType responseType = responseContentTypesRepository.findByContentType(textResponseType);
    // Assert
    assertNotNull(responseType);
    assertEquals(textResponseType, responseType.getContentType());
}
Also used : ResponseContentType(com.arbindo.mimock.entities.ResponseContentType) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 28 with ResponseContentType

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

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);
}
Also used : ResponseContentType(com.arbindo.mimock.entities.ResponseContentType) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 29 with ResponseContentType

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

the class GetStaticRecordsServiceImplTest method shouldReturnAllSupportedResponseContentTypes.

@Test
void shouldReturnAllSupportedResponseContentTypes() {
    List<ResponseContentType> contentTypesFromDB = new ArrayList<>();
    ResponseContentType jsonType = ResponseContentType.builder().contentType("application/json").build();
    ResponseContentType xmlType = ResponseContentType.builder().contentType("application/xml").build();
    contentTypesFromDB.add(jsonType);
    contentTypesFromDB.add(xmlType);
    lenient().when(mockResponseContentTypesRepository.findAll()).thenReturn(contentTypesFromDB);
    List<ResponseContentType> contentTypes = service.listAllSupportedResponseContentTypes();
    assertNotNull(contentTypes);
    assertNotEquals(0, contentTypes.size());
    assertEquals("application/json", contentTypes.get(0).getContentType());
    assertEquals("application/xml", contentTypes.get(1).getContentType());
}
Also used : ArrayList(java.util.ArrayList) ResponseContentType(com.arbindo.mimock.entities.ResponseContentType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 30 with ResponseContentType

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

the class ResponseContentTypesRepositoryTest method shouldReturnResponseContentTypeForTextualResponseContentTypes.

@ParameterizedTest
@ValueSource(strings = { "text/css", "text/csv", "text/html", "text/calendar", "text/javascript", "application/json", "application/ld+json", "text/plain", "application/xhtml+xml", "application/xml", "application/vnd.mozilla.xul+xml" })
void shouldReturnResponseContentTypeForTextualResponseContentTypes(String applicationResponseType) {
    // Act
    ResponseContentType responseType = responseContentTypesRepository.findByContentType(applicationResponseType);
    // Assert
    assertNotNull(responseType);
    assertEquals(applicationResponseType, responseType.getContentType());
    assertEquals(TypeOfResponse.TEXTUAL_RESPONSE, responseType.getResponseType().getName());
}
Also used : ResponseContentType(com.arbindo.mimock.entities.ResponseContentType) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ResponseContentType (com.arbindo.mimock.entities.ResponseContentType)40 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)32 ValueSource (org.junit.jupiter.params.provider.ValueSource)30 Test (org.junit.jupiter.api.Test)8 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 Mock (com.arbindo.mimock.entities.Mock)6 DomainModelForMock (com.arbindo.mimock.generic.model.DomainModelForMock)6 TextualResponse (com.arbindo.mimock.entities.TextualResponse)4 BinaryResponse (com.arbindo.mimock.entities.BinaryResponse)2 ArrayList (java.util.ArrayList)2 EmptySource (org.junit.jupiter.params.provider.EmptySource)2 NullSource (org.junit.jupiter.params.provider.NullSource)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1