Example usage for java.time LocalDate parse

List of usage examples for java.time LocalDate parse

Introduction

In this page you can find the example usage for java.time LocalDate parse.

Prototype

public static LocalDate parse(CharSequence text) 

Source Link

Document

Obtains an instance of LocalDate from a text string such as 2007-12-03 .

Usage

From source file:serposcope.controllers.google.GoogleGroupController.java

@FilterWith({ XSRFFilter.class, AdminFilter.class })
public Result delEvent(Context context, @Param("day") String day) {
    FlashScope flash = context.getFlashScope();
    Group group = context.getAttribute("group", Group.class);

    Event event = new Event();
    event.setGroupId(group.getId());//  w  w w .  ja  v a  2s .  co  m
    try {
        event.setDay(LocalDate.parse(day));
    } catch (Exception ex) {
    }
    if (event.getDay() == null) {
        flash.error("error.invalidDate");
        return Results.redirect(
                router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId()));
    }

    baseDB.event.delete(event);
    flash.success("google.group.eventDeleted");
    return Results
            .redirect(router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId()));
}

From source file:org.ojbc.adapters.analyticsstaging.custody.CamelContextAdamsTest.java

public void testBookingReportServiceRouteDup() throws Exception, IOException {
    Exchange senderExchange = createSenderExchange(
            "src/test/resources/xmlInstances/bookingReport/BookingReport-Adams-dup.xml");

    Person person = analyticalDatastoreDAO.getPerson(1);
    Assert.assertNotNull(person);/*from  www.  j av  a2  s .  c  o  m*/

    Booking booking = analyticalDatastoreDAO.getBookingByBookingNumber("Booking Number");
    assertNotNull(booking);

    List<BookingCharge> bookingCharges = analyticalDatastoreDAO.getBookingCharges(1);
    assertFalse(bookingCharges.isEmpty());

    List<BookingArrest> bookingArrests = analyticalDatastoreDAO.getBookingArrests(1);
    assertFalse(bookingArrests.isEmpty());

    //Send the one-way exchange.  Using template.send will send an one way message
    Exchange returnExchange = template.send("direct:bookingReportServiceEndpoint", senderExchange);

    //Use getException to see if we received an exception
    if (returnExchange.getException() != null) {
        throw new Exception(returnExchange.getException());
    }

    assertTrue(jdbcTemplate.queryForObject("select count(*)=1 from Booking", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=2 from BookingArrest", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=2 from BookingCharge", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=1 from Location", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=1 from Person", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=1 from BehavioralHealthAssessment", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=1 from Treatment", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=1 from BehavioralHealthEvaluation", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from BehavioralHealthAssessmentCategory",
            Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=1 from PrescribedMedication", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=1 from CustodyRelease", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from CustodyStatusChange", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from CustodyStatusChangeArrest", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from CustodyStatusChangeCharge", Boolean.class));

    booking = analyticalDatastoreDAO.getBookingByBookingNumber("Booking Number");
    assertNotNull(booking);

    assertEquals(LocalDate.parse("2013-12-17"), booking.getBookingDate());
    assertEquals(LocalTime.parse("09:30"), booking.getBookingTime());
    assertThat(booking.getFacilityId(), is(1));
    assertThat(booking.getSupervisionUnitTypeId(), nullValue());
    assertEquals("Booking Number", booking.getBookingNumber());
    assertEquals(LocalDate.parse("2014-12-17"), booking.getScheduledReleaseDate());
    assertThat(booking.getInmateJailResidentIndicator(), is(false));

    person = analyticalDatastoreDAO.getPerson(booking.getPersonId());
    Assert.assertNotNull(person);

    assertThat(person.getPersonId(), is(not(1)));
    assertThat(person.getPersonSexId(), is(1));
    assertThat(person.getPersonRaceId(), is(1));
    assertThat(person.getPersonSexDescription(), is("Male"));
    assertThat(person.getPersonRaceDescription(), is("Asian"));
    assertThat(person.getLanguage(), is("English"));
    assertThat(person.getPersonBirthDate(), is(LocalDate.parse("1968-12-17")));
    Assert.assertEquals("e807f1fcf82d132f9bb018ca6738a19f", person.getPersonUniqueIdentifier());
    assertThat(person.getLanguageId(), is(1));
    assertThat(person.getSexOffenderStatusTypeId(), is(1));
    assertThat(person.getMilitaryServiceStatusType().getValue(), is("Honorable Discharge"));

    assertThat(person.getEducationLevel(), is("High School Graduate"));
    assertThat(person.getOccupation(), is("Truck Driver"));

    List<BehavioralHealthAssessment> behavioralHealthAssessments = analyticalDatastoreDAO
            .getBehavioralHealthAssessments(booking.getPersonId());
    assertFalse(behavioralHealthAssessments.isEmpty());

    BehavioralHealthAssessment behavioralHealthAssessment = behavioralHealthAssessments.get(0);

    assertTrue(behavioralHealthAssessment.getBehavioralHealthDiagnoses().size() == 1);
    assertThat(behavioralHealthAssessment.getBehavioralHealthDiagnoses().get(0), is("Schizophrenia 295.10"));
    assertThat(behavioralHealthAssessment.getPersonId(), is(not(1)));
    assertThat(behavioralHealthAssessment.getBehavioralHealthAssessmentId(), is(not(1)));
    assertThat(behavioralHealthAssessment.getSeriousMentalIllness(), is(true));
    assertThat(behavioralHealthAssessment.getCareEpisodeStartDate(), is(LocalDate.parse("2016-01-01")));
    assertThat(behavioralHealthAssessment.getCareEpisodeEndDate(), is(LocalDate.parse("2016-04-01")));
    assertThat(behavioralHealthAssessment.getEnrolledProviderName(), is("79"));
    assertThat(behavioralHealthAssessment.getMedicaidStatusTypeId(), nullValue());

    List<Treatment> treatments = analyticalDatastoreDAO
            .getTreatments(behavioralHealthAssessment.getBehavioralHealthAssessmentId());
    assertThat(treatments.size(), is(1));

    Treatment treatment = treatments.get(0);
    assertThat(treatment.getBehavioralHealthAssessmentID(), is(not(1)));
    assertThat(treatment.getTreatmentStartDate(), is(LocalDate.parse("2016-01-01")));
    assertThat(treatment.getTreatmentAdmissionReasonTypeId(), nullValue());
    assertThat(treatment.getTreatmentStatusTypeId(), nullValue());
    assertThat(treatment.getTreatmentProviderName(), is("Treatment Providing Organization Name"));

    List<PrescribedMedication> prescribedMedications = analyticalDatastoreDAO
            .getPrescribedMedication(behavioralHealthAssessment.getBehavioralHealthAssessmentId());
    assertThat(prescribedMedications.size(), is(1));

    PrescribedMedication prescribedMedication = prescribedMedications.get(0);
    assertThat(prescribedMedication.getBehavioralHealthAssessmentID(), is(not(1)));
    assertThat(prescribedMedication.getMedicationDescription(), is("Zyprexa"));
    assertThat(prescribedMedication.getMedicationDispensingDate(), is(LocalDate.parse("2016-01-01")));
    assertThat(prescribedMedication.getMedicationDoseMeasure(), is("3mg"));

    bookingArrests = analyticalDatastoreDAO.getBookingArrests(booking.getBookingId());
    assertFalse(bookingArrests.isEmpty());
    BookingArrest bookingArrest = bookingArrests.get(0);

    assertThat(bookingArrest.getBookingId(), is(booking.getBookingId()));
    assertThat(bookingArrest.getBookingArrestId(), is(not(1)));
    assertEquals("392", bookingArrest.getAddress().getStreetNumber());
    assertEquals("Woodlawn Ave", bookingArrest.getAddress().getStreetName());
    assertEquals("Burlington", bookingArrest.getAddress().getCity());
    assertEquals("NY", bookingArrest.getAddress().getState());
    assertEquals("05408", bookingArrest.getAddress().getPostalcode());
    assertTrue(bookingArrest.getAddress().getLocationLatitude().doubleValue() == 56.1111);
    assertTrue(bookingArrest.getAddress().getLocationLongitude().doubleValue() == 32.1111);
    assertThat(bookingArrest.getArrestAgencyId(), is(29));

    bookingCharges = analyticalDatastoreDAO.getBookingCharges(booking.getBookingId());
    assertThat(bookingCharges.size(), is(2));

    BookingCharge bookingCharge = bookingCharges.get(0);
    assertThat(bookingCharge.getChargeCode(), is("Charge Code ID"));
    assertThat(bookingCharge.getBookingArrestId(), is(not(1)));
    assertTrue(bookingCharge.getBondAmount().doubleValue() == 500.00);
    assertThat(bookingCharge.getBondType().getValue(), is("CASH/SURETY/PROPERTY"));
    assertThat(bookingCharge.getAgencyId(), is(21));
    assertThat(bookingCharge.getChargeClassTypeId(), is(1));
    assertThat(bookingCharge.getBondStatusTypeId(), is(17));
    assertThat(bookingCharge.getChargeJurisdictionTypeId(), is(3));
    assertThat(bookingCharge.getChargeDisposition(), is("Disposition"));

    CustodyRelease custodyRelease = analyticalDatastoreDAO.getCustodyReleaseByBookingId(booking.getBookingId());
    log.info(custodyRelease.toString());
    assertEquals(LocalDate.parse("2014-12-17"), custodyRelease.getReleaseDate());
    assertEquals(LocalTime.parse("10:30"), custodyRelease.getReleaseTime());

    analyticalDatastoreDAO.deleteBooking(booking.getBookingId());

    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from Booking", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from BookingArrest", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from BookingCharge", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from Location", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from Person", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from BehavioralHealthAssessment", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from Treatment", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from BehavioralHealthEvaluation", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from BehavioralHealthAssessmentCategory",
            Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from PrescribedMedication", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from CustodyRelease", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from CustodyStatusChange", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from CustodyStatusChangeArrest", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from CustodyStatusChangeCharge", Boolean.class));
}

From source file:org.ojbc.adapters.analyticsstaging.custody.CamelContextAdamsWrongOrderTest.java

public void testBookingReportServiceRouteDup() throws Exception, IOException {
    Exchange senderExchange = createSenderExchange(
            "src/test/resources/xmlInstances/bookingReport/BookingReport-Adams-dup.xml");

    Person person = analyticalDatastoreDAO.getPerson(1);
    Assert.assertNotNull(person);//from   w  w  w  .j  ava 2  s  .  co m

    Booking booking = analyticalDatastoreDAO.getBookingByBookingNumber("Booking Number");
    assertNotNull(booking);

    List<BookingCharge> bookingCharges = analyticalDatastoreDAO.getBookingCharges(1);
    assertFalse(bookingCharges.isEmpty());

    List<BookingArrest> bookingArrests = analyticalDatastoreDAO.getBookingArrests(1);
    assertFalse(bookingArrests.isEmpty());

    //Send the one-way exchange.  Using template.send will send an one way message
    Exchange returnExchange = template.send("direct:bookingReportServiceEndpoint", senderExchange);

    //Use getException to see if we received an exception
    if (returnExchange.getException() != null) {
        throw new Exception(returnExchange.getException());
    }

    assertTrue(jdbcTemplate.queryForObject("select count(*)=1 from Booking", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=2 from BookingArrest", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=2 from BookingCharge", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=1 from Location", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=1 from Person", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=1 from BehavioralHealthAssessment", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=1 from Treatment", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=1 from BehavioralHealthEvaluation", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from BehavioralHealthAssessmentCategory",
            Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=1 from PrescribedMedication", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=1 from CustodyRelease", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from CustodyStatusChange", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from CustodyStatusChangeArrest", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from CustodyStatusChangeCharge", Boolean.class));

    booking = analyticalDatastoreDAO.getBookingByBookingNumber("Booking Number");
    assertNotNull(booking);

    assertEquals(LocalDate.parse("2013-12-17"), booking.getBookingDate());
    assertEquals(LocalTime.parse("09:30"), booking.getBookingTime());
    assertThat(booking.getFacilityId(), is(1));
    assertThat(booking.getSupervisionUnitTypeId(), nullValue());
    assertEquals("Booking Number", booking.getBookingNumber());
    assertEquals(LocalDate.parse("2014-12-17"), booking.getScheduledReleaseDate());
    assertThat(booking.getInmateJailResidentIndicator(), is(false));

    person = analyticalDatastoreDAO.getPerson(booking.getPersonId());
    Assert.assertNotNull(person);

    assertThat(person.getPersonId(), is(not(1)));
    assertThat(person.getPersonSexId(), is(1));
    assertThat(person.getPersonRaceId(), is(1));
    assertThat(person.getPersonSexDescription(), is("Male"));
    assertThat(person.getPersonRaceDescription(), is("Asian"));
    assertThat(person.getLanguage(), is("English"));
    assertThat(person.getPersonBirthDate(), is(LocalDate.parse("1968-12-17")));
    Assert.assertEquals("e807f1fcf82d132f9bb018ca6738a19f", person.getPersonUniqueIdentifier());
    assertThat(person.getLanguageId(), is(1));
    assertThat(person.getSexOffenderStatusTypeId(), is(1));
    assertThat(person.getMilitaryServiceStatusType().getValue(), is("Honorable Discharge"));

    assertThat(person.getEducationLevel(), is("High School Graduate"));
    assertThat(person.getOccupation(), is("Truck Driver"));

    List<BehavioralHealthAssessment> behavioralHealthAssessments = analyticalDatastoreDAO
            .getBehavioralHealthAssessments(booking.getPersonId());
    assertFalse(behavioralHealthAssessments.isEmpty());

    BehavioralHealthAssessment behavioralHealthAssessment = behavioralHealthAssessments.get(0);

    assertTrue(behavioralHealthAssessment.getBehavioralHealthDiagnoses().size() == 1);
    assertThat(behavioralHealthAssessment.getBehavioralHealthDiagnoses().get(0), is("Schizophrenia 295.10"));
    assertThat(behavioralHealthAssessment.getPersonId(), is(not(1)));
    assertThat(behavioralHealthAssessment.getBehavioralHealthAssessmentId(), is(not(1)));
    assertThat(behavioralHealthAssessment.getSeriousMentalIllness(), is(true));
    assertThat(behavioralHealthAssessment.getCareEpisodeStartDate(), is(LocalDate.parse("2016-01-01")));
    assertThat(behavioralHealthAssessment.getCareEpisodeEndDate(), is(LocalDate.parse("2016-04-01")));
    assertThat(behavioralHealthAssessment.getEnrolledProviderName(), is("79"));
    assertThat(behavioralHealthAssessment.getMedicaidStatusTypeId(), nullValue());

    List<Treatment> treatments = analyticalDatastoreDAO
            .getTreatments(behavioralHealthAssessment.getBehavioralHealthAssessmentId());
    assertThat(treatments.size(), is(1));

    Treatment treatment = treatments.get(0);
    assertThat(treatment.getBehavioralHealthAssessmentID(), is(not(1)));
    assertThat(treatment.getTreatmentStartDate(), is(LocalDate.parse("2016-01-01")));
    assertThat(treatment.getTreatmentAdmissionReasonTypeId(), nullValue());
    assertThat(treatment.getTreatmentStatusTypeId(), nullValue());
    assertThat(treatment.getTreatmentProviderName(), is("Treatment Providing Organization Name"));

    List<PrescribedMedication> prescribedMedications = analyticalDatastoreDAO
            .getPrescribedMedication(behavioralHealthAssessment.getBehavioralHealthAssessmentId());
    assertThat(prescribedMedications.size(), is(1));

    PrescribedMedication prescribedMedication = prescribedMedications.get(0);
    assertThat(prescribedMedication.getBehavioralHealthAssessmentID(), is(not(1)));
    assertThat(prescribedMedication.getMedicationDescription(), is("Zyprexa"));
    assertThat(prescribedMedication.getMedicationDispensingDate(), is(LocalDate.parse("2016-01-01")));
    assertThat(prescribedMedication.getMedicationDoseMeasure(), is("3mg"));

    bookingArrests = analyticalDatastoreDAO.getBookingArrests(booking.getBookingId());
    assertFalse(bookingArrests.isEmpty());
    BookingArrest bookingArrest = bookingArrests.get(0);

    assertThat(bookingArrest.getBookingId(), is(booking.getBookingId()));
    assertThat(bookingArrest.getBookingArrestId(), is(not(1)));
    assertEquals("392", bookingArrest.getAddress().getStreetNumber());
    assertEquals("Woodlawn Ave", bookingArrest.getAddress().getStreetName());
    assertEquals("Burlington", bookingArrest.getAddress().getCity());
    assertEquals("NY", bookingArrest.getAddress().getState());
    assertEquals("05408", bookingArrest.getAddress().getPostalcode());
    assertTrue(bookingArrest.getAddress().getLocationLatitude().doubleValue() == 56.1111);
    assertTrue(bookingArrest.getAddress().getLocationLongitude().doubleValue() == 32.1111);
    assertThat(bookingArrest.getArrestAgencyId(), is(29));

    bookingCharges = analyticalDatastoreDAO.getBookingCharges(booking.getBookingId());
    assertThat(bookingCharges.size(), is(2));

    BookingCharge bookingCharge = bookingCharges.get(0);
    assertThat(bookingCharge.getChargeCode(), is("Charge Code ID"));
    assertThat(bookingCharge.getBookingArrestId(), is(not(1)));
    assertTrue(bookingCharge.getBondAmount().doubleValue() == 500.00);
    assertThat(bookingCharge.getBondType().getValue(), is("CASH/SURETY/PROPERTY"));
    assertThat(bookingCharge.getAgencyId(), is(21));
    assertThat(bookingCharge.getChargeClassTypeId(), is(1));
    assertThat(bookingCharge.getBondStatusTypeId(), is(17));
    assertThat(bookingCharge.getChargeJurisdictionTypeId(), is(3));
    assertThat(bookingCharge.getChargeDisposition(), is("Disposition"));

    CustodyRelease custodyRelease = analyticalDatastoreDAO.getCustodyReleaseByBookingId(booking.getBookingId());
    log.info(custodyRelease.toString());
    assertEquals(LocalDate.parse("2014-12-17"), custodyRelease.getReleaseDate());
    assertEquals(LocalTime.parse("10:30"), custodyRelease.getReleaseTime());
    assertThat(custodyRelease.getBookingNumber(), is("Booking Number"));

    analyticalDatastoreDAO.deleteBooking(booking.getBookingId());

    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from Booking", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from BookingArrest", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from BookingCharge", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from Location", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from Person", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from BehavioralHealthAssessment", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from Treatment", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from BehavioralHealthEvaluation", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from BehavioralHealthAssessmentCategory",
            Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from PrescribedMedication", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from CustodyRelease", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from CustodyStatusChange", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from CustodyStatusChangeArrest", Boolean.class));
    assertTrue(jdbcTemplate.queryForObject("select count(*)=0 from CustodyStatusChangeCharge", Boolean.class));
}

From source file:org.silverpeas.core.calendar.icalendar.ICal4JExchangeImportTest.java

private static LocalDate date(String date) {
    return LocalDate.parse(date);
}

From source file:org.silverpeas.core.calendar.CalendarEventOccurrence.java

private static Temporal getDate(String temporal) {
    if (temporal.contains("T")) {
        return OffsetDateTime.parse(temporal);
    } else {//from w  w w  .j av a  2s. co  m
        return LocalDate.parse(temporal);
    }
}

From source file:org.ojbc.adapters.analyticsstaging.custody.CamelContextAdamsTest.java

public void testCustodyReleaseReportServiceRoute() throws Exception {
    CustodyRelease custodyRelease = analyticalDatastoreDAO.getCustodyReleaseByBookingId(1);
    assertEquals(LocalDate.parse("2014-12-17"), custodyRelease.getReleaseDate());
    assertEquals(LocalTime.parse("10:30"), custodyRelease.getReleaseTime());

    Exchange senderExchange = createSenderExchange(
            "src/test/resources/xmlInstances/custodyReleaseReport/CustodyReleaseReport-Adams.xml");

    //Send the one-way exchange.  Using template.send will send an one way message
    Exchange returnExchange = template.send("direct:custodyReleaseServiceEndpoint", senderExchange);

    //Use getException to see if we received an exception
    if (returnExchange.getException() != null) {
        throw new Exception(returnExchange.getException());
    }//from w w w .  j a  v  a 2 s  . c o m

    custodyRelease = analyticalDatastoreDAO.getCustodyReleaseByBookingId(1);
    assertEquals(LocalDate.parse("2001-12-17"), custodyRelease.getReleaseDate());
    assertEquals(LocalTime.parse("09:30:47"), custodyRelease.getReleaseTime());
    assertThat(custodyRelease.getBookingNumber(), is("Booking Number"));

    List<BehavioralHealthAssessment> behavioralHealthAssessments = analyticalDatastoreDAO
            .getBehavioralHealthAssessments(2);
    assertThat(behavioralHealthAssessments.size(), is(2));

    BehavioralHealthAssessment behavioralHealthAssessment = behavioralHealthAssessments.get(1);

    assertTrue(behavioralHealthAssessment.getBehavioralHealthDiagnoses().size() == 1);
    assertThat(behavioralHealthAssessment.getBehavioralHealthDiagnoses().get(0), is("Schizophrenia 295.10"));
    assertThat(behavioralHealthAssessment.getPersonId(), is(2));
    assertThat(behavioralHealthAssessment.getBehavioralHealthAssessmentId(), is(3));
    assertThat(behavioralHealthAssessment.getSeriousMentalIllness(), is(true));
    assertThat(behavioralHealthAssessment.getCareEpisodeStartDate(), is(LocalDate.parse("2016-01-01")));
    assertThat(behavioralHealthAssessment.getCareEpisodeEndDate(), is(LocalDate.parse("2016-04-01")));
    assertThat(behavioralHealthAssessment.getEnrolledProviderName(), is("79"));
    assertThat(behavioralHealthAssessment.getMedicaidStatusTypeId(), nullValue());

    List<Treatment> treatments = analyticalDatastoreDAO.getTreatments(3);
    assertThat(treatments.size(), is(1));

    Treatment treatment = treatments.get(0);
    assertThat(treatment.getBehavioralHealthAssessmentID(), is(3));
    assertThat(treatment.getTreatmentStartDate(), is(LocalDate.parse("2016-01-01")));
    assertThat(treatment.getTreatmentAdmissionReasonTypeId(), nullValue());
    assertThat(treatment.getTreatmentStatusTypeId(), nullValue());
    assertThat(treatment.getTreatmentProviderName(), is("Treatment Providing Organization Name"));

    List<PrescribedMedication> prescribedMedications = analyticalDatastoreDAO.getPrescribedMedication(3);
    assertThat(prescribedMedications.size(), is(1));

    PrescribedMedication prescribedMedication = prescribedMedications.get(0);
    assertThat(prescribedMedication.getBehavioralHealthAssessmentID(), is(3));
    assertThat(prescribedMedication.getMedicationDescription(), is("Zyprexa"));
    assertThat(prescribedMedication.getMedicationDispensingDate(), is(LocalDate.parse("2016-01-01")));
    assertThat(prescribedMedication.getMedicationDoseMeasure(), is("3mg"));

}

From source file:org.ojbc.adapters.analyticsstaging.custody.CamelContextAdamsWrongOrderTest.java

public void testCustodyReleaseReportServiceRoute() throws Exception {
    CustodyRelease custodyRelease = analyticalDatastoreDAO.getCustodyReleaseByBookingNumber("Booking Number");
    assertThat(custodyRelease, nullValue());

    Exchange senderExchange = createSenderExchange(
            "src/test/resources/xmlInstances/custodyReleaseReport/CustodyReleaseReport-Adams.xml");

    //Send the one-way exchange.  Using template.send will send an one way message
    Exchange returnExchange = template.send("direct:custodyReleaseServiceEndpoint", senderExchange);

    //Use getException to see if we received an exception
    if (returnExchange.getException() != null) {
        throw new Exception(returnExchange.getException());
    }//from   w w w . ja va2  s  . c  o m

    custodyRelease = analyticalDatastoreDAO.getCustodyReleaseByBookingNumber("Booking Number");
    assertEquals(LocalDate.parse("2001-12-17"), custodyRelease.getReleaseDate());
    assertEquals(LocalTime.parse("09:30:47"), custodyRelease.getReleaseTime());
    assertThat(custodyRelease.getBookingId(), nullValue());

    assertThat(jdbcTemplate.queryForObject("select count(*) from BehavioralHealthAssessment", Integer.class),
            is(0));
}