Search in sources :

Example 6 with ValidationError

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

the class ErrorCreationServiceTest method testCheckRiskAllele.

@Test
public void testCheckRiskAllele() throws Exception {
    when(validationChecks.checkRiskAllele("CHR4456:89")).thenReturn("Value does not start with rs or contain -");
    ValidationError error1 = errorCreationService.checkRiskAllele("CHR4456:89");
    assertThat(error1).extracting("field", "error", "warning").contains("Risk Allele", "Value does not start with rs or contain -", true);
    when(validationChecks.checkRiskAllele("")).thenReturn("Value is empty");
    ValidationError error2 = errorCreationService.checkRiskAllele("");
    assertThat(error2).extracting("field", "error", "warning").contains("Risk Allele", "Value is empty", false);
    when(validationChecks.checkRiskAllele("rs1234-?")).thenReturn(null);
    ValidationError error3 = errorCreationService.checkRiskAllele("rs1234-?");
    assertThat(error3).extracting("field", "error", "warning").contains(null, null, false);
}
Also used : ValidationError(uk.ac.ebi.spot.goci.model.ValidationError) Test(org.junit.Test)

Example 7 with ValidationError

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

the class ValidationChecksBuilder method runAuthorLevelBetaChecks.

/**
     * Run author level beta checks on a row
     *
     * @param association row to be checked
     */
public Collection<ValidationError> runAuthorLevelBetaChecks(Association association) {
    Collection<ValidationError> validationErrors = new ArrayList<>();
    ValidationError betaIsPresent = errorCreationService.checkBetaIsPresentAndIsNotNegative(association.getBetaNum());
    validationErrors.add(betaIsPresent);
    ValidationError betaUnitNotFound = errorCreationService.checkBetaUnitIsPresent(association.getBetaUnit());
    validationErrors.add(betaUnitNotFound);
    ValidationError betaDirectionNotFound = errorCreationService.checkBetaDirectionIsPresent(association.getBetaDirection());
    validationErrors.add(betaDirectionNotFound);
    ValidationError orFound = errorCreationService.checkOrEmpty(association.getOrPerCopyNum());
    validationErrors.add(orFound);
    ValidationError rangeNotFound = errorCreationService.checkRangeIsPresent(association.getRange());
    validationErrors.add(rangeNotFound);
    return ErrorProcessingService.checkForValidErrors(validationErrors);
}
Also used : ArrayList(java.util.ArrayList) ValidationError(uk.ac.ebi.spot.goci.model.ValidationError)

Example 8 with ValidationError

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

the class ErrorCreationServiceTest method testCheckAssociationRiskFrequency.

@Test
public void testCheckAssociationRiskFrequency() throws Exception {
    when(validationChecks.checkRiskFrequency("10")).thenReturn("Value is invalid, value is not between 0 and 1");
    ValidationError error1 = errorCreationService.checkAssociationRiskFrequency("10");
    assertThat(error1).extracting("field", "error", "warning").contains("Risk element (allele, haplotype or SNPxSNP interaction) frequency in controls", "Value is invalid, value is not between 0 and 1", true);
    when(validationChecks.checkRiskFrequency("")).thenReturn("Value is empty");
    ValidationError error2 = errorCreationService.checkAssociationRiskFrequency("");
    assertThat(error2).extracting("field", "error", "warning").contains("Risk element (allele, haplotype or SNPxSNP interaction) frequency in controls", "Value is empty", true);
    when(validationChecks.checkRiskFrequency("0.78")).thenReturn(null);
    ValidationError error3 = errorCreationService.checkAssociationRiskFrequency("0.78");
    assertThat(error3).extracting("field", "error", "warning").contains(null, null, false);
}
Also used : ValidationError(uk.ac.ebi.spot.goci.model.ValidationError) Test(org.junit.Test)

Example 9 with ValidationError

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

the class ErrorCreationServiceTest method testCheckMantissaIsLessThan10.

@Test
public void testCheckMantissaIsLessThan10() throws Exception {
    when(validationChecks.checkMantissaIsLessThan10(25)).thenReturn("Value not valid i.e. greater than 9");
    ValidationError error1 = errorCreationService.checkMantissaIsLessThan10(25);
    assertThat(error1).extracting("field", "error", "warning").contains("P-value mantissa", "Value not valid i.e. greater than 9", false);
    when(validationChecks.checkMantissaIsLessThan10(6)).thenReturn(null);
    ValidationError error2 = errorCreationService.checkMantissaIsLessThan10(6);
    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 10 with ValidationError

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

the class ErrorCreationServiceTest method testCheckBetaValuesIsEmpty.

@Test
public void testCheckBetaValuesIsEmpty() throws Exception {
    when(validationChecks.checkValueIsEmpty(Matchers.anyFloat())).thenReturn("Value is not empty");
    ValidationError error1 = errorCreationService.checkBetaValuesIsEmpty(Matchers.anyFloat());
    assertThat(error1).extracting("field", "error", "warning").contains("Beta", "Value is not empty", false);
    Float nullValue = null;
    when(validationChecks.checkValueIsEmpty(nullValue)).thenReturn(null);
    ValidationError error2 = errorCreationService.checkBetaValuesIsEmpty(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)

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