-
Notifications
You must be signed in to change notification settings - Fork 986
Configure jsonSchema2Pojo to not initialize collections #8356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,56 +18,65 @@ | |
| import io.opentelemetry.sdk.metrics.View; | ||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
| import org.junit.jupiter.api.Test; | ||
| import java.util.stream.Stream; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.Arguments; | ||
| import org.junit.jupiter.params.provider.MethodSource; | ||
|
|
||
| class ViewFactoryTest { | ||
|
|
||
| @Test | ||
| void create_Defaults() { | ||
| View expectedView = View.builder().build(); | ||
|
|
||
| View view = | ||
| ViewFactory.getInstance() | ||
| .create( | ||
| new ViewStreamModel().withAttributeKeys(null), | ||
| mock(DeclarativeConfigContext.class)); | ||
|
|
||
| @ParameterizedTest | ||
| @MethodSource("createArguments") | ||
| void create(ViewStreamModel model, View expectedView) { | ||
| View view = ViewFactory.getInstance().create(model, mock(DeclarativeConfigContext.class)); | ||
| assertThat(view.toString()).isEqualTo(expectedView.toString()); | ||
| } | ||
|
|
||
| @Test | ||
| void create() { | ||
| View expectedView = | ||
| View.builder() | ||
| .setName("name") | ||
| .setDescription("description") | ||
| .setAttributeFilter( | ||
| IncludeExcludePredicate.createPatternMatching( | ||
| Arrays.asList("foo", "bar"), Collections.singletonList("baz"))) | ||
| .setAggregation( | ||
| Aggregation.explicitBucketHistogram( | ||
| ExplicitBucketHistogramOptions.builder() | ||
| .setBucketBoundaries(Arrays.asList(1.0, 2.0)) | ||
| .build())) | ||
| .build(); | ||
|
|
||
| View view = | ||
| ViewFactory.getInstance() | ||
| .create( | ||
| new ViewStreamModel() | ||
| .withName("name") | ||
| .withDescription("description") | ||
| .withAttributeKeys( | ||
| new IncludeExcludeModel() | ||
| .withIncluded(Arrays.asList("foo", "bar")) | ||
| .withExcluded(Collections.singletonList("baz"))) | ||
| .withAggregation( | ||
| new AggregationModel() | ||
| .withExplicitBucketHistogram( | ||
| new ExplicitBucketHistogramAggregationModel() | ||
| .withBoundaries(Arrays.asList(1.0, 2.0)))), | ||
| mock(DeclarativeConfigContext.class)); | ||
|
|
||
| assertThat(view.toString()).isEqualTo(expectedView.toString()); | ||
| private static Stream<Arguments> createArguments() { | ||
| return Stream.of( | ||
| // defaults | ||
| Arguments.of(new ViewStreamModel().withAttributeKeys(null), View.builder().build()), | ||
| // attribute_keys with only included (no excluded) - reproduces | ||
| // https://github.com/open-telemetry/opentelemetry-java/issues/8337 | ||
| Arguments.of( | ||
| new ViewStreamModel() | ||
| .withAttributeKeys( | ||
| new IncludeExcludeModel() | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@breedx-splk Here's the null case test. Previously, omitting |
||
| .withIncluded( | ||
| Arrays.asList( | ||
| "url.full", "http.request.method", "http.response.status_code"))), | ||
| View.builder() | ||
| .setAttributeFilter( | ||
| IncludeExcludePredicate.createPatternMatching( | ||
| Arrays.asList( | ||
| "url.full", "http.request.method", "http.response.status_code"), | ||
| null)) | ||
| .build()), | ||
| // full configuration | ||
| Arguments.of( | ||
| new ViewStreamModel() | ||
| .withName("name") | ||
| .withDescription("description") | ||
| .withAttributeKeys( | ||
| new IncludeExcludeModel() | ||
| .withIncluded(Arrays.asList("foo", "bar")) | ||
| .withExcluded(Collections.singletonList("baz"))) | ||
| .withAggregation( | ||
| new AggregationModel() | ||
| .withExplicitBucketHistogram( | ||
| new ExplicitBucketHistogramAggregationModel() | ||
| .withBoundaries(Arrays.asList(1.0, 2.0)))), | ||
| View.builder() | ||
| .setName("name") | ||
| .setDescription("description") | ||
| .setAttributeFilter( | ||
| IncludeExcludePredicate.createPatternMatching( | ||
| Arrays.asList("foo", "bar"), Collections.singletonList("baz"))) | ||
| .setAggregation( | ||
| Aggregation.explicitBucketHistogram( | ||
| ExplicitBucketHistogramOptions.builder() | ||
| .setBucketBoundaries(Arrays.asList(1.0, 2.0)) | ||
| .build())) | ||
| .build())); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new test case fails without the change to build.gradle.kts.
Refactored these tests to follow the parameterized test pattern used elsewhere in these declarative config factory tests.