@Test
public void testGetWorkflowInstanceMetadata() {

  try {
    repo.addWorkflowInstance(testWrkInst);
  } catch (InstanceRepositoryException e) {
    fail(e.getMessage());
  }
  String testWrkInstId = testWrkInst.getId();
  assertNotNull(testWrkInstId);
  // get workflow instance from instance id
  WorkflowInstance WInst = null;
  try {
    WInst = repo.getWorkflowInstanceById(testWrkInstId);
  } catch (InstanceRepositoryException e) {
    fail(e.getMessage());
  }
  assertNotNull(WInst);
  // get Metadata for the workflow instance
  Metadata met;
  met = WInst.getSharedContext();
  assertNotNull(met);
  assertNotNull(met.getMap());
  assertEquals(2, met.getMap().keySet().size());
  assertNotNull(met.getAllMetadata("key1"));
  assertEquals(3, met.getAllMetadata("key1").size());
  assertNotNull(met.getAllMetadata("key2"));
  assertEquals(2, met.getAllMetadata("key2").size());
  // check key-values for key1
  boolean checkVal1 = false, checkVal2 = false, checkVal3 = false;
  for (String val : met.getAllMetadata("key1")) {
    if (val.equals("val1")) {
      checkVal1 = true;
    } else if (val.equals("val2")) {
      checkVal2 = true;
    } else if (val.equals("val3")) {
      checkVal3 = true;
    }
  }
  assert (checkVal1 && checkVal2 && checkVal3);
  // check key-values for key2
  boolean checkVal4 = false, checkVal5 = false;
  for (String val : met.getAllMetadata("key2")) {
    if (val.equals("val4")) {
      checkVal4 = true;
    } else if (val.equals("val5")) {
      checkVal5 = true;
    }
  }
  assertTrue(checkVal4 && checkVal5);
}