Skip to content
Snippets Groups Projects
Commit ae37e063 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-5841 OZG-5952 Renamed BehoerdenschluesselPropertiesValidator

parent 341323f6
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ class ExportConfiguration { ...@@ -23,7 +23,7 @@ class ExportConfiguration {
@Bean @Bean
static Validator configurationPropertiesValidator() { static Validator configurationPropertiesValidator() {
return new BehoerdenschluesselPropertiesValidator(); return new XdomeaPropertiesValidator();
} }
@Bean @Bean
......
...@@ -7,7 +7,7 @@ import org.springframework.validation.Validator; ...@@ -7,7 +7,7 @@ import org.springframework.validation.Validator;
import de.ozgcloud.common.errorhandling.TechnicalException; import de.ozgcloud.common.errorhandling.TechnicalException;
public class BehoerdenschluesselPropertiesValidator implements Validator { public class XdomeaPropertiesValidator implements Validator {
@Override @Override
public boolean supports(Class<?> clazz) { public boolean supports(Class<?> clazz) {
...@@ -17,6 +17,10 @@ public class BehoerdenschluesselPropertiesValidator implements Validator { ...@@ -17,6 +17,10 @@ public class BehoerdenschluesselPropertiesValidator implements Validator {
@Override @Override
public void validate(Object target, Errors errors) { public void validate(Object target, Errors errors) {
var properties = (XdomeaProperties) target; var properties = (XdomeaProperties) target;
validateBehoerdenschluesselProperties(errors, properties);
}
private void validateBehoerdenschluesselProperties(Errors errors, XdomeaProperties properties) {
if (StringUtils.isNotBlank(properties.getBehoerdenschluessel())) { if (StringUtils.isNotBlank(properties.getBehoerdenschluessel())) {
validateNotBlank("behoerdenschluesselUri", properties, errors); validateNotBlank("behoerdenschluesselUri", properties, errors);
validateNotBlank("behoerdenschluesselVersion", properties, errors); validateNotBlank("behoerdenschluesselVersion", properties, errors);
......
...@@ -12,6 +12,6 @@ class BehoerdenschluesselPropertiesValidatorITCase { ...@@ -12,6 +12,6 @@ class BehoerdenschluesselPropertiesValidatorITCase {
@Test @Test
void shouldExistInApplicationContext(ApplicationContext context) { void shouldExistInApplicationContext(ApplicationContext context) {
assertThat(context.getBean("configurationPropertiesValidator")).isNotNull().isInstanceOf(BehoerdenschluesselPropertiesValidator.class); assertThat(context.getBean("configurationPropertiesValidator")).isNotNull().isInstanceOf(XdomeaPropertiesValidator.class);
} }
} }
...@@ -9,10 +9,10 @@ import org.junit.jupiter.params.provider.NullAndEmptySource; ...@@ -9,10 +9,10 @@ import org.junit.jupiter.params.provider.NullAndEmptySource;
import org.mockito.Spy; import org.mockito.Spy;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
class BehoerdenschluesselPropertiesValidatorTest { class XdomeaPropertiesValidatorTest {
@Spy @Spy
private BehoerdenschluesselPropertiesValidator validator; private XdomeaPropertiesValidator validator;
@Nested @Nested
class TestSupports { class TestSupports {
...@@ -57,7 +57,7 @@ class BehoerdenschluesselPropertiesValidatorTest { ...@@ -57,7 +57,7 @@ class BehoerdenschluesselPropertiesValidatorTest {
@ParameterizedTest @ParameterizedTest
@NullAndEmptySource @NullAndEmptySource
void shouldHaveFieldErrors(String uri) { void shouldHaveFieldErrors(String uri) {
var properties = havingBehoerdenschluesselUri(uri); var properties = withBehoerdenschluesselUri(uri);
var errors = validate(properties); var errors = validate(properties);
...@@ -67,7 +67,7 @@ class BehoerdenschluesselPropertiesValidatorTest { ...@@ -67,7 +67,7 @@ class BehoerdenschluesselPropertiesValidatorTest {
@ParameterizedTest @ParameterizedTest
@NullAndEmptySource @NullAndEmptySource
void shouldHaveMeaningfulErrorMessage(String uri) { void shouldHaveMeaningfulErrorMessage(String uri) {
var properties = havingBehoerdenschluesselUri(uri); var properties = withBehoerdenschluesselUri(uri);
var errors = validate(properties); var errors = validate(properties);
...@@ -77,14 +77,14 @@ class BehoerdenschluesselPropertiesValidatorTest { ...@@ -77,14 +77,14 @@ class BehoerdenschluesselPropertiesValidatorTest {
@ParameterizedTest @ParameterizedTest
@NullAndEmptySource @NullAndEmptySource
void shouldHaveErrorCode(String uri) { void shouldHaveErrorCode(String uri) {
var properties = havingBehoerdenschluesselUri(uri); var properties = withBehoerdenschluesselUri(uri);
var errors = validate(properties); var errors = validate(properties);
assertThat(errors.getFieldError(PROPERTY_NAME).getCode()).isEqualTo(ERROR_CODE); assertThat(errors.getFieldError(PROPERTY_NAME).getCode()).isEqualTo(ERROR_CODE);
} }
private XdomeaProperties havingBehoerdenschluesselUri(String uri) { private XdomeaProperties withBehoerdenschluesselUri(String uri) {
return XdomeaPropertiesTestFactory.createBuilder().behoerdenschluesselUri(uri).build(); return XdomeaPropertiesTestFactory.createBuilder().behoerdenschluesselUri(uri).build();
} }
} }
...@@ -99,7 +99,7 @@ class BehoerdenschluesselPropertiesValidatorTest { ...@@ -99,7 +99,7 @@ class BehoerdenschluesselPropertiesValidatorTest {
@ParameterizedTest @ParameterizedTest
@NullAndEmptySource @NullAndEmptySource
void shouldHaveFieldErrors(String version) { void shouldHaveFieldErrors(String version) {
var properties = havingBehoerdenschluesselVersion(version); var properties = withBehoerdenschluesselVersion(version);
var errors = validate(properties); var errors = validate(properties);
...@@ -109,7 +109,7 @@ class BehoerdenschluesselPropertiesValidatorTest { ...@@ -109,7 +109,7 @@ class BehoerdenschluesselPropertiesValidatorTest {
@ParameterizedTest @ParameterizedTest
@NullAndEmptySource @NullAndEmptySource
void shouldHaveMeaningfulErrorMessage(String version) { void shouldHaveMeaningfulErrorMessage(String version) {
var properties = havingBehoerdenschluesselVersion(version); var properties = withBehoerdenschluesselVersion(version);
var errors = validate(properties); var errors = validate(properties);
...@@ -119,14 +119,14 @@ class BehoerdenschluesselPropertiesValidatorTest { ...@@ -119,14 +119,14 @@ class BehoerdenschluesselPropertiesValidatorTest {
@ParameterizedTest @ParameterizedTest
@NullAndEmptySource @NullAndEmptySource
void shouldHaveErrorCode(String version) { void shouldHaveErrorCode(String version) {
var properties = havingBehoerdenschluesselVersion(version); var properties = withBehoerdenschluesselVersion(version);
var errors = validate(properties); var errors = validate(properties);
assertThat(errors.getFieldError(PROPERTY_NAME).getCode()).isEqualTo(ERROR_CODE); assertThat(errors.getFieldError(PROPERTY_NAME).getCode()).isEqualTo(ERROR_CODE);
} }
private XdomeaProperties havingBehoerdenschluesselVersion(String version) { private XdomeaProperties withBehoerdenschluesselVersion(String version) {
return XdomeaPropertiesTestFactory.createBuilder().behoerdenschluesselVersion(version).build(); return XdomeaPropertiesTestFactory.createBuilder().behoerdenschluesselVersion(version).build();
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment