@Test
  public void test_walk() {
    final RiakClient c = new RiakClient(RIAK_URL);

    final String ROOT = "root";
    final String LEAF1 = "leaf1";
    final String LEAF2 = "leaf2";
    final String EXCLUDED_LEAF = "excluded_leaf";
    final byte[] INCLUDED_VALUE = CharsetUtils.utf8StringToBytes("included");
    final byte[] EXCLUDED_VALUE = CharsetUtils.utf8StringToBytes("excluded");
    final String TAG_INCLUDE = "tag_include";
    final String TAG_EXCLUDE = "tag_exclude";

    // Clear out the objects we're testing with
    assertSuccess(c.delete(BUCKET, ROOT));
    assertSuccess(c.delete(BUCKET, LEAF1));
    assertSuccess(c.delete(BUCKET, LEAF2));
    assertSuccess(c.delete(BUCKET, EXCLUDED_LEAF));

    // Add a few objects
    RiakObject leaf1 = new RiakObject(BUCKET, LEAF1, INCLUDED_VALUE);
    RiakObject leaf2 = new RiakObject(BUCKET, LEAF2, INCLUDED_VALUE);
    RiakObject excludedLeaf = new RiakObject(BUCKET, EXCLUDED_LEAF, EXCLUDED_VALUE);
    RiakObject root =
        new RiakObject(c, BUCKET, ROOT)
            .addLink(new RiakLink(BUCKET, LEAF1, TAG_INCLUDE))
            .addLink(new RiakLink(BUCKET, LEAF2, TAG_INCLUDE))
            .addLink(new RiakLink(BUCKET, EXCLUDED_LEAF, TAG_EXCLUDE));
    assertSuccess(c.store(root, WRITE_3_REPLICAS()));
    assertSuccess(c.store(leaf1, WRITE_3_REPLICAS()));
    assertSuccess(c.store(leaf2, WRITE_3_REPLICAS()));
    assertSuccess(c.store(excludedLeaf, WRITE_3_REPLICAS()));

    // Perform walk
    WalkResponse walkresp = root.walk(BUCKET, TAG_INCLUDE).run();
    assertSuccess(walkresp);
    assertTrue(walkresp.hasSteps());
    assertEquals(1, walkresp.getSteps().size());
    assertEquals(2, walkresp.getSteps().get(0).size());

    // Verify expected only linked to objects are returned
    List<? extends List<RiakObject>> steps = walkresp.getSteps();
    List<String> keys = new ArrayList<String>();
    for (List<RiakObject> step : steps) {
      for (RiakObject object : step) {
        keys.add(object.getKey());
        assertArrayEquals(INCLUDED_VALUE, object.getValueAsBytes());
      }
    }
    assertTrue(keys.contains(LEAF1));
    assertTrue(keys.contains(LEAF2));
  }
  @Test
  public void testUseClassWithSameFQNInDifferentContainers() throws Exception {
    assertSuccess(
        client.createContainer(CONTAINER_1_ID, new KieContainerResource(CONTAINER_1_ID, kjar1)));

    Object person = createInstance(PERSON_CLASS_NAME);
    List<Command<?>> commands = new ArrayList<Command<?>>();
    BatchExecutionCommand batchExecution1 =
        commandsFactory.newBatchExecution(commands, KIE_SESSION_1);

    commands.add(commandsFactory.newInsert(person, PERSON_OUT_IDENTIFIER));
    commands.add(commandsFactory.newFireAllRules());

    ServiceResponse<String> response1 = ruleClient.executeCommands(CONTAINER_1_ID, batchExecution1);
    assertSuccess(response1);
    String result1 = response1.getResult();
    assertTrue(
        "Person's id should be 'Person from kjar1'!. Got result: " + result1,
        result1.contains("Person from kjar1"));

    // now execute the same commands, but for the second container. The rule in there should set
    // different id
    // (namely "Person from kjar2") for the inserted person
    assertSuccess(
        client.createContainer(CONTAINER_2_ID, new KieContainerResource(CONTAINER_2_ID, kjar2)));

    person = createInstance(PERSON_CLASS_NAME);
    commands = new ArrayList<Command<?>>();
    BatchExecutionCommand batchExecution2 =
        commandsFactory.newBatchExecution(commands, KIE_SESSION_2);

    commands.add(commandsFactory.newInsert(person, PERSON_OUT_IDENTIFIER));
    commands.add(commandsFactory.newFireAllRules());

    ServiceResponse<String> response2 = ruleClient.executeCommands(CONTAINER_2_ID, batchExecution2);
    assertSuccess(response2);
    String result2 = response2.getResult();
    assertTrue(
        "Person's id should be 'Person from kjar2'!. Got result: " + result2,
        result2.contains("Person from kjar2"));
  }
  @Test
  public void testFindTaskAssignedAsBusinessAdmin() throws Exception {
    assertSuccess(
        client.createContainer(
            "definition-project", new KieContainerResource("definition-project", releaseId)));

    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("stringData", "waiting for signal");
    parameters.put("personData", createPersonInstance("john"));

    Long processInstanceId =
        processClient.startProcess("definition-project", "definition-project.usertask", parameters);

    try {

      List<TaskSummary> tasks =
          taskClient.findTasksAssignedAsBusinessAdministrator("Administrator", 0, 10);
      assertNotNull(tasks);
      assertEquals(1, tasks.size());

      TaskSummary taskInstance = tasks.get(0);
      assertNotNull(taskInstance);
      assertEquals("First task", taskInstance.getName());
      assertEquals("", taskInstance.getDescription());
      assertEquals("Reserved", taskInstance.getStatus());
      assertEquals(0, taskInstance.getPriority().intValue());
      assertEquals("yoda", taskInstance.getActualOwner());
      assertEquals("yoda", taskInstance.getCreatedBy());
      assertEquals("definition-project.usertask", taskInstance.getProcessId());
      assertEquals("definition-project", taskInstance.getContainerId());
      assertEquals(-1, taskInstance.getParentId().longValue());
      assertEquals(processInstanceId, taskInstance.getProcessInstanceId());

      List<String> status = new ArrayList<String>();
      status.add(Status.InProgress.toString());

      tasks = taskClient.findTasksAssignedAsBusinessAdministrator("Administrator", status, 0, 10);
      assertNotNull(tasks);
      assertEquals(0, tasks.size());

    } finally {
      processClient.abortProcessInstance("definition-project", processInstanceId);
    }
  }