package uk.ac.ebi.quickgo.annotation.model;

import uk.ac.ebi.quickgo.common.validator.DbXRefEntity;
import uk.ac.ebi.quickgo.common.validator.EntityValidation;

import java.util.ArrayList;
import java.util.List;
import org.springframework.context.annotation.Bean;

import javax.validation.Validator;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;

/**
 * Configuration class mimics {@link uk.ac.ebi.quickgo.annotation.service.search.SearchServiceConfig} used for testing.
 *
 * @author Tony Wardell
 * Date: 29/06/2016
 * Time: 14:24
 * Created with IntelliJ IDEA.
 */
public class AnnotationRequestConfig {
    private static final String UNIPROTKB_GENE_PRODUCT_ID_VALIDATING_REGEX="([OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z]" +
            "([0-9][A-Z][A-Z0-9]{2}){1,2}[0-9])" +
            "((-[0-9]+)|:PRO_[0-9]{10}|:VAR_[0-9]{6}){0,1}";

    public AnnotationRequestConfig() {}

    /**
     * Create test validator
     * @return A hardcoded example of a GeneProductDbXRefIDFormats containing a validating regular expression for
     * UniProtKB.
     */
    @Bean
    public EntityValidation geneProductValidator() {

        List<DbXRefEntity> entities = new ArrayList<>();
        DbXRefEntity entity1 = new DbXRefEntity("UniProtKB", "PR:000000001", "protein",
                UNIPROTKB_GENE_PRODUCT_ID_VALIDATING_REGEX, "http://www.uniprot.org/uniprot/[example_id]/");
        entities.add(entity1);

        return EntityValidation.createWithData(entities);
    }

    /**
     *
     * @return instance used to run validation against the validated class.
     */
    @Bean
    public Validator validator(){
        return new LocalValidatorFactoryBean();
    }

}

@@ -181,35 +181,9 @@
 rray
-List;%0Aimport java.util.List
+s
 ;%0Aim
@@ -609,16 +609,289 @@
 onfig %7B%0A
+    private static final String TARGET_DB = %22UniProtKB%22;%0A    private static final String ENTITY_TYPE_ID = %22PR:000000001%22;%0A    private static final String ENTITY_TYPE_NAME = %22protein%22;%0A    private static final String DB_URL = %22http://www.uniprot.org/uniprot/%5Bexample_id%5D/%22;%0A
     priv
@@ -956,17 +956,19 @@
 NG_REGEX
-=
+ = 
 %22(%5BOPQ%5D%5B
@@ -1394,25 +1394,24 @@
 tor() %7B%0A
-%0A
         
 List%3CDbX
@@ -1402,21 +1402,16 @@
         
-List%3C
 DbXRefEn
@@ -1418,269 +1418,153 @@
 tity
-%3E entities = new ArrayList%3C%3E();%0A        DbXRefEntity entity1 = new DbXRefEntity(%22UniProtKB%22, %22PR:000000001%22, %22protein%22,%0A                UNIPROTKB_GENE_PRODUCT_ID_VALIDATING_REGEX, %22http://www.uniprot.org/uniprot/%5Bexample_id%5D/%22);%0A        entities.add(entity1
+ testEntity = new DbXRefEntity(TARGET_DB, ENTITY_TYPE_ID, ENTITY_TYPE_NAME,%0A                UNIPROTKB_GENE_PRODUCT_ID_VALIDATING_REGEX, DB_URL
 );%0A
-%0A
     
@@ -1610,16 +1610,33 @@
 ata(
-e
+Arrays.asList(testE
 ntit
-ies
+y)
 );%0A 
@@ -1653,15 +1653,8 @@
 /**%0A
-     *%0A
     
@@ -1735,32 +1735,32 @@
    */%0A    @Bean%0A
-
     public Valid
@@ -1775,16 +1775,17 @@
 idator()
+ 
 %7B%0A      

Reformat code.