Repository: open-telemetry/opentelemetry-java
File: sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/OpenTelemetryConfigurationFactoryTest.java (Java)

Code before:
  @ParameterizedTest
  @MethodSource("fileFormatArgs")
  void create_FileFormat(String fileFormat, boolean isValid) {
    OpenTelemetryConfigurationModel model =
        new OpenTelemetryConfigurationModel().withFileFormat(fileFormat);

    if (isValid) {
      assertThatCode(() -> OpenTelemetryConfigurationFactory.getInstance().create(model, context))
          .doesNotThrowAnyException();
    } else {
      assertThatThrownBy(
              () -> OpenTelemetryConfigurationFactory.getInstance().create(model, context))
          .isInstanceOf(DeclarativeConfigException.class)
          .hasMessage("Unsupported file format. Supported formats include 0.4, 1.0*");
    }
  }

  private static Stream<Arguments> fileFormatArgs() {
    return Stream.of(
        // Invalid file formats
        Arguments.of(null, false),
        Arguments.of("0.3", false),
        Arguments.of("a0.4", false),
        Arguments.of("0.4a", false),
        Arguments.of("foo", false),
        Arguments.of("1.0-rc.a", false),
        // Valid file formats
        Arguments.of("0.4", true),
        Arguments.of("1.0-rc.1", true),
        Arguments.of("1.0-rc.2", true),
        Arguments.of("1.0", true));
  }

  @Test
  void create_Defaults() {
    List<Closeable> closeables = new ArrayList<>();
    OpenTelemetrySdk expectedSdk = OpenTelemetrySdk.builder().build();
    cleanup.addCloseable(expectedSdk);

    OpenTelemetrySdk sdk =
        OpenTelemetryConfigurationFactory.getInstance()
            .create(new OpenTelemetryConfigurationModel().withFileFormat("1.0-rc.1"), context);
    cleanup.addCloseable(sdk);
    cleanup.addCloseables(closeables);

    assertThat(sdk.toString()).isEqualTo(expectedSdk.toString());
  }

  @Test
  void create_Disabled() {
    List<Closeable> closeables = new ArrayList<>();

Review comment (suggestion):
Just to make it very clear we're not doing semver....
```suggestion
        Arguments.of("1.0.0", false),
        Arguments.of("1.0.3", false),
        Arguments.of("1.0-rc.a", false),
```

Code after:
  @ParameterizedTest
  @MethodSource("fileFormatArgs")
  void create_FileFormat(String fileFormat, boolean isValid) {
    OpenTelemetryConfigurationModel model =
        new OpenTelemetryConfigurationModel().withFileFormat(fileFormat);

    if (isValid) {
      assertThatCode(() -> OpenTelemetryConfigurationFactory.getInstance().create(model, context))
          .doesNotThrowAnyException();
    } else {
      assertThatThrownBy(
              () -> OpenTelemetryConfigurationFactory.getInstance().create(model, context))
          .isInstanceOf(DeclarativeConfigException.class)
          .hasMessage("Unsupported file format. Supported formats include 0.4, 1.0*");
    }
  }

  private static Stream<Arguments> fileFormatArgs() {
    return Stream.of(
        // Invalid file formats
        Arguments.of(null, false),
        Arguments.of("0.3", false),
        Arguments.of("a0.4", false),
        Arguments.of("0.4a", false),
        Arguments.of("foo", false),
        Arguments.of("1.0-rc.a", false),
        Arguments.of("1.0.0", false),
        Arguments.of("1.0.3", false),
        // Valid file formats
        Arguments.of("0.4", true),
        Arguments.of("1.0-rc.1", true),
        Arguments.of("1.0-rc.2", true),
        Arguments.of("1.0", true));
  }

  @Test
  void create_Defaults() {
    List<Closeable> closeables = new ArrayList<>();
    OpenTelemetrySdk expectedSdk = OpenTelemetrySdk.builder().build();
    cleanup.addCloseable(expectedSdk);

    OpenTelemetrySdk sdk =
        OpenTelemetryConfigurationFactory.getInstance()
            .create(new OpenTelemetryConfigurationModel().withFileFormat("1.0-rc.1"), context);
    cleanup.addCloseable(sdk);
    cleanup.addCloseables(closeables);

    assertThat(sdk.toString()).isEqualTo(expectedSdk.toString());
  }

  @Test