@Test public void testGetRequiredColumns() { JavaScriptDimFilter javaScriptDimFilter = new JavaScriptDimFilter("dim", FN1, null, new JavaScriptConfig(false)); Assert.assertEquals(javaScriptDimFilter.getRequiredColumns(), Sets.newHashSet("dim")); } }
@Test public void testJavaScriptDisabledFactorizeBuffered() { final JavaScriptAggregatorFactory factory = new JavaScriptAggregatorFactory( "foo", ImmutableList.of("foo"), scriptDoubleSum.get("fnAggregate"), scriptDoubleSum.get("fnReset"), scriptDoubleSum.get("fnCombine"), new JavaScriptConfig(false) ); expectedException.expect(IllegalStateException.class); expectedException.expectMessage("JavaScript is disabled"); factory.factorizeBuffered(DUMMY_COLUMN_SELECTOR_FACTORY); Assert.assertTrue(false); }
@Test public void testJavaScriptDisabledFactorize() { final JavaScriptAggregatorFactory factory = new JavaScriptAggregatorFactory( "foo", ImmutableList.of("foo"), scriptDoubleSum.get("fnAggregate"), scriptDoubleSum.get("fnReset"), scriptDoubleSum.get("fnCombine"), new JavaScriptConfig(false) ); expectedException.expect(IllegalStateException.class); expectedException.expectMessage("JavaScript is disabled"); factory.factorize(DUMMY_COLUMN_SELECTOR_FACTORY); Assert.assertTrue(false); }
@Test public void testComputeJavaScriptNotAllowed() { String absPercentFunction = "function(delta, total) { return 100 * Math.abs(delta) / total; }"; JavaScriptPostAggregator aggregator = new JavaScriptPostAggregator( "absPercent", Lists.newArrayList("delta", "total"), absPercentFunction, new JavaScriptConfig(false) ); expectedException.expect(IllegalStateException.class); expectedException.expectMessage("JavaScript is disabled"); aggregator.compute(new HashMap<>()); } }
@Test public void testToFilterNotAllowed() { JavaScriptDimFilter javaScriptDimFilter = new JavaScriptDimFilter("dim", FN1, null, new JavaScriptConfig(false)); expectedException.expect(IllegalStateException.class); expectedException.expectMessage("JavaScript is disabled"); javaScriptDimFilter.toFilter(); Assert.assertTrue(false); }
@Test public void testJavascriptNotAllowed() { String function = "function(str) { return str.substring(0,3); }"; ExtractionFn extractionFn = new JavaScriptExtractionFn(function, false, new JavaScriptConfig(false)); expectedException.expect(IllegalStateException.class); expectedException.expectMessage("JavaScript is disabled"); extractionFn.apply("hey"); Assert.assertTrue(false); }
@Test public void testDisabled() throws Exception { ObjectMapper mapper = new DefaultObjectMapper(); mapper.setInjectableValues( new InjectableValues.Std().addValue( JavaScriptConfig.class, new JavaScriptConfig(false) ) ); final String strategyString = mapper.writeValueAsString(STRATEGY); expectedException.expect(JsonMappingException.class); expectedException.expectCause(CoreMatchers.instanceOf(IllegalStateException.class)); expectedException.expectMessage("JavaScript is disabled"); mapper.readValue(strategyString, JavaScriptTieredBrokerSelectorStrategy.class); }
@Test public void testDisabled() throws Exception { ObjectMapper mapper = new DefaultObjectMapper(); mapper.setInjectableValues( new InjectableValues.Std().addValue( JavaScriptConfig.class, new JavaScriptConfig(false) ) ); final String strategyString = mapper.writeValueAsString(STRATEGY); expectedException.expect(JsonMappingException.class); expectedException.expectCause(CoreMatchers.instanceOf(IllegalStateException.class)); expectedException.expectMessage("JavaScript is disabled"); mapper.readValue(strategyString, WorkerSelectStrategy.class); }
@Test public void testMakeParserNotAllowed() { final JavaScriptConfig config = new JavaScriptConfig(false); JavaScriptParseSpec spec = new JavaScriptParseSpec( new TimestampSpec("abc", "iso", null), new DimensionsSpec(DimensionsSpec.getDefaultSchemas(Collections.singletonList("abc")), null, null), "abc", config ); expectedException.expect(IllegalStateException.class); expectedException.expectMessage("JavaScript is disabled"); spec.makeParser(); } }