@Override public Validator getValidator() { Validator selected = null; for (WebMvcConfigurer configurer : this.delegates) { Validator validator = configurer.getValidator(); if (validator != null) { if (selected != null) { throw new IllegalStateException("No unique Validator found: {" + selected + ", " + validator + "}"); } selected = validator; } } return selected; }
@Override public Validator getValidator() { Validator selected = null; for (WebMvcConfigurer configurer : this.delegates) { Validator validator = configurer.getValidator(); if (validator != null) { if (selected != null) { throw new IllegalStateException("No unique Validator found: {" + selected + ", " + validator + "}"); } selected = validator; } } return selected; }
@Test public void getCustomValidator() { given(webMvcConfigurer.getValidator()).willReturn(new LocalValidatorFactoryBean()); delegatingConfig.setConfigurers(Collections.singletonList(webMvcConfigurer)); delegatingConfig.mvcValidator(); verify(webMvcConfigurer).getValidator(); }
@Override public Validator getValidator() { Validator selected = null; for (WebMvcConfigurer configurer : this.delegates) { Validator validator = configurer.getValidator(); if (validator != null) { if (selected != null) { throw new IllegalStateException("No unique Validator found: {" + selected + ", " + validator + "}"); } selected = validator; } } return selected; }