package org.gbif.registry;

import org.gbif.common.messaging.api.MessagePublisher;
import org.gbif.registry.mail.EmailSender;
import org.gbif.registry.mail.InMemoryEmailSender;
import org.gbif.registry.message.MessagePublisherStub;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.PropertySource;

@TestConfiguration
@EnableAutoConfiguration
@ComponentScan(basePackages = {"org.gbif.ws.server.interceptor",
  "org.gbif.ws.server.filter", "org.gbif.ws.security", "org.gbif.query", "org.gbif.registry"})
@PropertySource("classpath:application-test.yml")
public class RegistryIntegrationTestsConfiguration {

  // use InMemoryEmailSender if devemail is disabled
  @Bean
  @Primary
  @ConditionalOnProperty(value = "mail.devemail.enabled", havingValue = "false")
  public EmailSender emailSender() {
    return new InMemoryEmailSender();
  }

  // use stub instead of rabbit MQ if message is disabled
  @Bean
  @Primary
  @ConditionalOnProperty(value = "message.enabled", havingValue = "false")
  public MessagePublisher messagePublisher() {
    return new MessagePublisherStub();
  }
}

@@ -21,16 +21,299 @@
 istry;%0A%0A
+import org.apache.commons.beanutils.BeanUtilsBean;%0Aimport org.apache.commons.beanutils.ConvertUtils;%0Aimport org.apache.commons.beanutils.ConvertUtilsBean;%0Aimport org.apache.commons.beanutils.converters.DateConverter;%0Aimport org.apache.commons.beanutils.converters.DateTimeConverter;%0A
 import o
@@ -355,24 +355,24 @@
 ePublisher;%0A
-
 import org.g
@@ -953,16 +953,40 @@
 ource;%0A%0A
+import java.util.Date;%0A%0A
 @TestCon
@@ -1713,24 +1713,24 @@
 blisher() %7B%0A
-
     return n
@@ -1759,11 +1759,651 @@
 b();%0A  %7D
+%0A%0A  @Bean%0A  public BeanUtilsBean beanUtilsBean() %7B%0A    DateTimeConverter dateConverter = new DateConverter(null);%0A    dateConverter.setPatterns(new String%5B%5D%7B%22dd-MM-yyyy%22%7D);%0A    ConvertUtils.register(dateConverter, Date.class);%0A%0A    ConvertUtilsBean convertUtilsBean = new ConvertUtilsBean() %7B%0A      @Override%0A      public Object convert(String value, Class clazz) %7B%0A        if (clazz.isEnum()) %7B%0A          return Enum.valueOf(clazz, value);%0A        %7D else %7B%0A          return super.convert(value, clazz);%0A        %7D%0A      %7D%0A    %7D;%0A%0A    convertUtilsBean.register(dateConverter, Date.class);%0A%0A    return new BeanUtilsBean(convertUtilsBean);%0A  %7D
 %0A%7D%0A

Add utility BeanUtil for integration tests