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 {
@Bean
static Validator configurationPropertiesValidator() {
return new BehoerdenschluesselPropertiesValidator();
return new XdomeaPropertiesValidator();
}
@Bean
......
......@@ -7,7 +7,7 @@ import org.springframework.validation.Validator;
import de.ozgcloud.common.errorhandling.TechnicalException;
public class BehoerdenschluesselPropertiesValidator implements Validator {
public class XdomeaPropertiesValidator implements Validator {
@Override
public boolean supports(Class<?> clazz) {
......@@ -17,6 +17,10 @@ public class BehoerdenschluesselPropertiesValidator implements Validator {
@Override
public void validate(Object target, Errors errors) {
var properties = (XdomeaProperties) target;
validateBehoerdenschluesselProperties(errors, properties);
}
private void validateBehoerdenschluesselProperties(Errors errors, XdomeaProperties properties) {
if (StringUtils.isNotBlank(properties.getBehoerdenschluessel())) {
validateNotBlank("behoerdenschluesselUri", properties, errors);
validateNotBlank("behoerdenschluesselVersion", properties, errors);
......
......@@ -12,6 +12,6 @@ class BehoerdenschluesselPropertiesValidatorITCase {
@Test
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;
import org.mockito.Spy;
import org.springframework.validation.Errors;
class BehoerdenschluesselPropertiesValidatorTest {
class XdomeaPropertiesValidatorTest {
@Spy
private BehoerdenschluesselPropertiesValidator validator;
private XdomeaPropertiesValidator validator;
@Nested
class TestSupports {
......@@ -57,7 +57,7 @@ class BehoerdenschluesselPropertiesValidatorTest {
@ParameterizedTest
@NullAndEmptySource
void shouldHaveFieldErrors(String uri) {
var properties = havingBehoerdenschluesselUri(uri);
var properties = withBehoerdenschluesselUri(uri);
var errors = validate(properties);
......@@ -67,7 +67,7 @@ class BehoerdenschluesselPropertiesValidatorTest {
@ParameterizedTest
@NullAndEmptySource
void shouldHaveMeaningfulErrorMessage(String uri) {
var properties = havingBehoerdenschluesselUri(uri);
var properties = withBehoerdenschluesselUri(uri);
var errors = validate(properties);
......@@ -77,14 +77,14 @@ class BehoerdenschluesselPropertiesValidatorTest {
@ParameterizedTest
@NullAndEmptySource
void shouldHaveErrorCode(String uri) {
var properties = havingBehoerdenschluesselUri(uri);
var properties = withBehoerdenschluesselUri(uri);
var errors = validate(properties);
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();
}
}
......@@ -99,7 +99,7 @@ class BehoerdenschluesselPropertiesValidatorTest {
@ParameterizedTest
@NullAndEmptySource
void shouldHaveFieldErrors(String version) {
var properties = havingBehoerdenschluesselVersion(version);
var properties = withBehoerdenschluesselVersion(version);
var errors = validate(properties);
......@@ -109,7 +109,7 @@ class BehoerdenschluesselPropertiesValidatorTest {
@ParameterizedTest
@NullAndEmptySource
void shouldHaveMeaningfulErrorMessage(String version) {
var properties = havingBehoerdenschluesselVersion(version);
var properties = withBehoerdenschluesselVersion(version);
var errors = validate(properties);
......@@ -119,14 +119,14 @@ class BehoerdenschluesselPropertiesValidatorTest {
@ParameterizedTest
@NullAndEmptySource
void shouldHaveErrorCode(String version) {
var properties = havingBehoerdenschluesselVersion(version);
var properties = withBehoerdenschluesselVersion(version);
var errors = validate(properties);
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();
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment