/**
   * @verifies load objects based on the resource description
   * @see RestAssuredService#loadObjects(String, com.burkeware.search.api.resource.Resource)
   */
  @Test
  public void loadObjects_shouldLoadObjectsBasedOnTheResourceDescription() throws Exception {

    Resource resource = null;

    resource = Context.getResource("Cohort Resource");
    Assert.assertNotNull(resource);
    service.loadObjects(StringUtil.EMPTY, resource);
    List<Cohort> cohorts = service.getObjects(StringUtil.EMPTY, Cohort.class);
    for (Cohort cohort : cohorts) {
      resource = Context.getResource("Cohort Member Resource");
      Assert.assertNotNull(resource);
      service.loadObjects(cohort.getUuid(), resource);
      List<Patient> patients = service.getObjects(StringUtil.EMPTY, Patient.class);
      for (Patient patient : patients) {
        resource = Context.getResource("Observation Resource");
        Assert.assertNotNull(resource);
        service.loadObjects(patient.getUuid(), resource);
      }
    }

    List<Patient> patients = service.getObjects("name:A*", Patient.class);
    Assert.assertNotNull(patients);
    Assert.assertTrue(patients.size() > 0);
    for (Patient patient : patients) {
      Assert.assertNotNull(patient);
      Assert.assertEquals(Patient.class, patient.getClass());
    }

    Patient patient =
        service.getObject("name: " + StringUtil.quote(REST_PATIENT_NAME), Patient.class);
    Assert.assertNotNull(patient);
    Assert.assertEquals(Patient.class, patient.getClass());
  }
  /**
   * @verifies return null when no object match the key
   * @see RestAssuredService#getObject(String, com.burkeware.search.api.resource.Resource)
   */
  @Test
  public void getObject_shouldReturnNullWhenNoObjectMatchTheKey() throws Exception {
    Patient patient;
    Resource resource;

    resource = Context.getResource("Patient Resource");
    patient = (Patient) service.getObject(StringUtil.quote(REST_PATIENT_UUID), resource);
    Assert.assertNull(patient);

    resource = Context.getResource("Cohort Member Resource");
    patient = (Patient) service.getObject(StringUtil.quote(REST_PATIENT_UUID), resource);
    Assert.assertNotNull(patient);
    Assert.assertEquals(Patient.class, patient.getClass());
  }
 /**
  * @verifies throw IOException if the key and resource unable to return unique object
  * @see RestAssuredService#getObject(String, com.burkeware.search.api.resource.Resource)
  */
 @Test(expected = IOException.class)
 public void getObject_shouldThrowIOExceptionIfTheKeyAndResourceUnableToReturnUniqueObject()
     throws Exception {
   Resource resource = Context.getResource("Cohort Member Resource");
   Patient patient = (Patient) service.getObject("name:A*", resource);
   Assert.assertNull(patient);
 }
 /**
  * @verifies return empty list when no object match the search string and resource
  * @see RestAssuredService#getObjects(String, com.burkeware.search.api.resource.Resource)
  */
 @Test
 public void getObjects_shouldReturnEmptyListWhenNoObjectMatchTheSearchStringAndResource()
     throws Exception {
   Resource resource = Context.getResource("Cohort Member Resource");
   List<Object> patients = service.getObjects("name:Zz*", resource);
   Assert.assertNotNull(patients);
   Assert.assertTrue(patients.size() == 0);
 }
 /**
  * @verifies return all object matching the search search string and resource
  * @see RestAssuredService#getObjects(String, com.burkeware.search.api.resource.Resource)
  */
 @Test
 public void getObjects_shouldReturnAllObjectMatchingTheSearchSearchStringAndResource()
     throws Exception {
   Resource resource = Context.getResource("Cohort Member Resource");
   List<Object> patients = service.getObjects("name:Ab*", resource);
   Assert.assertNotNull(patients);
   Assert.assertTrue(patients.size() > 0);
   for (Object patient : patients) {
     Assert.assertNotNull(patient);
     Assert.assertEquals(Patient.class, patient.getClass());
   }
 }
  /**
   * @verifies remove an object from the internal index system
   * @see RestAssuredService#invalidate(Object, com.burkeware.search.api.resource.Resource)
   */
  @Test
  public void invalidate_shouldRemoveAnObjectFromTheInternalIndexSystem() throws Exception {
    Patient patient = service.getObject(StringUtil.quote(REST_PATIENT_UUID), Patient.class);
    Assert.assertNotNull(patient);
    Assert.assertEquals(Patient.class, patient.getClass());

    Resource resource = Context.getResource("Cohort Member Resource");
    Patient deletedPatient = (Patient) service.invalidate(patient, resource);
    Assert.assertNotNull(deletedPatient);
    Assert.assertEquals(Patient.class, deletedPatient.getClass());

    Patient afterDeletionPatient =
        service.getObject(StringUtil.quote(REST_PATIENT_UUID), Patient.class);
    Assert.assertNull(afterDeletionPatient);
  }
  /**
   * @verifies load object from filesystem based on the resource description
   * @see RestAssuredService#loadObjects(String, com.burkeware.search.api.resource.Resource,
   *     java.io.File)
   */
  @Test
  public void loadObjects_shouldLoadObjectFromFilesystemBasedOnTheResourceDescription()
      throws Exception {

    URL corpus = RestAssuredService.class.getResource("sample/corpus");
    Resource resource = Context.getResource("Patient Resource");
    Assert.assertNotNull(resource);
    service.loadObjects(StringUtil.EMPTY, resource, new File(corpus.getPath()));

    List<Patient> patients = service.getObjects("name:Test*", Patient.class);
    Assert.assertNotNull(patients);
    Assert.assertTrue(patients.size() > 0);
    for (Patient patient : patients) {
      Assert.assertNotNull(patient);
      Assert.assertEquals(Patient.class, patient.getClass());
    }

    Patient patient =
        service.getObject("name: " + StringUtil.quote(FILE_PATIENT_NAME), Patient.class);
    Assert.assertNotNull(patient);
    Assert.assertEquals(Patient.class, patient.getClass());
  }