/**
   * Maps a JSON response node from the Fitbit API into a {@link StepCount} measure
   *
   * @param node a JSON node for an individual object in the "activities-steps" array retrieved from
   *     the activities/steps Fitbit API endpoint
   * @return a {@link DataPoint} object containing a {@link StepCount} measure with the appropriate
   *     values from the node parameter, wrapped as an {@link Optional}
   */
  @Override
  protected Optional<DataPoint<StepCount>> asDataPoint(JsonNode node) {

    int stepCountValue = Integer.parseInt(asRequiredString(node, "value"));

    if (stepCountValue == 0) {
      return Optional.empty();
    }

    StepCount.Builder builder = new StepCount.Builder(stepCountValue);

    Optional<LocalDate> stepDate = asOptionalLocalDate(node, "dateTime");

    if (stepDate.isPresent()) {
      LocalDateTime startDateTime = stepDate.get().atTime(0, 0, 0, 0);

      builder.setEffectiveTimeFrame(
          TimeInterval.ofStartDateTimeAndDuration(
              combineDateTimeAndTimezone(startDateTime),
              new DurationUnitValue(DurationUnit.DAY, 1)));
    }

    StepCount measure = builder.build();
    Optional<Long> externalId = asOptionalLong(node, "logId");
    return Optional.of(newDataPoint(measure, externalId.orElse(null)));
  }
  // TODO clean up
  @Override
  public void testGoogleFitMeasureFromDataPoint(
      BodyHeight testMeasure, Map<String, Object> properties) {

    BodyHeight.Builder bodyHeightBuilder =
        new BodyHeight.Builder(new LengthUnitValue(METER, (double) properties.get("fpValue")));
    if (properties.containsKey("endDateTimeString")) {
      bodyHeightBuilder.setEffectiveTimeFrame(
          TimeInterval.ofStartDateTimeAndEndDateTime(
              OffsetDateTime.parse((String) properties.get("startDateTimeString")),
              OffsetDateTime.parse((String) properties.get("endDateTimeString"))));
    } else {
      bodyHeightBuilder.setEffectiveTimeFrame(
          OffsetDateTime.parse((String) properties.get("startDateTimeString")));
    }
    BodyHeight expectedBodyHeight = bodyHeightBuilder.build();
    assertThat(testMeasure, equalTo(expectedBodyHeight));
  }