public static double[] toDoubleArray(String name, Object value) {
    try {
      if (value instanceof BigDecimal[]) {
        return Arrays.stream((BigDecimal[]) value).mapToDouble(BigDecimal::doubleValue).toArray();
      } else if (value instanceof double[]) {
        return (double[]) value;
      } else if (value instanceof List) {
        return ((List<?>) value)
            .stream().mapToDouble(d -> new BigDecimal(String.valueOf(d)).doubleValue()).toArray();
      } else {
        throw new MaestroInternalError(
            "Param [%s] has an invalid evaluated result [%s]", name, toTruncateString(value));
      }
    } catch (NumberFormatException nfe) {
      throw new MaestroInternalError(
          nfe,
          "Invalid number format for evaluated result: %s for param [%s]",
          toTruncateString(value),
          name);
    }
  }
@Test
  public void testInvalidToDoubleArray() {
    AssertHelper.assertThrows(
        "Invalid number format",
        MaestroInternalError.class,
        "Invalid number format for evaluated result: [true, 5.6]",
        () -> ParamHelper.toDoubleArray("foo", Arrays.asList(true, 5.6)));

    AssertHelper.assertThrows(
        "Invalid number format",
        MaestroInternalError.class,
        "Invalid number format for evaluated result: [3.4abc, 5.6]",
        () -> ParamHelper.toDoubleArray("foo", Arrays.asList("3.4abc", 5.6)));

    AssertHelper.assertThrows(
        "Invalid number format",
        MaestroInternalError.class,
        "Invalid number format for evaluated result: [null, 5.6]",
        () -> ParamHelper.toDoubleArray("foo", Arrays.asList(null, 5.6)));

    AssertHelper.assertThrows(
        "Invalid number format",
        MaestroInternalError.class,
        "Param [foo] has an invalid evaluated result [null]",
        () -> ParamHelper.toDoubleArray("foo", null));
  }