Skip to content

Commit

Permalink
EVA-3664 Update test to throw exception in transaction when saving ne…
Browse files Browse the repository at this point in the history
…w block (#462)

* update test to throw error in transaction when saving new block
  • Loading branch information
nitin-ebi authored Oct 9, 2024
1 parent 03c1eda commit 1343e0f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

import uk.ac.ebi.ampt2d.commons.accession.persistence.jpa.monotonic.service.ContiguousIdBlockService;
import uk.ac.ebi.eva.accession.core.configuration.nonhuman.SubmittedVariantAccessioningConfiguration;
import uk.ac.ebi.eva.accession.core.repository.nonhuman.eva.SubmittedVariantAccessioningRepository;
import uk.ac.ebi.eva.accession.core.model.eva.SubmittedVariantEntity;
import uk.ac.ebi.eva.accession.core.repository.nonhuman.eva.SubmittedVariantAccessioningRepository;
import uk.ac.ebi.eva.accession.pipeline.batch.io.AccessionReportWriter;
import uk.ac.ebi.eva.accession.pipeline.batch.io.AccessionWriter;
import uk.ac.ebi.eva.accession.pipeline.parameters.InputParameters;
Expand All @@ -47,6 +48,7 @@
import java.nio.file.Paths;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
import static uk.ac.ebi.eva.accession.pipeline.configuration.BeanNames.CREATE_SUBSNP_ACCESSION_STEP;

@RunWith(SpringRunner.class)
Expand Down Expand Up @@ -76,8 +78,19 @@ public class CreateSubsnpAccessionsStepConfigurationTest {
@Autowired
private MongoTemplate mongoTemplate;

@SpyBean
private ContiguousIdBlockService contiguousIdBlockService;

@Before
public void setUp() throws Exception {
// if a new transaction is not created it will fail
when(contiguousIdBlockService.getBlockParameters("test-pipeline-ss"))
.thenThrow(RuntimeException.class)
.thenThrow(RuntimeException.class)
.thenThrow(RuntimeException.class)
.thenThrow(RuntimeException.class)
.thenCallRealMethod();

Files.deleteIfExists(Paths.get(inputParameters.getOutputVcf()));
Files.deleteIfExists(Paths.get(inputParameters.getOutputVcf() + AccessionReportWriter.VARIANTS_FILE_SUFFIX));
Files.deleteIfExists(Paths.get(inputParameters.getOutputVcf() + AccessionReportWriter.CONTIGS_FILE_SUFFIX));
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>4.13</junit.version>
<variation-commons-version>0.8.5</variation-commons-version>
<accession-commons-version>0.7.16</accession-commons-version>
<accession-commons-version>0.7.17</accession-commons-version>
</properties>

<parent>
Expand Down

0 comments on commit 1343e0f

Please sign in to comment.