Example usage for java.time OffsetDateTime parse

List of usage examples for java.time OffsetDateTime parse

Introduction

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

Prototype

public static OffsetDateTime parse(CharSequence text) 

Source Link

Document

Obtains an instance of OffsetDateTime from a text string such as 2007-12-03T10:15:30+01:00 .

Usage

From source file:org.openmhealth.shim.ihealth.mapper.IHealthBloodGlucoseDataPointMapperUnitTests.java

@Test
public void asDataPointsShouldReturnCorrectSensedDataPoints() {

    BloodGlucose.Builder expectedBloodGlucoseBuilder = new BloodGlucose.Builder(
            new TypedUnitValue<>(MILLIGRAMS_PER_DECILITER, 60))
                    .setEffectiveTimeFrame(OffsetDateTime.parse("2015-09-17T12:03:27-08:00"))
                    .setTemporalRelationshipToMeal(BEFORE_BREAKFAST).setUserNotes("Such glucose, much blood.");

    assertThat(dataPoints.get(0).getBody(), equalTo(expectedBloodGlucoseBuilder.build()));

    assertThat(dataPoints.get(0).getBody().getAdditionalProperty("temporal_relationship_to_medication").get(),
            equalTo("Before_taking_pills"));

    testDataPointHeader(dataPoints.get(0).getHeader(), SCHEMA_ID, SENSED, "f706b6152f684c0e9185b1fa6b7c5148",
            OffsetDateTime.parse("2015-09-17T20:03:41Z"));
}

From source file:org.openmhealth.shim.ihealth.mapper.IHealthStepCountDataPointMapperUnitTests.java

@Test
public void asDataPointsShouldReturnCorrectDataPointsWhenSensed() {

    StepCount expectedStepCount = new StepCount.Builder(21)
            .setEffectiveTimeFrame(TimeInterval.ofStartDateTimeAndDuration(
                    OffsetDateTime.parse("2015-11-16T00:00:00+05:00"), new DurationUnitValue(DAY, 1)))
            .build();/*w ww.j a  v a2 s.c o  m*/

    assertThat(dataPoints.get(0).getBody(), equalTo(expectedStepCount));

    testDataPointHeader(dataPoints.get(0).getHeader(), SCHEMA_ID, SENSED, "ac67c4ccf64af669d92569af85d19f59",
            OffsetDateTime.parse("2015-11-17T19:23:21Z"));
}

From source file:org.openmhealth.shim.ihealth.mapper.IHealthOxygenSaturationDataPointMapperUnitTests.java

@Test
public void asDataPointsShouldReturnCorrectSensedDataPoints() {

    OxygenSaturation expectedOxygenSaturation = new OxygenSaturation.Builder(new TypedUnitValue<>(PERCENT, 99))
            .setMeasurementMethod(PULSE_OXIMETRY).setMeasurementSystem(PERIPHERAL_CAPILLARY)
            .setEffectiveTimeFrame(OffsetDateTime.parse("2015-09-23T15:46:00-06:00")).build();

    assertThat(dataPoints.get(0).getBody(), equalTo(expectedOxygenSaturation));
    assertThat(dataPoints.get(0).getHeader().getAcquisitionProvenance().getModality(), equalTo(SENSED));
    assertThat(dataPoints.get(0).getHeader().getBodySchemaId(), equalTo(SCHEMA_ID));
    assertThat(dataPoints.get(0).getHeader().getAcquisitionProvenance().getSourceName(),
            equalTo(RESOURCE_API_SOURCE_NAME));
}

From source file:org.openmhealth.shim.withings.mapper.WithingsBodyWeightDataPointMapperUnitTests.java

public void testDataPoint(DataPoint<BodyWeight> testDataPoint, double massValue, String offsetTimeString,
        long externalId) {

    BodyWeight bodyWeightExpected = new BodyWeight.Builder(new MassUnitValue(KILOGRAM, massValue))
            .setEffectiveTimeFrame(OffsetDateTime.parse(offsetTimeString)).build();

    assertThat(testDataPoint.getBody(), equalTo(bodyWeightExpected));

    DataPointAcquisitionProvenance testProvenance = testDataPoint.getHeader().getAcquisitionProvenance();

    assertThat(testProvenance.getSourceName(), equalTo(RESOURCE_API_SOURCE_NAME));
    assertThat(testProvenance.getModality(), equalTo(SENSED));

    Long expectedExternalId = (Long) testDataPoint.getHeader().getAcquisitionProvenance()
            .getAdditionalProperties().get("external_id");

    assertThat(expectedExternalId, equalTo(externalId));
    assertThat(testDataPoint.getHeader().getBodySchemaId(), equalTo(SCHEMA_ID));
}

From source file:org.openmhealth.shim.withings.mapper.WithingsIntradayStepCountDataPointMapperUnitTests.java

public void testIntradayStepCountDataPoint(DataPoint<StepCount> stepCountDataPoint, long expectedStepCountValue,
        String expectedDateString, Long expectedDuration) {

    StepCount expectedStepCount = new StepCount.Builder(expectedStepCountValue)
            .setEffectiveTimeFrame(ofStartDateTimeAndDuration(OffsetDateTime.parse(expectedDateString),
                    new DurationUnitValue(SECOND, expectedDuration)))
            .build();/*  ww  w  .j a v a2s .  c  o m*/

    StepCount testStepCount = stepCountDataPoint.getBody();

    assertThat(testStepCount, equalTo(expectedStepCount));
    assertThat(stepCountDataPoint.getHeader().getAcquisitionProvenance().getModality(), equalTo(SENSED));
    assertThat(stepCountDataPoint.getHeader().getAcquisitionProvenance().getSourceName(),
            equalTo(RESOURCE_API_SOURCE_NAME));
    assertThat(stepCountDataPoint.getHeader().getBodySchemaId(), equalTo(SCHEMA_ID));

}

From source file:org.openmhealth.shim.ihealth.mapper.IHealthBodyWeightDataPointMapperUnitTests.java

@Test
public void asDataPointsShouldReturnCorrectSelfReportedDataPoints() {

    BodyWeight expectedBodyWeight = new BodyWeight.Builder(
            new MassUnitValue(MassUnit.KILOGRAM, 77.56438446044922))
                    .setEffectiveTimeFrame(OffsetDateTime.parse("2015-09-17T14:07:57-06:00"))
                    .setUserNotes("Weight so good, look at me now").build();

    assertThat(dataPoints.get(1).getBody(), equalTo(expectedBodyWeight));

    testDataPointHeader(dataPoints.get(1).getHeader(), SCHEMA_ID, SELF_REPORTED,
            "b702a3a5e998f2fca268df6daaa69871", OffsetDateTime.parse("2015-09-17T20:08:00Z"));

}

From source file:org.openmhealth.shim.withings.mapper.WithingsHeartRateDataPointMapperUnitTests.java

private void assertThatDataPointMatches(DataPoint<HeartRate> actualDataPoint, double expectedHeartRateValue,
        String expectedDateTimeAsString, long expectedExternalId, String expectedComment,
        DataPointModality expectedModality) {

    HeartRate.Builder expectedHeartRateBuilder = new HeartRate.Builder(expectedHeartRateValue)
            .setEffectiveTimeFrame(OffsetDateTime.parse(expectedDateTimeAsString));

    if (expectedComment != null) {
        expectedHeartRateBuilder.setUserNotes(expectedComment);
    }/*from w w  w.  j ava  2s . c o m*/

    HeartRate expectedHeartRate = expectedHeartRateBuilder.build();

    assertThat(actualDataPoint.getBody(), equalTo(expectedHeartRate));
    assertThat(actualDataPoint.getHeader().getBodySchemaId(), equalTo(SCHEMA_ID));

    DataPointAcquisitionProvenance actualProvenance = actualDataPoint.getHeader().getAcquisitionProvenance();

    assertThat(actualProvenance.getModality(), equalTo(expectedModality));
    assertThat(actualProvenance.getSourceName(), equalTo(RESOURCE_API_SOURCE_NAME));
    assertThat(actualProvenance.getAdditionalProperties().get("external_id"), equalTo(expectedExternalId));
}

From source file:org.openmhealth.shim.withings.mapper.WithingsDailyStepCountDataPointMapperUnitTests.java

public void testDailyStepCountDataPoint(DataPoint<StepCount> stepCountDataPoint, long expectedStepCountValue,
        String expectedDateString, String expectedEndDateString) {

    StepCount expectedStepCount = new StepCount.Builder(expectedStepCountValue)
            .setEffectiveTimeFrame(TimeInterval.ofStartDateTimeAndEndDateTime(
                    OffsetDateTime.parse(expectedDateString), OffsetDateTime.parse(expectedEndDateString)))
            .build();/*from w  ww .j ava 2s  .  co  m*/

    StepCount testStepCount = stepCountDataPoint.getBody();

    assertThat(testStepCount, equalTo(expectedStepCount));
    assertThat(stepCountDataPoint.getHeader().getAcquisitionProvenance().getModality(), equalTo(SENSED));
    assertThat(stepCountDataPoint.getHeader().getAcquisitionProvenance().getSourceName(),
            equalTo(RESOURCE_API_SOURCE_NAME));
    assertThat(stepCountDataPoint.getHeader().getBodySchemaId(), equalTo(SCHEMA_ID));

}

From source file:org.openmhealth.shim.ihealth.mapper.IHealthBloodPressureDataPointMapperUnitTests.java

@Test
public void asDataPointsShouldReturnCorrectSelfReportedDataPoints() {

    BloodPressure expectedBloodPressure = new BloodPressure.Builder(
            new SystolicBloodPressure(MM_OF_MERCURY, 130), new DiastolicBloodPressure(MM_OF_MERCURY, 95))
                    .setEffectiveTimeFrame(OffsetDateTime.parse("2015-09-17T14:07:45-06:00"))
                    .setUserNotes("BP on the up and up.").build();

    assertThat(dataPoints.get(1).getBody(), equalTo(expectedBloodPressure));

    DataPointHeader testHeader = dataPoints.get(1).getHeader();

    assertThat(testHeader.getAcquisitionProvenance().getModality(), equalTo(SELF_REPORTED));

}