Search in sources :

Example 11 with ConflictOverrides

use of org.candlepin.sync.ConflictOverrides in project candlepin by candlepin.

the class ImportJobTest method ensureJobFailure.

@Test
public void ensureJobFailure() throws Exception {
    String archiveFilePath = "/path/to/some/file.zip";
    ConflictOverrides co = new ConflictOverrides();
    String uploadedFileName = "test.zip";
    String expectedMessage = "Expected Exception Message";
    JobDetail detail = job.scheduleImport(owner, archiveFilePath, uploadedFileName, co);
    when(ctx.getMergedJobDataMap()).thenReturn(detail.getJobDataMap());
    when(ownerCurator.lookupByKey(eq(owner.getKey()))).thenReturn(owner);
    when(manifestManager.importStoredManifest(eq(owner), any(String.class), any(ConflictOverrides.class), eq(uploadedFileName))).thenThrow(new ImporterException(expectedMessage));
    try {
        job.execute(ctx);
        fail("Expected exception to be thrown");
    } catch (JobExecutionException e) {
    // Expected
    }
    verify(ctx).setResult(eq(expectedMessage));
}
Also used : ImporterException(org.candlepin.sync.ImporterException) ConflictOverrides(org.candlepin.sync.ConflictOverrides) JobDetail(org.quartz.JobDetail) JobExecutionException(org.quartz.JobExecutionException) Test(org.junit.Test)

Aggregations

ConflictOverrides (org.candlepin.sync.ConflictOverrides)11 Test (org.junit.Test)8 Owner (org.candlepin.model.Owner)7 JobDetail (org.quartz.JobDetail)5 IseException (org.candlepin.common.exceptions.IseException)3 ImporterException (org.candlepin.sync.ImporterException)3 ManifestFile (org.candlepin.sync.file.ManifestFile)3 JobDataMap (org.quartz.JobDataMap)3 JobExecutionException (org.quartz.JobExecutionException)3 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 File (java.io.File)2 IOException (java.io.IOException)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 BadRequestException (org.candlepin.common.exceptions.BadRequestException)2 CandlepinException (org.candlepin.common.exceptions.CandlepinException)2 NotFoundException (org.candlepin.common.exceptions.NotFoundException)2