Search in sources :

Example 1 with SchedulerTransaction

use of org.opencastproject.scheduler.api.SchedulerService.SchedulerTransaction in project opencast by opencast.

the class SchedulerServiceImplTest method testTransactionCommit.

@Test
public void testTransactionCommit() throws Exception {
    Date start = new Date();
    Date end = new Date(System.currentTimeMillis() + 60000);
    String captureDeviceID = "demo";
    String seriesId = "series1";
    Set<String> userIds = new HashSet<>();
    userIds.add("user1");
    userIds.add("user2");
    MediaPackage mp = generateEvent(Opt.<String>none());
    mp.setSeries(seriesId);
    DublinCoreCatalog event = generateEvent(captureDeviceID, start, end);
    addDublinCore(Opt.<String>none(), mp, event);
    Map<String, String> caProperties = generateCaptureAgentMetadata("demo");
    try {
        schedSvc.addEvent(start, end, captureDeviceID, userIds, mp, wfProperties, caProperties, Opt.<Boolean>none(), Opt.some("new"), "new");
    } catch (SchedulerTransactionLockException e) {
        fail("Transaction create lock not working!");
    }
    SchedulerTransaction trx = schedSvc.createTransaction("new");
    assertEquals("new", trx.getSource());
    AQueryBuilder query = assetManager.createQuery();
    AResult result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    assertEquals(1, result.getSize());
    trx.addEvent(start, end, captureDeviceID, userIds, mp, wfPropertiesUpdated, caProperties, Opt.<Boolean>none());
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    assertEquals(2, result.getSize());
    trx.commit();
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact())).and(query.hasPropertiesOf(SchedulerServiceImpl.TRX_NAMESPACE).not())).run();
    assertEquals(1, result.getSize());
    ARecord record = result.getRecords().head2();
    assertEquals(VersionImpl.mk(1), record.getSnapshot().get().getVersion());
    try {
        schedSvc.getTransaction(trx.getId());
        fail("Deleted transaction found!");
    } catch (NotFoundException e) {
        assertNotNull(e);
    }
}
Also used : AQueryBuilder(org.opencastproject.assetmanager.api.query.AQueryBuilder) NotFoundException(org.opencastproject.util.NotFoundException) SchedulerTransaction(org.opencastproject.scheduler.api.SchedulerService.SchedulerTransaction) Date(java.util.Date) ARecord(org.opencastproject.assetmanager.api.query.ARecord) SchedulerTransactionLockException(org.opencastproject.scheduler.api.SchedulerTransactionLockException) MediaPackage(org.opencastproject.mediapackage.MediaPackage) RichAResult(org.opencastproject.assetmanager.api.query.RichAResult) AResult(org.opencastproject.assetmanager.api.query.AResult) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) HashSet(java.util.HashSet) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) Test(org.junit.Test)

Example 2 with SchedulerTransaction

use of org.opencastproject.scheduler.api.SchedulerService.SchedulerTransaction in project opencast by opencast.

the class SchedulerServiceImplTest method testTransactionCleanup.

@Test
public void testTransactionCleanup() throws Exception {
    Date start = new Date();
    Date end = new Date(System.currentTimeMillis() + 60000);
    String captureDeviceID = "demo";
    String seriesId = "series1";
    Set<String> userIds = new HashSet<>();
    userIds.add("user1");
    userIds.add("user2");
    MediaPackage mp = generateEvent(Opt.<String>none());
    mp.setSeries(seriesId);
    DublinCoreCatalog event = generateEvent(captureDeviceID, start, end);
    addDublinCore(Opt.<String>none(), mp, event);
    Map<String, String> caProperties = generateCaptureAgentMetadata("demo");
    SchedulerTransaction trx = schedSvc.createTransaction("new");
    assertEquals("new", trx.getSource());
    AQueryBuilder query = assetManager.createQuery();
    AResult result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    Opt<ARecord> record = result.getRecords().head();
    assertFalse(record.isSome());
    trx.addEvent(start, end, captureDeviceID, userIds, mp, wfPropertiesUpdated, caProperties, Opt.<Boolean>none());
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    record = result.getRecords().head();
    assertTrue(record.isSome());
    schedSvc.transactionOffsetMillis = 0;
    schedSvc.cleanupTransactions();
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    record = result.getRecords().head();
    assertFalse(record.isSome());
    try {
        schedSvc.getTransaction(trx.getId());
        fail("Deleted transaction found!");
    } catch (NotFoundException e) {
        assertNotNull(e);
    }
}
Also used : AQueryBuilder(org.opencastproject.assetmanager.api.query.AQueryBuilder) NotFoundException(org.opencastproject.util.NotFoundException) SchedulerTransaction(org.opencastproject.scheduler.api.SchedulerService.SchedulerTransaction) Date(java.util.Date) ARecord(org.opencastproject.assetmanager.api.query.ARecord) MediaPackage(org.opencastproject.mediapackage.MediaPackage) RichAResult(org.opencastproject.assetmanager.api.query.RichAResult) AResult(org.opencastproject.assetmanager.api.query.AResult) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) HashSet(java.util.HashSet) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) Test(org.junit.Test)

Example 3 with SchedulerTransaction

use of org.opencastproject.scheduler.api.SchedulerService.SchedulerTransaction in project opencast by opencast.

the class SchedulerServiceImplTest method testTransactionRollback.

@Test
public void testTransactionRollback() throws Exception {
    Date start = new Date();
    Date end = new Date(System.currentTimeMillis() + 60000);
    String captureDeviceID = "demo";
    String seriesId = "series1";
    Set<String> userIds = new HashSet<>();
    userIds.add("user1");
    userIds.add("user2");
    MediaPackage mp = generateEvent(Opt.<String>none());
    mp.setSeries(seriesId);
    DublinCoreCatalog event = generateEvent(captureDeviceID, start, end);
    addDublinCore(Opt.<String>none(), mp, event);
    Map<String, String> caProperties = generateCaptureAgentMetadata("demo");
    try {
        schedSvc.addEvent(start, end, captureDeviceID, userIds, mp, wfPropertiesUpdated, caProperties, Opt.<Boolean>none(), Opt.some(SchedulerService.ORIGIN), SchedulerService.ORIGIN);
    } catch (SchedulerTransactionLockException e) {
        fail("Unable to add event!");
    }
    SchedulerTransaction trx = schedSvc.createTransaction("new");
    assertEquals("new", trx.getSource());
    AQueryBuilder query = assetManager.createQuery();
    AResult result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    assertEquals(1, result.getSize());
    trx.addEvent(start, end, captureDeviceID, userIds, mp, wfPropertiesUpdated, caProperties, Opt.<Boolean>none());
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    assertEquals(2, result.getSize());
    trx.rollback();
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    assertEquals(1, result.getSize());
    try {
        schedSvc.getTransaction(trx.getId());
        fail("Deleted transaction found!");
    } catch (NotFoundException e) {
        assertNotNull(e);
    }
    trx = schedSvc.createTransaction("new");
    trx.addEvent(start, end, captureDeviceID, userIds, mp, wfPropertiesUpdated, caProperties, Opt.<Boolean>none());
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    assertEquals(2, result.getSize());
    assertEquals(new VersionImpl(2), result.getRecords().tail().head2().getSnapshot().get().getVersion());
    assertEquals(new VersionImpl(0), result.getRecords().head2().getSnapshot().get().getVersion());
    try {
        schedSvc.getMediaPackage(mp.getIdentifier().compact());
    } catch (NotFoundException e) {
        fail("Detection of second last element doesn't work!");
    }
}
Also used : AQueryBuilder(org.opencastproject.assetmanager.api.query.AQueryBuilder) NotFoundException(org.opencastproject.util.NotFoundException) SchedulerTransaction(org.opencastproject.scheduler.api.SchedulerService.SchedulerTransaction) Date(java.util.Date) VersionImpl(org.opencastproject.assetmanager.impl.VersionImpl) SchedulerTransactionLockException(org.opencastproject.scheduler.api.SchedulerTransactionLockException) MediaPackage(org.opencastproject.mediapackage.MediaPackage) RichAResult(org.opencastproject.assetmanager.api.query.RichAResult) AResult(org.opencastproject.assetmanager.api.query.AResult) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) HashSet(java.util.HashSet) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) Test(org.junit.Test)

Example 4 with SchedulerTransaction

use of org.opencastproject.scheduler.api.SchedulerService.SchedulerTransaction in project opencast by opencast.

the class SchedulerServiceImplTest method testTransactionCommitConflict.

@Test
public void testTransactionCommitConflict() throws Exception {
    Date start = new Date();
    Date end = new Date(System.currentTimeMillis() + 60000);
    String captureDeviceID = "demo";
    String seriesId = "series1";
    Set<String> userIds = new HashSet<>();
    userIds.add("user1");
    userIds.add("user2");
    MediaPackage mp = generateEvent(Opt.<String>none());
    mp.setSeries(seriesId);
    DublinCoreCatalog extendedEvent = generateExtendedEvent(Opt.<String>none(), "extended");
    addDublinCore(Opt.<String>none(), mp, extendedEvent);
    DublinCoreCatalog event = generateEvent(captureDeviceID, start, end);
    addDublinCore(Opt.<String>none(), mp, event);
    addAcl(Opt.<String>none(), mp, acl);
    Map<String, String> caProperties = generateCaptureAgentMetadata("demo");
    SchedulerTransaction trx = schedSvc.createTransaction("new");
    trx.addEvent(start, end, captureDeviceID, userIds, mp, wfProperties, caProperties, Opt.<Boolean>none());
    try {
        trx.commit();
    } catch (SchedulerConflictException e) {
        fail("Pre-conflict detection not working!");
    }
    AQueryBuilder query = assetManager.createQuery();
    AResult result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    assertEquals(1, result.getSize());
    Opt<ARecord> record = result.getRecords().head();
    assertTrue(record.isSome());
    assertEquals(new VersionImpl(0), record.get().getSnapshot().get().getVersion());
    schedSvc.updateEvent(mp.getIdentifier().compact(), Opt.<Date>none(), Opt.<Date>none(), Opt.<String>none(), Opt.<Set<String>>none(), Opt.<MediaPackage>none(), Opt.<Map<String, String>>none(), Opt.<Map<String, String>>none(), Opt.some(Opt.some(true)), SchedulerService.ORIGIN);
    // Update with same checksum
    trx = schedSvc.createTransaction("new");
    trx.addEvent(start, end, captureDeviceID, userIds, mp, wfProperties, caProperties, Opt.some(true));
    try {
        // works because of same checksum
        trx.commit();
    } catch (SchedulerConflictException e) {
        fail("Pre-conflict detection not working!");
    }
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    assertEquals(1, result.getSize());
    record = result.getRecords().head();
    assertTrue(record.isSome());
    assertEquals(new VersionImpl(1), record.get().getSnapshot().get().getVersion());
    assertTrue(record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getBoolean("optout")));
    assertEquals("new", record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("source")));
    assertEquals("new", record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("last_modified_origin")));
    // Update with different checksum
    schedSvc.updateEvent(mp.getIdentifier().compact(), Opt.<Date>none(), Opt.<Date>none(), Opt.<String>none(), Opt.<Set<String>>none(), Opt.<MediaPackage>none(), Opt.<Map<String, String>>none(), Opt.<Map<String, String>>none(), Opt.some(Opt.some(false)), SchedulerService.ORIGIN);
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    assertEquals(1, result.getSize());
    record = result.getRecords().head();
    assertTrue(record.isSome());
    assertEquals(new VersionImpl(1), record.get().getSnapshot().get().getVersion());
    assertFalse(record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getBoolean("optout")));
    assertTrue(record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getStringOpt("checksum")).isSome());
    assertEquals("new", record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("source")));
    assertEquals(SchedulerService.ORIGIN, record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("last_modified_origin")));
    trx = schedSvc.createTransaction("new");
    trx.addEvent(start, end, captureDeviceID, userIds, mp, wfProperties, caProperties, Opt.some(true));
    try {
        // creates conflict
        trx.commit();
    } catch (SchedulerConflictException e) {
        fail("Pre-conflict detection not working!");
    }
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    assertEquals(1, result.getSize());
    record = result.getRecords().head();
    assertTrue(record.isSome());
    assertEquals(new VersionImpl(1), record.get().getSnapshot().get().getVersion());
    assertFalse(record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getBoolean("optout")));
    assertTrue(record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getStringOpt("last_conflict")).isSome());
    assertEquals("new", record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("source")));
    assertEquals(SchedulerService.ORIGIN, record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("last_modified_origin")));
    // Commit again with no changes
    trx = schedSvc.createTransaction("new");
    trx.addEvent(start, end, captureDeviceID, userIds, mp, wfProperties, caProperties, Opt.some(true));
    try {
        // ignores conflict
        trx.commit();
    } catch (SchedulerConflictException e) {
        fail("Pre-conflict detection not working!");
    }
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    assertEquals(1, result.getSize());
    record = result.getRecords().head();
    assertTrue(record.isSome());
    assertEquals(new VersionImpl(1), record.get().getSnapshot().get().getVersion());
    assertFalse(record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getBoolean("optout")));
    assertTrue(record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getStringOpt("last_conflict")).isSome());
    assertEquals("new", record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("source")));
    assertEquals(SchedulerService.ORIGIN, record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("last_modified_origin")));
    // Commit again with changes
    trx = schedSvc.createTransaction("new");
    trx.addEvent(start, end, "newdevice", userIds, mp, wfProperties, caProperties, Opt.some(true));
    try {
        // override from existing
        // creates new conflict
        testConflictHandler.setStrategy(Strategy.OLD);
        trx.commit();
    } catch (SchedulerConflictException e) {
        fail("Pre-conflict detection not working!");
    }
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    assertEquals(1, result.getSize());
    record = result.getRecords().head();
    assertTrue(record.isSome());
    assertEquals(new VersionImpl(1), record.get().getSnapshot().get().getVersion());
    assertFalse(record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getBoolean("optout")));
    assertTrue(record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getStringOpt("last_conflict")).isSome());
    assertEquals("new", record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("source")));
    assertEquals("demo", record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("agent")));
    assertEquals(SchedulerService.ORIGIN, record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("last_modified_origin")));
    // Commit again with new changes
    trx = schedSvc.createTransaction("new");
    trx.addEvent(start, end, "newdevice", userIds, mp, wfProperties, caProperties, Opt.some(false));
    try {
        // override from transaction
        testConflictHandler.setStrategy(Strategy.NEW);
        trx.commit();
    } catch (SchedulerConflictException e) {
        fail("Pre-conflict detection not working!");
    }
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    assertEquals(1, result.getSize());
    record = result.getRecords().head();
    assertTrue(record.isSome());
    assertEquals(new VersionImpl(5), record.get().getSnapshot().get().getVersion());
    assertFalse(record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getBoolean("optout")));
    assertFalse(record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getStringOpt("last_conflict")).isSome());
    assertEquals("newdevice", record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("agent")));
    assertEquals("new", record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("source")));
    assertEquals("new", record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("last_modified_origin")));
    // Commit again with new changes
    trx = schedSvc.createTransaction("new2");
    trx.addEvent(start, end, captureDeviceID, userIds, mp, wfProperties, caProperties, Opt.some(true));
    try {
        // merge opt out only and keep agent id
        testConflictHandler.setStrategy(Strategy.MERGED);
        trx.commit();
    } catch (SchedulerConflictException e) {
        fail("Pre-conflict detection not working!");
    }
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.mediaPackageId(mp.getIdentifier().compact()))).run();
    assertEquals(1, result.getSize());
    record = result.getRecords().head();
    assertTrue(record.isSome());
    assertEquals(new VersionImpl(7), record.get().getSnapshot().get().getVersion());
    assertFalse(record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getBoolean("optout")));
    assertFalse(record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getStringOpt("last_conflict")).isSome());
    assertEquals(captureDeviceID, record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("agent")));
    assertEquals("new2", record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("source")));
    assertEquals("new2", record.get().getProperties().apply(org.opencastproject.assetmanager.api.fn.Properties.getString("last_modified_origin")));
}
Also used : SchedulerConflictException(org.opencastproject.scheduler.api.SchedulerConflictException) AQueryBuilder(org.opencastproject.assetmanager.api.query.AQueryBuilder) SchedulerTransaction(org.opencastproject.scheduler.api.SchedulerService.SchedulerTransaction) Date(java.util.Date) VersionImpl(org.opencastproject.assetmanager.impl.VersionImpl) ARecord(org.opencastproject.assetmanager.api.query.ARecord) MediaPackage(org.opencastproject.mediapackage.MediaPackage) RichAResult(org.opencastproject.assetmanager.api.query.RichAResult) AResult(org.opencastproject.assetmanager.api.query.AResult) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) HashSet(java.util.HashSet) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) Test(org.junit.Test)

Example 5 with SchedulerTransaction

use of org.opencastproject.scheduler.api.SchedulerService.SchedulerTransaction in project opencast by opencast.

the class SchedulerServiceImplTest method testTransactionCommitCleanup.

@Test
public void testTransactionCommitCleanup() throws Exception {
    Date start = new Date();
    Date end = new Date(System.currentTimeMillis() + 60000);
    String captureDeviceID = "demo";
    String seriesId = "series1";
    Set<String> userIds = new HashSet<>();
    userIds.add("user1");
    userIds.add("user2");
    MediaPackage mp = generateEvent(Opt.<String>none());
    mp.setSeries(seriesId);
    DublinCoreCatalog event = generateEvent(captureDeviceID, start, end);
    addDublinCore(Opt.<String>none(), mp, event);
    Map<String, String> caProperties = generateCaptureAgentMetadata("demo");
    MediaPackage mp2 = generateEvent(Opt.<String>none());
    SchedulerTransaction trx = schedSvc.createTransaction("new");
    assertEquals("new", trx.getSource());
    trx.addEvent(start, end, captureDeviceID, userIds, mp, wfPropertiesUpdated, caProperties, Opt.<Boolean>none());
    AQueryBuilder query = assetManager.createQuery();
    AResult result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.version().isLatest())).run();
    assertEquals(1, result.getSize());
    trx.commit();
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.version().isLatest())).run();
    assertEquals(1, result.getSize());
    trx = schedSvc.createTransaction("new");
    assertEquals("new", trx.getSource());
    trx.addEvent(start, end, captureDeviceID, userIds, mp2, wfPropertiesUpdated, caProperties, Opt.<Boolean>none());
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.version().isLatest())).run();
    assertEquals(2, result.getSize());
    trx.commit();
    query = assetManager.createQuery();
    result = query.select(query.snapshot(), query.properties()).where(query.organizationId().eq(new DefaultOrganization().getId()).and(query.version().isLatest())).run();
    assertEquals(1, result.getSize());
    try {
        schedSvc.getTransaction(trx.getId());
        fail("Deleted transaction found!");
    } catch (NotFoundException e) {
        assertNotNull(e);
    }
}
Also used : MediaPackage(org.opencastproject.mediapackage.MediaPackage) AQueryBuilder(org.opencastproject.assetmanager.api.query.AQueryBuilder) RichAResult(org.opencastproject.assetmanager.api.query.RichAResult) AResult(org.opencastproject.assetmanager.api.query.AResult) NotFoundException(org.opencastproject.util.NotFoundException) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) SchedulerTransaction(org.opencastproject.scheduler.api.SchedulerService.SchedulerTransaction) Date(java.util.Date) HashSet(java.util.HashSet) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) Test(org.junit.Test)

Aggregations

SchedulerTransaction (org.opencastproject.scheduler.api.SchedulerService.SchedulerTransaction)12 HashSet (java.util.HashSet)8 MediaPackage (org.opencastproject.mediapackage.MediaPackage)8 Date (java.util.Date)7 Test (org.junit.Test)7 DublinCoreCatalog (org.opencastproject.metadata.dublincore.DublinCoreCatalog)7 DefaultOrganization (org.opencastproject.security.api.DefaultOrganization)7 NotFoundException (org.opencastproject.util.NotFoundException)7 AQueryBuilder (org.opencastproject.assetmanager.api.query.AQueryBuilder)6 AResult (org.opencastproject.assetmanager.api.query.AResult)6 RichAResult (org.opencastproject.assetmanager.api.query.RichAResult)6 SchedulerTransactionLockException (org.opencastproject.scheduler.api.SchedulerTransactionLockException)5 ARecord (org.opencastproject.assetmanager.api.query.ARecord)4 SchedulerConflictException (org.opencastproject.scheduler.api.SchedulerConflictException)4 SchedulerException (org.opencastproject.scheduler.api.SchedulerException)4 Path (javax.ws.rs.Path)3 WebApplicationException (javax.ws.rs.WebApplicationException)3 RestQuery (org.opencastproject.util.doc.rest.RestQuery)3 IOException (java.io.IOException)2 POST (javax.ws.rs.POST)2