Search in sources :

Example 11 with ValidationError

use of uk.ac.ebi.spot.goci.model.ValidationError in project goci by EBISPOT.

the class ErrorCreationServiceTest method testCheckGeneSynthax.

@Test
public void testCheckGeneSynthax() throws Exception {
    when(validationChecks.checkSynthax("SFRP1 x SFRP2", ";")).thenReturn("Value does not contain correct separator");
    ValidationError error1 = errorCreationService.checkGeneSynthax("SFRP1 x SFRP2", ";");
    assertThat(error1).extracting("field", "error", "warning").contains("Gene", "Value does not contain correct separator", false);
    when(validationChecks.checkSynthax("rs2981579; rs123", ";")).thenReturn(null);
    ValidationError error2 = errorCreationService.checkGeneSynthax("rs2981579; rs123", ";");
    assertThat(error2).extracting("field", "error", "warning").contains(null, null, false);
}
Also used : ValidationError(uk.ac.ebi.spot.goci.model.ValidationError) Test(org.junit.Test)

Example 12 with ValidationError

use of uk.ac.ebi.spot.goci.model.ValidationError in project goci by EBISPOT.

the class ErrorCreationServiceTest method testCheckOrIsPresent.

@Test
public void testCheckOrIsPresent() throws Exception {
    when(validationChecks.checkOrIsPresent(null)).thenReturn("Value is empty");
    ValidationError error1 = errorCreationService.checkOrIsPresent((null));
    assertThat(error1).extracting("field", "error", "warning").contains("OR", "Value is empty", false);
    when(validationChecks.checkOrIsPresent((float) 1.23)).thenReturn(null);
    ValidationError error2 = errorCreationService.checkOrIsPresent((float) 1.23);
    assertThat(error2).extracting("field", "error", "warning").contains(null, null, false);
    Float f1 = (float) (0.0 / 0.0);
    when(validationChecks.checkOrIsPresent(f1)).thenReturn("Value is not number");
    ValidationError error3 = errorCreationService.checkOrIsPresent((f1));
    assertThat(error3).extracting("field", "error", "warning").contains("OR", "Value is not number", false);
}
Also used : ValidationError(uk.ac.ebi.spot.goci.model.ValidationError) Test(org.junit.Test)

Example 13 with ValidationError

use of uk.ac.ebi.spot.goci.model.ValidationError in project goci by EBISPOT.

the class ErrorCreationServiceTest method testCheckDescriptionIsEmpty.

@Test
public void testCheckDescriptionIsEmpty() throws Exception {
    when(validationChecks.checkValueIsEmpty(Matchers.anyString())).thenReturn("Value is not empty");
    ValidationError error1 = errorCreationService.checkDescriptionIsEmpty(Matchers.anyString());
    assertThat(error1).extracting("field", "error", "warning").contains("OR/Beta description", "Value is not empty", false);
    String nullValue = null;
    when(validationChecks.checkValueIsEmpty(nullValue)).thenReturn(null);
    ValidationError error2 = errorCreationService.checkDescriptionIsEmpty(nullValue);
    assertThat(error2).extracting("field", "error", "warning").contains(null, null, false);
}
Also used : ValidationError(uk.ac.ebi.spot.goci.model.ValidationError) Test(org.junit.Test)

Example 14 with ValidationError

use of uk.ac.ebi.spot.goci.model.ValidationError in project goci by EBISPOT.

the class ErrorCreationServiceTest method testCheckRangeIsEmpty.

@Test
public void testCheckRangeIsEmpty() throws Exception {
    when(validationChecks.checkValueIsEmpty(Matchers.anyString())).thenReturn("Value is not empty");
    ValidationError error1 = errorCreationService.checkRangeIsEmpty(Matchers.anyString());
    assertThat(error1).extracting("field", "error", "warning").contains("Range", "Value is not empty", false);
    String nullRange = null;
    when(validationChecks.checkValueIsEmpty(nullRange)).thenReturn(null);
    ValidationError error2 = errorCreationService.checkRangeIsEmpty(nullRange);
    assertThat(error2).extracting("field", "error", "warning").contains(null, null, false);
}
Also used : ValidationError(uk.ac.ebi.spot.goci.model.ValidationError) Test(org.junit.Test)

Example 15 with ValidationError

use of uk.ac.ebi.spot.goci.model.ValidationError in project goci by EBISPOT.

the class AssociationFileUploadService method createRowValidationSummary.

/**
     * Return a list of syntax errors. These error checks will look for things that would prevent creation of an
     * association which could then be carried forward to full validation
     *
     * @param row Row to validate
     */
private RowValidationSummary createRowValidationSummary(AssociationUploadRow row, String eRelease) {
    getLog().info("Creating row summary for row " + row.getRowNumber());
    Collection<ValidationError> errors = validationService.runRowValidation(row, eRelease);
    RowValidationSummary rowValidationSummary = new RowValidationSummary();
    rowValidationSummary.setRow(row);
    rowValidationSummary.setErrors(errors);
    return rowValidationSummary;
}
Also used : RowValidationSummary(uk.ac.ebi.spot.goci.model.RowValidationSummary) ValidationError(uk.ac.ebi.spot.goci.model.ValidationError)

Aggregations

ValidationError (uk.ac.ebi.spot.goci.model.ValidationError)46 Test (org.junit.Test)32 ArrayList (java.util.ArrayList)11 Locus (uk.ac.ebi.spot.goci.model.Locus)3 Association (uk.ac.ebi.spot.goci.model.Association)2 AssociationSummary (uk.ac.ebi.spot.goci.model.AssociationSummary)2 RowValidationSummary (uk.ac.ebi.spot.goci.model.RowValidationSummary)2 File (java.io.File)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 XSSFCell (org.apache.poi.xssf.usermodel.XSSFCell)1 XSSFRow (org.apache.poi.xssf.usermodel.XSSFRow)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1