public Optional<Measure> toMeasure(@Nullable ScannerReport.Measure batchMeasure, Metric metric) {
    Objects.requireNonNull(metric);
    if (batchMeasure == null) {
      return Optional.empty();
    }

    Measure.NewMeasureBuilder builder = Measure.newMeasureBuilder();
    switch (metric.getType().getValueType()) {
      case INT:
        return toIntegerMeasure(builder, batchMeasure);
      case LONG:
        return toLongMeasure(builder, batchMeasure);
      case DOUBLE:
        return toDoubleMeasure(builder, batchMeasure);
      case BOOLEAN:
        return toBooleanMeasure(builder, batchMeasure);
      case STRING:
        return toStringMeasure(builder, batchMeasure);
      case LEVEL:
        return toLevelMeasure(builder, batchMeasure);
      case NO_VALUE:
        return toNoValueMeasure(builder);
      default:
        throw new IllegalArgumentException("Unsupported Measure.ValueType " + metric.getType().getValueType());
    }
  }
@Test
  public void toMeasure_maps_data_and_alert_properties_in_dto_for_Long_Metric() {
    ScannerReport.Measure batchMeasure = ScannerReport.Measure.newBuilder()
      .setLongValue(LongValue.newBuilder().setValue(10L).setData(SOME_DATA))
      .build();

    Optional<Measure> measure = underTest.toMeasure(batchMeasure, SOME_LONG_METRIC);

    assertThat(measure).isPresent();
    assertThat(measure.get().getValueType()).isEqualTo(Measure.ValueType.LONG);
    assertThat(measure.get().getLongValue()).isEqualTo(10);
    assertThat(measure.get().getData()).isEqualTo(SOME_DATA);
  }