Search in sources :

Example 1 with HttpMethod

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

the class GetStaticRecordsServiceImplTest method shouldReturnAllSupportedHttpMethods.

@Test
void shouldReturnAllSupportedHttpMethods() {
    List<HttpMethod> httpMethodsFromDB = new ArrayList<>();
    HttpMethod getMethod = HttpMethod.builder().method("GET").build();
    HttpMethod postMethod = HttpMethod.builder().method("POST").build();
    httpMethodsFromDB.add(getMethod);
    httpMethodsFromDB.add(postMethod);
    lenient().when(mockHttpMethodsRepository.findAll()).thenReturn(httpMethodsFromDB);
    List<HttpMethod> httpMethods = service.listAllSupportedHttpMethods();
    assertNotNull(httpMethods);
    assertNotEquals(0, httpMethods.size());
    assertEquals("GET", httpMethods.get(0).getMethod());
    assertEquals("POST", httpMethods.get(1).getMethod());
}
Also used : ArrayList(java.util.ArrayList) HttpMethod(com.arbindo.mimock.entities.HttpMethod) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with HttpMethod

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

the class HttpMethodsRepositoryTest method shouldReturnNullForCaseSensitiveMethodStrings.

@ParameterizedTest
@ValueSource(strings = { "get", "Head", "pOSt", "put", "Delete", "connect", "Options", "trace", "PaTch" })
void shouldReturnNullForCaseSensitiveMethodStrings(String method) {
    // Act
    HttpMethod httpMethod = httpMethodsRepository.findByMethod(method);
    // Assert
    assertNull(httpMethod);
}
Also used : HttpMethod(com.arbindo.mimock.entities.HttpMethod) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with HttpMethod

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

the class HttpMethodsRepositoryTest method shouldReturnNullForInvalidMethod.

@ParameterizedTest
@ValueSource(strings = { "TEST", "RANDOM", "EXEC", "123X" })
void shouldReturnNullForInvalidMethod(String method) {
    // Act
    HttpMethod httpMethod = httpMethodsRepository.findByMethod(method);
    // Assert
    assertNull(httpMethod);
}
Also used : HttpMethod(com.arbindo.mimock.entities.HttpMethod) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with HttpMethod

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

the class HttpMethodsRepositoryTest method shouldReturnNullForInvalidMethodWhenEmptyOrNull.

@ParameterizedTest
@EmptySource
@NullSource
void shouldReturnNullForInvalidMethodWhenEmptyOrNull(String method) {
    // Act
    HttpMethod httpMethod = httpMethodsRepository.findByMethod(method);
    // Assert
    assertNull(httpMethod);
}
Also used : HttpMethod(com.arbindo.mimock.entities.HttpMethod) EmptySource(org.junit.jupiter.params.provider.EmptySource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) NullSource(org.junit.jupiter.params.provider.NullSource)

Example 5 with HttpMethod

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

the class HttpMethodsRepositoryTest method shouldReturnNullForInvalidMethodForSqlInjectionStrings.

@ParameterizedTest
@ValueSource(strings = { "get OR 1=1", "GET; DROP TABLE mocks;" })
void shouldReturnNullForInvalidMethodForSqlInjectionStrings(String method) {
    // Act
    HttpMethod httpMethod = httpMethodsRepository.findByMethod(method);
    // Assert
    assertNull(httpMethod);
}
Also used : HttpMethod(com.arbindo.mimock.entities.HttpMethod) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

HttpMethod (com.arbindo.mimock.entities.HttpMethod)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 ValueSource (org.junit.jupiter.params.provider.ValueSource)8 Mock (com.arbindo.mimock.entities.Mock)2 DomainModelForMock (com.arbindo.mimock.generic.model.DomainModelForMock)2 ArrayList (java.util.ArrayList)2 Test (org.junit.jupiter.api.Test)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 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1