Пользовательский валидатор определяется как
Код: Выделить всё
open class CustomValidator {
//Some of the internal classes as fields
}
Код: Выделить всё
fun validate(argumentOne: ArgumentOne, argumentTwo: ArgumentTwo? = null)
Код: Выделить всё
@TestConfiguration
class TestSecurityConfig {
val customValidator: CustomValidator = mockkClass(CustomValidator::class)
}
Код: Выделить всё
@SpringBootTest(webEnvironment = RANDOM_PORT)
@ExtendWith(MockKExtension::class)
@TestInstance(PER_CLASS)
@AutoConfigureWebTestClient(timeout = "1d")
@Import(TestSecurityConfig::class)
class FunctionalTestClass {
** THIS IS GIVING ERROR (COULD NOT AUTOWIRE ) IN EDITOR
@Autowired
private lateinit var egTokenValidator: EGTokenValidator
}
@Test
fun `testing One` () {
//This function i am trying to mock
Mockito.`when\`(customeValidator.validate(anyOrNull(), anyOrNull())).thenReturn(validationResult)
//Other code
}
Не могли бы вы, ребята, пожалуйста? Помогите, как это сделать?
Я не добавил полную реализацию, так как это код организации.
Я ожидал, что класс CustomValidator будет высмеивали, чтобы я мог высмеивать его функцию валидатора
Подробнее здесь: https://stackoverflow.com/questions/786 ... on-testing