Search in sources :

Example 16 with ResponseContentType

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

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 17 with ResponseContentType

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

the class ResponseContentTypesRepositoryTest method shouldReturnNullForSqlInjectionStrings.

@ParameterizedTest
@ValueSource(strings = { "application/json OR 1=1", "text/css; DROP TABLE mocks;" })
void shouldReturnNullForSqlInjectionStrings(String applicationResponseType) {
    // Act
    ResponseContentType responseType = responseContentTypesRepository.findByContentType(applicationResponseType);
    // 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 18 with ResponseContentType

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

the class ResponseContentTypesRepositoryTest method shouldReturnResponseContentTypeForValidApplicationType.

@ParameterizedTest
@ValueSource(strings = { "application/java-archive", "application/octet-stream", "application/ogg", "application/pdf", "application/x-shockwave-flash", "application/json", "application/xml", "application/zip" })
void shouldReturnResponseContentTypeForValidApplicationType(String applicationResponseType) {
    // Act
    ResponseContentType responseType = responseContentTypesRepository.findByContentType(applicationResponseType);
    // Assert
    assertNotNull(responseType);
    assertEquals(applicationResponseType, responseType.getContentType());
}
Also used : ResponseContentType(com.arbindo.mimock.entities.ResponseContentType) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 19 with ResponseContentType

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

the class ResponseContentTypesRepositoryTest method shouldReturnNullForInvalidVideoType.

@ParameterizedTest
@ValueSource(strings = { "video/quicktime", "video/x-ms-wmv", "video/x-flv" })
void shouldReturnNullForInvalidVideoType(String videoResponseType) {
    // Act
    ResponseContentType responseType = responseContentTypesRepository.findByContentType(videoResponseType);
    // 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 20 with ResponseContentType

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

the class ResponseContentTypesRepositoryTest method shouldReturnResponseContentTypeForValidImageType.

@ParameterizedTest
@ValueSource(strings = { "image/gif", "image/jpeg", "image/png", "image/svg+xml" })
void shouldReturnResponseContentTypeForValidImageType(String imageResponseType) {
    // Act
    ResponseContentType responseType = responseContentTypesRepository.findByContentType(imageResponseType);
    // Assert
    assertNotNull(responseType);
    assertEquals(imageResponseType, responseType.getContentType());
}
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