mirror of https://github.com/apache/druid.git
validate non-empty String baseDataSource in MaterializedViewSupervisorSpec, added tests (#6075)
This commit is contained in:
parent
577632f5c1
commit
c3b7704b50
|
@ -26,6 +26,7 @@ import com.google.common.base.Preconditions;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.base.Strings;
|
||||
import io.druid.data.input.impl.DimensionSchema;
|
||||
import io.druid.data.input.impl.DimensionsSpec;
|
||||
import io.druid.indexer.HadoopIOConfig;
|
||||
|
@ -102,10 +103,9 @@ public class MaterializedViewSupervisorSpec implements SupervisorSpec
|
|||
@JacksonInject ChatHandlerProvider chatHandlerProvider
|
||||
)
|
||||
{
|
||||
this.baseDataSource = Preconditions.checkNotNull(
|
||||
baseDataSource,
|
||||
"baseDataSource cannot be null. Please provide a baseDataSource."
|
||||
);
|
||||
Preconditions.checkArgument(!Strings.isNullOrEmpty(baseDataSource), "baseDataSource cannot be null or empty. Please provide a baseDataSource.");
|
||||
this.baseDataSource = baseDataSource;
|
||||
|
||||
this.dimensionsSpec = Preconditions.checkNotNull(
|
||||
dimensionsSpec,
|
||||
"dimensionsSpec cannot be null. Please provide a dimensionsSpec"
|
||||
|
|
|
@ -44,11 +44,17 @@ import static org.easymock.EasyMock.createMock;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class MaterializedViewSupervisorSpecTest
|
||||
{
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
private ObjectMapper objectMapper = TestHelper.makeJsonMapper();
|
||||
|
||||
@Before
|
||||
|
@ -143,4 +149,92 @@ public class MaterializedViewSupervisorSpecTest
|
|||
Assert.assertEquals(expected.getDimensions(), spec.getDimensions());
|
||||
Assert.assertEquals(expected.getMetrics(), spec.getMetrics());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyBaseDataSource() throws Exception
|
||||
{
|
||||
expectedException.expect(CoreMatchers.instanceOf(IllegalArgumentException.class));
|
||||
expectedException.expectMessage(
|
||||
"baseDataSource cannot be null or empty. Please provide a baseDataSource."
|
||||
);
|
||||
MaterializedViewSupervisorSpec materializedViewSupervisorSpec = new MaterializedViewSupervisorSpec(
|
||||
"",
|
||||
new DimensionsSpec(
|
||||
Lists.newArrayList(
|
||||
new StringDimensionSchema("isUnpatrolled"),
|
||||
new StringDimensionSchema("metroCode"),
|
||||
new StringDimensionSchema("namespace"),
|
||||
new StringDimensionSchema("page"),
|
||||
new StringDimensionSchema("regionIsoCode"),
|
||||
new StringDimensionSchema("regionName"),
|
||||
new StringDimensionSchema("user")
|
||||
),
|
||||
null,
|
||||
null
|
||||
),
|
||||
new AggregatorFactory[]{
|
||||
new CountAggregatorFactory("count"),
|
||||
new LongSumAggregatorFactory("added", "added")
|
||||
},
|
||||
HadoopTuningConfig.makeDefaultTuningConfig(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
objectMapper,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
new MaterializedViewTaskConfig(),
|
||||
createMock(AuthorizerMapper.class),
|
||||
new NoopChatHandlerProvider()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullBaseDataSource() throws Exception
|
||||
{
|
||||
expectedException.expect(CoreMatchers.instanceOf(IllegalArgumentException.class));
|
||||
expectedException.expectMessage(
|
||||
"baseDataSource cannot be null or empty. Please provide a baseDataSource."
|
||||
);
|
||||
MaterializedViewSupervisorSpec materializedViewSupervisorSpec = new MaterializedViewSupervisorSpec(
|
||||
null,
|
||||
new DimensionsSpec(
|
||||
Lists.newArrayList(
|
||||
new StringDimensionSchema("isUnpatrolled"),
|
||||
new StringDimensionSchema("metroCode"),
|
||||
new StringDimensionSchema("namespace"),
|
||||
new StringDimensionSchema("page"),
|
||||
new StringDimensionSchema("regionIsoCode"),
|
||||
new StringDimensionSchema("regionName"),
|
||||
new StringDimensionSchema("user")
|
||||
),
|
||||
null,
|
||||
null
|
||||
),
|
||||
new AggregatorFactory[]{
|
||||
new CountAggregatorFactory("count"),
|
||||
new LongSumAggregatorFactory("added", "added")
|
||||
},
|
||||
HadoopTuningConfig.makeDefaultTuningConfig(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
objectMapper,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
new MaterializedViewTaskConfig(),
|
||||
createMock(AuthorizerMapper.class),
|
||||
new NoopChatHandlerProvider()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue