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);
}
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);
}
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;
}
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);
}
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);
}
Aggregations