Search in sources :

Example 26 with ValidationError

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

the class ValidationChecksBuilder method runOrChecks.

/**
     * Run OR checks on a row
     *
     * @param association association to be checked
     */
public Collection<ValidationError> runOrChecks(Association association) {
    Collection<ValidationError> validationErrors = new ArrayList<>();
    ValidationError orAndOrRecipCheck = errorCreationService.checkOrAndOrRecip(association.getOrPerCopyNum(), association.getOrPerCopyRecip());
    validationErrors.add(orAndOrRecipCheck);
    ValidationError betaFoundForOr = errorCreationService.checkBetaValuesIsEmpty(association.getBetaNum());
    validationErrors.add(betaFoundForOr);
    ValidationError betaUnitFoundForOr = errorCreationService.checkBetaUnitIsEmpty(association.getBetaUnit());
    validationErrors.add(betaUnitFoundForOr);
    ValidationError betaDirectionFoundForOr = errorCreationService.checkBetaDirectionIsEmpty(association.getBetaDirection());
    validationErrors.add(betaDirectionFoundForOr);
    ValidationError rangeNotFound = errorCreationService.checkRangeIsPresent(association.getRange());
    validationErrors.add(rangeNotFound);
    ValidationError recipRangeNotFound = errorCreationService.checkOrPerCopyRecipRangeIsPresent(association.getOrPerCopyRecipRange());
    validationErrors.add(recipRangeNotFound);
    return ErrorProcessingService.checkForValidErrors(validationErrors);
}
Also used : ArrayList(java.util.ArrayList) ValidationError(uk.ac.ebi.spot.goci.model.ValidationError)

Example 27 with ValidationError

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

the class ErrorCreationServiceTest method testCheckGene.

@Test
public void testCheckGene() throws Exception {
    when(validationChecks.checkGene("testX", "")).thenReturn("Gene synbol testX is not valid");
    ValidationError error1 = errorCreationService.checkGene("testX", "");
    assertThat(error1).extracting("field", "error", "warning").contains("Gene", "Gene synbol testX is not valid", true);
    when(validationChecks.checkGene("SFRP1", "")).thenReturn(null);
    ValidationError error2 = errorCreationService.checkGene("SFRP1", "");
    assertThat(error2).extracting("field", "error", "warning").contains(null, null, false);
    when(validationChecks.checkGene("", "")).thenReturn("Gene name is empty");
    ValidationError error3 = errorCreationService.checkGene("", "");
    assertThat(error3).extracting("field", "error", "warning").contains("Gene", "Gene name is empty", true);
}
Also used : ValidationError(uk.ac.ebi.spot.goci.model.ValidationError) Test(org.junit.Test)

Example 28 with ValidationError

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

the class ErrorProcessingService method createError.

/**
     * Create error object
     *
     * @param message       Error message
     * @param columnChecked Name of the column checked
     */
public static ValidationError createError(String message, String columnChecked, Boolean warning) {
    ValidationError error = new ValidationError();
    // If there is an error create a fully formed object
    if (message != null) {
        error.setField(columnChecked);
        error.setError(message);
        error.setWarning(warning);
    }
    return error;
}
Also used : ValidationError(uk.ac.ebi.spot.goci.model.ValidationError)

Example 29 with ValidationError

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

the class ErrorCreationServiceTest method testCheckOrEmpty.

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

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

the class ErrorCreationServiceTest method testCheckBetaDirectionIsEmpty.

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