@Test
  public void testGetWorkflowInstanceMetadata2() throws Exception {
    WorkflowInstance wf = (WorkflowInstance) fmc.getFirstPage().getPageWorkflows().get(0);

    assertThat(wf, is(not(Matchers.nullValue())));

    Metadata meta = fmc.getWorkflowInstanceMetadata(wf.getId());

    assertNotNull(meta);
  }
  @Test
  public void testGetWorkflowById() throws RepositoryException, XmlRpcException, IOException {
    List<Workflow> workflowlist = fmc.getWorkflows();

    assertThat(workflowlist, is(not(nullValue())));

    assertThat(workflowlist.size(), is(not(0)));

    Workflow work = fmc.getWorkflowById(workflowlist.get(0).getId());

    assertThat(work, is(not(nullValue())));
  }
  @Test
  public void testGetWorkflowCurrentTaskWallClockMinutes() throws Exception {
    XmlRpcWorkflowManagerClient fmc =
        new XmlRpcWorkflowManagerClient(new URL("http://localhost:" + WM_PORT));

    List<WorkflowInstance> wfinstances = fmc.getWorkflowInstances();

    assertNotNull(wfinstances);

    double clock = fmc.getWorkflowCurrentTaskWallClockMinutes(wfinstances.get(0).getId());

    assertThat(clock, is(not(Matchers.nullValue())));
  }
  @Test
  public void testGetWorkflowInstanceById()
      throws XmlRpcException, IOException, RepositoryException {

    List<WorkflowInstance> workflowlist = fmc.getWorkflowInstances();

    assertThat(workflowlist, is(not(nullValue())));

    assertThat(workflowlist.size(), is(not(0)));

    WorkflowInstance instance = fmc.getWorkflowInstanceById(workflowlist.get(0).getId());

    assertThat(instance, is(not(nullValue())));
  }
  private static void startWorkflow() {
    XmlRpcWorkflowManagerClient client = null;
    try {
      client = new XmlRpcWorkflowManagerClient(new URL("http://localhost:" + WM_PORT));
    } catch (Exception e) {
      fail(e.getMessage());
    }

    try {
      client.sendEvent("long", new Metadata());
    } catch (Exception e) {
      LOG.log(Level.SEVERE, e.getMessage());
      throw new RuntimeException(e);
    }
  }
  @Test
  public void testGetNumWorkflowInstancesByStatus() throws Exception {

    int inst = fmc.getNumWorkflowInstancesByStatus("QUEUED");

    assertThat(inst, equalTo(0));
  }
  @Test
  public void testGetWorkflowInstances() throws IOException, XmlRpcException {

    List<WorkflowInstance> wfinstances = fmc.getWorkflowInstances();

    assertNotNull(wfinstances);
  }
  @Test
  public void testGetWorkflowInstancesByStatus() throws Exception {

    List<WorkflowInstance> wflows = fmc.getWorkflowInstancesByStatus("QUEUED");

    assertNotNull(wflows);
  }
  @Test
  public void testPaginateWorkflowInstancesByStatus() throws XmlRpcException, IOException {

    WorkflowInstancePage paginate = fmc.paginateWorkflowInstances(2, "QUEUED");

    assertThat(paginate, is(not(nullValue())));
  }
  @Test
  public void testGetNumWorkflowInstances() throws Exception {

    int num = fmc.getNumWorkflowInstances();

    assertThat(num, is(not(0)));
  }
  @Ignore
  @Test
  public void testRefreshRepository() throws XmlRpcException, IOException {

    boolean refresh = fmc.refreshRepository();

    assertThat(refresh, equalTo(true));
  }
  @Test
  public void testGetConditionById() throws Exception {

    WorkflowCondition cond = fmc.getConditionById("urn:oodt:TrueCondition");

    assertNotNull(cond);

    assertThat(cond.getConditionName(), equalTo("True Condition"));
  }
  @Test
  public void testUpdateWorkflowInstanceStatus()
      throws XmlRpcException, IOException, RepositoryException {

    List<WorkflowInstance> workflowlist = fmc.getWorkflowInstances();

    assertThat(workflowlist, is(not(nullValue())));

    assertThat(workflowlist.size(), is(not(0)));

    WorkflowInstance instance = fmc.getWorkflowInstanceById(workflowlist.get(0).getId());

    assertThat(instance, is(not(nullValue())));

    boolean upd = fmc.updateWorkflowInstanceStatus(instance.getId(), "RUNNING");

    assertThat(upd, equalTo(true));
  }
  @Test
  public void testGetTaskById() throws Exception {

    WorkflowTask task = fmc.getTaskById("urn:oodt:HelloWorld");

    assertThat(task, is(not(nullValue())));

    assertThat(task.getTaskName(), equalTo("Hello World"));
  }
  @Test
  public void testGetWFMUrl() {

    URL url = fmc.getWorkflowManagerUrl();

    assertThat(url, is(not(nullValue())));

    assertThat(url.toString(), equalTo("http://localhost:" + WM_PORT));
  }
  @Test
  public void testGetWorkflowInstanceMetadataActuallyUsingTheXmlRpcWorkflowManagerClient()
      throws IOException, RepositoryException, XmlRpcException {

    List<Workflow> workflows = fmc.getWorkflows();
    assertThat(workflows, is(not(empty())));

    assertNotNull(workflows.get(0).getName());
  }
  @Ignore
  @Test
  public void testGetNullWorkflowInstances()
      throws RepositoryException, XmlRpcException, IOException, InterruptedException {

    Thread.sleep(3000);
    WorkflowInstance instance = fmc.getWorkflowInstanceById("1234");

    assertThat(instance, is(nullValue()));
  }
  @Test
  public void testGetPages() throws Exception {

    Thread.sleep(3000);
    WorkflowInstancePage page = fmc.getFirstPage();

    assertNotNull(page);

    WorkflowInstancePage lastpage = fmc.getLastPage();

    assertNotNull(lastpage);

    WorkflowInstancePage nextpage = fmc.getNextPage(page);

    assertNotNull(nextpage);

    WorkflowInstancePage prevpage = fmc.getPrevPage(nextpage);

    assertNotNull(prevpage);
  }
  @Test
  public void testGetWorkflowsByEvent() throws Exception {

    List<Workflow> wflows = fmc.getWorkflowsByEvent("long");

    assertNotNull(wflows);

    assertThat(wflows, hasSize(2));

    assertThat(wflows.get(0).getName(), equalTo("Long Workflow"));
  }
  @Test
  public void testGetRegisteredEvents() throws Exception {

    List<String> events = fmc.getRegisteredEvents();

    assertThat(events, is(not(nullValue())));

    assertThat(events, hasSize(12));

    assertThat(events, hasItem("stuck"));
  }
  @Test
  public void testGetNullWorkflowInstancesByStatus() throws XmlRpcException, IOException {
    List<WorkflowInstance> instances = fmc.getWorkflowInstancesByStatus("NULL");

    assertThat(instances, is(empty()));
  }