Search in sources :

Example 1 with TaskListImpl

use of org.olat.course.nodes.gta.model.TaskListImpl in project OpenOLAT by OpenOLAT.

the class GTAManagerTest method createIfNotExists.

@Test
public void createIfNotExists() {
    RepositoryEntry re = deployGTACourse();
    GTACourseNode node = getGTACourseNode(re);
    Assert.assertNotNull(node.getIdent());
    TaskList tasks = gtaManager.createIfNotExists(re, node);
    Assert.assertNotNull(tasks);
    dbInstance.commit();
    // reload and check
    TaskList reloadedTasks = gtaManager.getTaskList(re, node);
    Assert.assertNotNull(reloadedTasks);
    Assert.assertEquals(tasks, reloadedTasks);
    Assert.assertTrue(reloadedTasks instanceof TaskListImpl);
    TaskListImpl tasksImpl = (TaskListImpl) reloadedTasks;
    Assert.assertNotNull(tasksImpl.getCreationDate());
    Assert.assertNotNull(tasksImpl.getLastModified());
    Assert.assertEquals(re, tasksImpl.getEntry());
    Assert.assertEquals(node.getIdent(), tasksImpl.getCourseNodeIdent());
    dbInstance.commit();
    // check that a second call doesn't create a new task list
    TaskList secondTasks = gtaManager.createIfNotExists(re, node);
    Assert.assertNotNull(secondTasks);
    dbInstance.commit();
    Assert.assertEquals(tasks, secondTasks);
}
Also used : TaskList(org.olat.course.nodes.gta.TaskList) TaskListImpl(org.olat.course.nodes.gta.model.TaskListImpl) GTACourseNode(org.olat.course.nodes.GTACourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 2 with TaskListImpl

use of org.olat.course.nodes.gta.model.TaskListImpl in project openolat by klemens.

the class GTAIdentityMarkDAOTest method createTaskList.

private TaskList createTaskList() {
    TaskListImpl tasksImpl = new TaskListImpl();
    Date creationDate = new Date();
    tasksImpl.setCreationDate(creationDate);
    tasksImpl.setLastModified(creationDate);
    tasksImpl.setEntry(JunitTestHelper.createAndPersistRepositoryEntry());
    tasksImpl.setCourseNodeIdent(UUID.randomUUID().toString());
    dbInstance.getCurrentEntityManager().persist(tasksImpl);
    return tasksImpl;
}
Also used : TaskListImpl(org.olat.course.nodes.gta.model.TaskListImpl) Date(java.util.Date)

Example 3 with TaskListImpl

use of org.olat.course.nodes.gta.model.TaskListImpl in project openolat by klemens.

the class GTAManagerTest method createIfNotExists.

@Test
public void createIfNotExists() {
    RepositoryEntry re = deployGTACourse();
    GTACourseNode node = getGTACourseNode(re);
    Assert.assertNotNull(node.getIdent());
    TaskList tasks = gtaManager.createIfNotExists(re, node);
    Assert.assertNotNull(tasks);
    dbInstance.commit();
    // reload and check
    TaskList reloadedTasks = gtaManager.getTaskList(re, node);
    Assert.assertNotNull(reloadedTasks);
    Assert.assertEquals(tasks, reloadedTasks);
    Assert.assertTrue(reloadedTasks instanceof TaskListImpl);
    TaskListImpl tasksImpl = (TaskListImpl) reloadedTasks;
    Assert.assertNotNull(tasksImpl.getCreationDate());
    Assert.assertNotNull(tasksImpl.getLastModified());
    Assert.assertEquals(re, tasksImpl.getEntry());
    Assert.assertEquals(node.getIdent(), tasksImpl.getCourseNodeIdent());
    dbInstance.commit();
    // check that a second call doesn't create a new task list
    TaskList secondTasks = gtaManager.createIfNotExists(re, node);
    Assert.assertNotNull(secondTasks);
    dbInstance.commit();
    Assert.assertEquals(tasks, secondTasks);
}
Also used : TaskList(org.olat.course.nodes.gta.TaskList) TaskListImpl(org.olat.course.nodes.gta.model.TaskListImpl) GTACourseNode(org.olat.course.nodes.GTACourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 4 with TaskListImpl

use of org.olat.course.nodes.gta.model.TaskListImpl in project OpenOLAT by OpenOLAT.

the class GTAIdentityMarkDAOTest method createTaskList.

private TaskList createTaskList() {
    TaskListImpl tasksImpl = new TaskListImpl();
    Date creationDate = new Date();
    tasksImpl.setCreationDate(creationDate);
    tasksImpl.setLastModified(creationDate);
    tasksImpl.setEntry(JunitTestHelper.createAndPersistRepositoryEntry());
    tasksImpl.setCourseNodeIdent(UUID.randomUUID().toString());
    dbInstance.getCurrentEntityManager().persist(tasksImpl);
    return tasksImpl;
}
Also used : TaskListImpl(org.olat.course.nodes.gta.model.TaskListImpl) Date(java.util.Date)

Example 5 with TaskListImpl

use of org.olat.course.nodes.gta.model.TaskListImpl in project OpenOLAT by OpenOLAT.

the class GTAManagerImpl method createIfNotExists.

@Override
public TaskList createIfNotExists(RepositoryEntry entry, GTACourseNode cNode) {
    TaskList tasks = getTaskList(entry, cNode);
    if (tasks == null) {
        TaskListImpl tasksImpl = new TaskListImpl();
        Date creationDate = new Date();
        tasksImpl.setCreationDate(creationDate);
        tasksImpl.setLastModified(creationDate);
        tasksImpl.setEntry(entry);
        tasksImpl.setCourseNodeIdent(cNode.getIdent());
        dbInstance.getCurrentEntityManager().persist(tasksImpl);
        tasks = tasksImpl;
    }
    return tasks;
}
Also used : TaskList(org.olat.course.nodes.gta.TaskList) TaskListImpl(org.olat.course.nodes.gta.model.TaskListImpl) Date(java.util.Date) TaskDueDate(org.olat.course.nodes.gta.TaskDueDate) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) DueDate(org.olat.course.nodes.gta.model.DueDate)

Aggregations

TaskListImpl (org.olat.course.nodes.gta.model.TaskListImpl)6 Date (java.util.Date)4 TaskList (org.olat.course.nodes.gta.TaskList)4 Test (org.junit.Test)2 GTACourseNode (org.olat.course.nodes.GTACourseNode)2 TaskDueDate (org.olat.course.nodes.gta.TaskDueDate)2 TaskRevisionDate (org.olat.course.nodes.gta.TaskRevisionDate)2 DueDate (org.olat.course.nodes.gta.model.DueDate)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2