use of uk.ac.ebi.spot.goci.builder.RiskAlleleBuilder in project goci by EBISPOT.
the class LociAttributesServiceTest method saveRiskAllele.
@Test
public void saveRiskAllele() throws Exception {
RiskAllele NEW_RISK_ALLELE = new RiskAlleleBuilder().setSnp(SNP_01).setRiskAlleleName("rs579459-?").setProxySnps(Arrays.asList(PROXY_SNP_01, PROXY_SNP_02)).build();
// Stubbing
when(singleNucleotidePolymorphismRepository.findByRsIdIgnoreCase(NEW_RISK_ALLELE.getSnp().getRsId())).thenReturn(null);
when(singleNucleotidePolymorphismRepository.findByRsIdIgnoreCase(PROXY_SNP_01.getRsId())).thenReturn(null);
when(singleNucleotidePolymorphismRepository.findByRsIdIgnoreCase(PROXY_SNP_02.getRsId())).thenReturn(null);
when(singleNucleotidePolymorphismRepository.save(NEW_RISK_ALLELE.getSnp())).thenReturn(SNP_01);
when(singleNucleotidePolymorphismRepository.save(PROXY_SNP_01)).thenReturn(PROXY_SNP_01);
when(singleNucleotidePolymorphismRepository.save(PROXY_SNP_02)).thenReturn(PROXY_SNP_02);
lociAttributesService.saveRiskAlleles(Collections.singletonList(NEW_RISK_ALLELE));
verify(singleNucleotidePolymorphismRepository, times(1)).findByRsIdIgnoreCase(NEW_RISK_ALLELE.getSnp().getRsId());
verify(singleNucleotidePolymorphismRepository, times(1)).save(NEW_RISK_ALLELE.getSnp());
verify(singleNucleotidePolymorphismRepository, times(1)).findByRsIdIgnoreCase(PROXY_SNP_01.getRsId());
verify(singleNucleotidePolymorphismRepository, times(1)).save(PROXY_SNP_01);
verify(singleNucleotidePolymorphismRepository, times(1)).findByRsIdIgnoreCase(PROXY_SNP_02.getRsId());
verify(singleNucleotidePolymorphismRepository, times(1)).save(PROXY_SNP_02);
verify(riskAlleleRepository, times(1)).save(NEW_RISK_ALLELE);
}
Aggregations