@Test public void checkRiskFrequency() throws Exception { assertThat(validationChecks.checkRiskFrequency("NR")).isNull(); assertThat(validationChecks.checkRiskFrequency("0.24")).isNull(); assertThat(validationChecks.checkRiskFrequency("(aac)")).isEqualTo( "Value is invalid i.e. not equal to NR or a number"); assertThat(validationChecks.checkRiskFrequency("989")).isEqualTo( "Value is invalid, value is not between 0 and 1"); }
public String checkRiskFrequency(String riskFrequency) { String error = null; if (riskFrequency == null) { error = "Value is empty"; } else if (riskFrequency.isEmpty()) { error = "Value is empty"; } else { if (!riskFrequency.equals("NR")) { try { float f = Float.parseFloat(riskFrequency); if (f < 0 || f > 1) { error = "Value is invalid, value is not between 0 and 1"; } } catch (NumberFormatException e) { if (!riskFrequency.contentEquals("NR")) { error = "Value is invalid i.e. not equal to NR or a number"; } } } } return error; }
ValidationChecks { public String checkRiskFrequency(String riskFrequency) { String error = null; if (riskFrequency == null) { error = "Value is empty"; } else if (riskFrequency.isEmpty()) { error = "Value is empty"; } else { if (!riskFrequency.equals("NR")) { try { float f = Float.parseFloat(riskFrequency); if (f < 0 || f > 1) { error = "Value is invalid, value is not between 0 and 1"; } } catch (NumberFormatException e) { if (!riskFrequency.contentEquals("NR")) { error = "Value is invalid i.e. not equal to NR or a number"; } } } } return error; } }
ValidationChecks { public String checkRiskFrequency(String riskFrequency) { String error = null; if (riskFrequency == null) { error = "Value is empty"; } else if (riskFrequency.isEmpty()) { error = "Value is empty"; } else { if (!riskFrequency.equals("NR")) { try { float f = Float.parseFloat(riskFrequency); if (f < 0 || f > 1) { error = "Value is invalid, value is not between 0 and 1"; } } catch (NumberFormatException e) { if (!riskFrequency.contentEquals("NR")) { error = "Value is invalid i.e. not equal to NR or a number"; } } } } return error; } @Autowired  ValidationChecks(GeneCheckingRestService geneCheckingRestService,
                            SnpCheckingRestService snpCheckingRestService); }
ValidationChecks { public String checkRiskFrequency(String riskFrequency) { String error = null; if (riskFrequency == null) { error = "Value is empty"; } else if (riskFrequency.isEmpty()) { error = "Value is empty"; } else { if (!riskFrequency.equals("NR")) { try { float f = Float.parseFloat(riskFrequency); if (f < 0 || f > 1) { error = "Value is invalid, value is not between 0 and 1"; } } catch (NumberFormatException e) { if (!riskFrequency.contentEquals("NR")) { error = "Value is invalid i.e. not equal to NR or a number"; } } } } return error; } @Autowired  ValidationChecks(GeneCheckingRestService geneCheckingRestService,
                            SnpCheckingRestService snpCheckingRestService); String checkValueIsPresent(String value); String checkValueIsEmpty(String value); String checkValueIsEmpty(Float value); String checkSnpType(String value); String checkOrIsPresent(Float value); String checkOrRecipIsPresentAndLessThanOne(Float value); String checkOrAndOrRecip(Float or, Float orRecip); String checkBetaIsPresentAndIsNotNegative(Float value); String checkBetaDirectionIsPresent(String value); String checkMantissaIsLessThan10(Integer value); String checkExponentIsPresentAndNegative(Integer value); String checkGene(String geneName, String eRelease); String checkSnp(String snp, String eRelease); String checkSnpGeneLocation(String snp, String gene, String eRelease); String checkRiskAllele(String riskAlleleName); String checkRiskFrequency(String riskFrequency); String checkSynthax(String value, String delimiter); String checkSnpStatus(Boolean genomeWide, Boolean limitedList); }
ValidationChecks { public String checkRiskFrequency(String riskFrequency) { String error = null; if (riskFrequency == null) { error = "Value is empty"; } else if (riskFrequency.isEmpty()) { error = "Value is empty"; } else { if (!riskFrequency.equals("NR")) { try { float f = Float.parseFloat(riskFrequency); if (f < 0 || f > 1) { error = "Value is invalid, value is not between 0 and 1"; } } catch (NumberFormatException e) { if (!riskFrequency.contentEquals("NR")) { error = "Value is invalid i.e. not equal to NR or a number"; } } } } return error; } @Autowired  ValidationChecks(GeneCheckingRestService geneCheckingRestService,
                            SnpCheckingRestService snpCheckingRestService); String checkValueIsPresent(String value); String checkValueIsEmpty(String value); String checkValueIsEmpty(Float value); String checkSnpType(String value); String checkOrIsPresent(Float value); String checkOrRecipIsPresentAndLessThanOne(Float value); String checkOrAndOrRecip(Float or, Float orRecip); String checkBetaIsPresentAndIsNotNegative(Float value); String checkBetaDirectionIsPresent(String value); String checkMantissaIsLessThan10(Integer value); String checkExponentIsPresentAndNegative(Integer value); String checkGene(String geneName, String eRelease); String checkSnp(String snp, String eRelease); String checkSnpGeneLocation(String snp, String gene, String eRelease); String checkRiskAllele(String riskAlleleName); String checkRiskFrequency(String riskFrequency); String checkSynthax(String value, String delimiter); String checkSnpStatus(Boolean genomeWide, Boolean limitedList);  }