コード例 #1
0
  @Test(expected = RepositoryException.class)
  public void testGetWorkflowsNullRepository() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(null);
    List flows = repo.getWorkflows();

    assertNotNull(flows);
  }
コード例 #2
0
  @Test(expected = RepositoryException.class)
  public void testGetTasksByWorkflowNameNoDataSource() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(null);
    List<WorkflowTask> tasks = repo.getTasksByWorkflowName(null);

    assertThat(tasks, allOf(notNullValue(), hasSize(2)));
  }
コード例 #3
0
  @Test
  public void testGetWorkflows() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);
    List<Workflow> flows = repo.getWorkflows();

    assertThat(flows, allOf(notNullValue(), hasSize(1)));
  }
コード例 #4
0
  @Test
  public void testDataSourceRepo() throws SQLException, RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);

    // test id 1
    WorkflowCondition wc = repo.getWorkflowConditionById("1");
    assertEquals(wc.getConditionName(), "CheckCond");
    WorkflowConditionInstance condInst =
        GenericWorkflowObjectFactory.getConditionObjectFromClassName(
            wc.getConditionInstanceClassName());
    Metadata m = new Metadata();
    m.addMetadata("Met1", "Val1");
    m.addMetadata("Met2", "Val2");
    m.addMetadata("Met3", "Val3");
    assertTrue(condInst.evaluate(m, wc.getTaskConfig()));

    // test id 2
    wc = repo.getWorkflowConditionById("2");
    assertEquals(wc.getConditionName(), "FalseCond");
    condInst =
        GenericWorkflowObjectFactory.getConditionObjectFromClassName(
            wc.getConditionInstanceClassName());
    assertFalse(condInst.evaluate(m, wc.getTaskConfig()));

    // test id 3
    wc = repo.getWorkflowConditionById("3");
    assertEquals(wc.getConditionName(), "TrueCond");
    condInst =
        GenericWorkflowObjectFactory.getConditionObjectFromClassName(
            wc.getConditionInstanceClassName());
    assertTrue(condInst.evaluate(m, wc.getTaskConfig()));
  }
コード例 #5
0
  @Test
  public void testGetTasksByWorkflowNameNull() throws RepositoryException {

    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);
    List<WorkflowTask> tasks = repo.getTasksByWorkflowName(null);

    assertThat(tasks, nullValue());
  }
コード例 #6
0
  @Test(expected = RepositoryException.class)
  public void testGetConditionsByTaskIdNoDataSource() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(null);
    List<WorkflowCondition> workflow = repo.getConditionsByTaskName("1");

    assertThat(workflow, allOf(notNullValue(), hasSize(1)));
    assertThat(workflow.get(0).getConditionName(), equalTo("Test Condition"));
  }
コード例 #7
0
  @Test
  public void testGetRegisteredEvents() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);
    List<String> workflow = repo.getRegisteredEvents();

    assertThat(workflow, allOf(notNullValue(), hasSize(1)));
    assertThat(workflow.get(0), equalTo("event"));
  }
コード例 #8
0
  @Test
  public void testGetTaskById() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);
    WorkflowTask task = repo.getTaskById("1");

    assertThat(task, notNullValue());
    assertThat(task.getTaskName(), allOf(notNullValue(), equalTo("Test Task")));
  }
コード例 #9
0
  @Test
  public void testGetWorkflowByNameIncorrect() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);

    Workflow w = repo.getWorkflowByName("Broken Workflow");

    assertNull(w);
  }
コード例 #10
0
  @Test(expected = RepositoryException.class)
  public void testGetTaskByIdNoDataSource() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(null);
    WorkflowTask task = repo.getTaskById("1");

    assertThat(task, notNullValue());
    assertThat(task.getTaskName(), allOf(notNullValue(), equalTo("Test")));
  }
コード例 #11
0
  @Test(expected = RepositoryException.class)
  public void testGetworkflowByIdNoDataSource() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(null);

    Workflow w = repo.getWorkflowById("1");

    assertNull(w);
  }
コード例 #12
0
  @Test
  public void testGetworkflowByIncorredId() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);

    Workflow w = repo.getWorkflowById("100");

    assertNull(w);
  }
コード例 #13
0
  @Test
  public void testGetWorkflowsForEvent() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);
    List<Workflow> workflow = repo.getWorkflowsForEvent("event");

    assertThat(workflow, allOf(notNullValue(), hasSize(1)));

    assertThat(workflow.get(0).getName(), equalTo("Test Workflow"));
  }
コード例 #14
0
  @Test
  public void testGetConditions() throws RepositoryException {

    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);
    List<WorkflowCondition> task = repo.getConditions();

    assertThat(task, allOf(notNullValue(), hasSize(4)));
    assertThat(task.get(0).getConditionName(), allOf(notNullValue(), equalTo("CheckCond")));
  }
コード例 #15
0
  @Test(expected = RepositoryException.class)
  public void testGetConfigurationByTaskIdNoDataSource() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(null);
    WorkflowTaskConfiguration workflow = repo.getConfigurationByTaskId("1");

    assertThat(workflow, notNullValue());
    assertThat(workflow.getProperties(), notNullValue());
    assertThat(workflow.getProperties().getProperty("test"), notNullValue());
  }
コード例 #16
0
  @Test
  public void testGetConfigurationByTaskId() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);
    WorkflowTaskConfiguration workflow = repo.getConfigurationByTaskId("1");

    assertThat(workflow, notNullValue());
    assertThat(workflow.getProperties(), notNullValue());
    assertThat(workflow.getProperties().getProperty("TestProp"), notNullValue());
  }
コード例 #17
0
  @Test
  public void testGetConditionsByTaskId() throws RepositoryException {

    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);
    List<WorkflowCondition> workflow = repo.getConditionsByTaskId("1");

    assertThat(workflow, allOf(notNullValue(), hasSize(1)));
    assertThat(workflow.get(0).getConditionName(), equalTo("TrueCond"));
  }
コード例 #18
0
  @Test
  public void testGetworkflowByName() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);

    Workflow w = repo.getWorkflowByName("Test Workflow");

    assertNotNull(w);

    assertThat("Test Workflow", equalTo(w.getName()));
  }
コード例 #19
0
  @Test(expected = RepositoryException.class)
  public void testGetWorkflowsForEventNoDataSource() throws RepositoryException {

    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(null);
    List<Workflow> workflow = repo.getWorkflowsForEvent("event", false, false);

    assertThat(workflow, allOf(notNullValue(), hasSize(2)));

    assertThat(workflow.get(0).getPreConditions(), allOf(notNullValue(), hasSize(0)));
    assertThat(workflow.get(0).getPostConditions(), allOf(notNullValue(), hasSize(0)));
  }
コード例 #20
0
  @Test
  public void testGetworkflowsForEventNoTasksOrConditions() throws RepositoryException {

    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);
    List<Workflow> workflow = repo.getWorkflowsForEvent("event", false, false);

    assertThat(workflow, allOf(notNullValue(), hasSize(1)));

    assertThat(workflow.get(0).getPreConditions(), allOf(notNullValue(), hasSize(0)));
    assertThat(workflow.get(0).getPostConditions(), allOf(notNullValue(), hasSize(0)));
  }
コード例 #21
0
  @Test
  public void testGetTaskByWorkflowName() throws RepositoryException {

    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);
    List<WorkflowTask> tasks = repo.getTasksByWorkflowName("Test Workflow");

    assertThat(tasks, allOf(notNullValue(), hasSize(2)));

    assertThat(tasks.get(0).getTaskName(), equalTo("Test Task"));

    assertThat(tasks.get(1).getTaskName(), equalTo("Test Task2"));
  }
コード例 #22
0
  @Test
  public void testGetWorkflowsNoConditionsOrTasks() throws RepositoryException {

    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);
    List<Workflow> flows = repo.getWorkflows(false, false);

    assertThat(flows, allOf(notNullValue(), hasSize(1)));

    assertThat(flows.get(0).getPreConditions(), hasSize(0));

    assertThat(flows.get(0).getPostConditions(), hasSize(0));

    assertThat(flows.get(0).getTasks(), hasSize(0));
  }
コード例 #23
0
  /** @since OODT-205 */
  @Test
  public void testWorkflowConditions() {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);

    Workflow w = null;
    try {
      w = repo.getWorkflowById("1");
    } catch (Exception e) {
      fail(e.getMessage());
    }

    assertNotNull(w);
    assertNotNull(w.getConditions());
    assertTrue(w.getConditions().size() > 0);
    assertEquals(w.getConditions().size(), 1);
  }
コード例 #24
0
  @Test
  public void testAddTask() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);
    WorkflowTask t = new WorkflowTask();
    t.setTaskName("Manual");
    t.setTaskId("50");
    t.setPreConditions(Collections.EMPTY_LIST);
    t.setPostConditions(Collections.EMPTY_LIST);
    String workflow = repo.addTask(t);

    assertThat(workflow, notNullValue());
    assertThat(workflow, equalTo("3"));

    // TODO GET TASK BACK

  }
コード例 #25
0
  @Test
  public void testAddWorkflow() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(ds);
    Workflow w = new Workflow();
    w.setId("50");
    w.setName("Manual");
    WorkflowTask t = new WorkflowTask();
    t.setTaskId("1");
    List<WorkflowTask> l = new ArrayList<WorkflowTask>();
    l.add(t);
    w.setTasks(l);
    String workflow = repo.addWorkflow(w);

    assertThat(workflow, notNullValue());
    assertThat(workflow, equalTo("50"));

    // TODO GET WORKFLOW

  }
コード例 #26
0
  @Test(expected = RepositoryException.class)
  public void testGetWorkflowByNameNoDataSource() throws RepositoryException {
    DataSourceWorkflowRepository repo = new DataSourceWorkflowRepository(null);

    repo.getWorkflowByName("Broken Workflow");
  }