/**
   * @verifies return object with matching key
   * @see RestAssuredService#getObject(String, com.burkeware.search.api.resource.Resource)
   */
  @Test
  public void getObject_shouldReturnObjectWithMatchingKey() throws Exception {

    Resource resource = Context.getResource("Cohort Member Resource");
    Patient patient = (Patient) service.getObject(StringUtil.quote(REST_PATIENT_UUID), resource);
    Assert.assertNotNull(patient);
    Assert.assertEquals(Patient.class, patient.getClass());
  }
 /**
  * @verifies return all object matching the search search string and class
  * @see RestAssuredService#getObjects(String, Class)
  */
 @Test
 public void getObjects_shouldReturnAllObjectMatchingTheSearchSearchStringAndClass()
     throws Exception {
   List<Patient> patients = service.getObjects("name:Ab*", Patient.class);
   Assert.assertNotNull(patients);
   Assert.assertTrue(patients.size() > 0);
   for (Patient 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 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 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());
  }
 /**
  * @verifies return object with matching key and type
  * @see RestAssuredService#getObject(String, Class)
  */
 @Test
 public void getObject_shouldReturnObjectWithMatchingKeyAndType() throws Exception {
   Patient patient = service.getObject(StringUtil.quote(REST_PATIENT_UUID), Patient.class);
   Assert.assertNotNull(patient);
   Assert.assertEquals(Patient.class, patient.getClass());
 }