github-code-scanning[bot] commented on code in PR #14004:
URL: https://github.com/apache/druid/pull/14004#discussion_r1229591223
##########
server/src/test/java/org/apache/druid/segment/indexing/DataSchemaTest.java:
##########
@@ -442,27 +446,21 @@
);
for (Map.Entry<String, String> entry :
invalidCharToDataSourceName.entrySet()) {
- testInvalidWhitespaceDatasourceHelper(entry.getValue(), entry.getKey());
- }
- }
-
- private void testInvalidWhitespaceDatasourceHelper(String dataSource, String
invalidChar)
- {
- String testFailMsg = "dataSource contain invalid whitespace character: " +
invalidChar;
- try {
- DataSchema schema = new DataSchema(
- dataSource,
- Collections.emptyMap(),
- null,
- null,
- null,
- jsonMapper
+ String dataSource = entry.getValue();
+ final String msg = StringUtils.format(
+ "Invalid value for field [dataSource]: Value [%s] contains illegal
whitespace characters. Only space is allowed.",
+ dataSource
+ );
+
DruidExceptionMatcher.invalidInput().expectMessageIs(msg).assertThrowsAndMatches(
+ () -> new DataSchema(
+ dataSource,
+ Collections.emptyMap(),
+ null,
+ null,
+ null,
+ jsonMapper
+ )
Review Comment:
## Deprecated method or constructor invocation
Invoking [DataSchema.DataSchema](1) should be avoided because it has been
deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/5085)
##########
server/src/test/java/org/apache/druid/segment/indexing/DataSchemaTest.java:
##########
@@ -413,22 +415,24 @@
), JacksonUtils.TYPE_REFERENCE_MAP_STRING_OBJECT
);
-
expectedException.expect(CoreMatchers.instanceOf(IllegalArgumentException.class));
- expectedException.expectMessage(
- "dataSource cannot be null or empty. Please provide a dataSource."
- );
-
- DataSchema schema = new DataSchema(
- "",
- parser,
- new AggregatorFactory[]{
- new DoubleSumAggregatorFactory("metric1", "col1"),
- new DoubleSumAggregatorFactory("metric2", "col2"),
- },
- new ArbitraryGranularitySpec(Granularities.DAY,
ImmutableList.of(Intervals.of("2014/2015"))),
- null,
- jsonMapper
- );
+ DruidExceptionMatcher
+ .invalidInput()
+ .expectMessageIs("Invalid value for field [dataSource]: must not be
null")
+ .assertThrowsAndMatches(
+ () -> new DataSchema(
+ "",
+ parser,
+ new AggregatorFactory[]{
+ new DoubleSumAggregatorFactory("metric1", "col1"),
+ new DoubleSumAggregatorFactory("metric2", "col2"),
+ },
+ new ArbitraryGranularitySpec(
+ Granularities.DAY,
+ ImmutableList.of(Intervals.of("2014/2015"))
+ ),
+ null,
+ jsonMapper
+ ));
Review Comment:
## Deprecated method or constructor invocation
Invoking [DataSchema.DataSchema](1) should be avoided because it has been
deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/5084)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]