Skip to content

Commit

Permalink
use correct bundleMessageSource in unit tests as it might be cached a…
Browse files Browse the repository at this point in the history
…nd has the potential to break tests depending on validationmessages

Co-authored-by: Maximilian Ruenz <[email protected]>
Co-authored-by: Marco Geweke <[email protected]>
Co-authored-by: Riko Stave <[email protected]>
  • Loading branch information
3 people committed Sep 25, 2023
1 parent 134130f commit eeb9130
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package de.otto.edison.validation.validators;

import de.otto.edison.validation.configuration.AggregateResourceBundleMessageSource;
import jakarta.validation.ConstraintValidatorContext;
import jakarta.validation.metadata.ConstraintDescriptor;
import org.hibernate.validator.internal.engine.DefaultClockProvider;
import org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorContextImpl;
import org.hibernate.validator.internal.engine.path.PathImpl;
import org.hibernate.validator.messageinterpolation.ExpressionLanguageFeatureLevel;
import org.junit.jupiter.api.Test;
import org.springframework.context.support.ResourceBundleMessageSource;

import jakarta.validation.ConstraintValidatorContext;
import jakarta.validation.metadata.ConstraintDescriptor;
import java.util.*;
import java.util.Arrays;
import java.util.Collections;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
Expand Down Expand Up @@ -81,7 +82,7 @@ public void shouldFailForEmptyString() {
}

private EnumListValidator createAndInitializeValidator(boolean ignoreCase, boolean allowNull) {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
AggregateResourceBundleMessageSource messageSource = new AggregateResourceBundleMessageSource();
messageSource.setBasename("ValidationMessages");
messageSource.setUseCodeAsDefaultMessage(true);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.otto.edison.validation.web;

import com.fasterxml.jackson.databind.ObjectMapper;
import de.otto.edison.validation.configuration.AggregateResourceBundleMessageSource;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.support.ResourceBundleMessageSource;
Expand All @@ -21,11 +22,11 @@
public class ErrorHalRepresentationFactoryTest {


private ResourceBundleMessageSource messageSource;
private AggregateResourceBundleMessageSource messageSource;

@BeforeEach
public void setUp() {
messageSource = new ResourceBundleMessageSource();
messageSource = new AggregateResourceBundleMessageSource();
messageSource.setBasename("ValidationMessages");
messageSource.setUseCodeAsDefaultMessage(true);

Expand Down

0 comments on commit eeb9130

Please sign in to comment.