Search in sources :

Example 46 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.

the class RESTPubSubTest method testSettings.

@Test
public void testSettings() throws PubSubException {
    BulletConfig config = new BulletConfig("src/test/resources/test_config.yaml");
    RESTPubSub pubSub = new RESTPubSub(config);
    // Test custom values from file
    RESTQueryPublisher publisher = (RESTQueryPublisher) pubSub.getPublisher();
    String queryURL = publisher.getQueryURL();
    Assert.assertEquals(queryURL, "http://localhost:9901/CUSTOM/query");
    // Test defaults
    RESTSubscriber resultSubscriber = (RESTSubscriber) pubSub.getSubscriber();
    List<String> urls = resultSubscriber.getUrls();
    Assert.assertEquals(urls.size(), 1);
    Assert.assertEquals(urls.get(0), "http://localhost:9901/api/bullet/pubsub/result");
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 47 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.

the class AggregationOperationsTest method testGroupByStrategy.

@Test
public void testGroupByStrategy() {
    Aggregation aggregation = new Aggregation();
    BulletConfig config = new BulletConfig();
    aggregation.setType(Aggregation.Type.GROUP);
    aggregation.setFields(singletonMap("field", "foo"));
    aggregation.setAttributes(singletonMap(GroupOperation.OPERATIONS, singletonList(singletonMap(GroupOperation.OPERATION_TYPE, GroupOperation.GroupOperationType.COUNT.getName()))));
    aggregation.configure(config);
    Assert.assertEquals(AggregationOperations.findStrategy(aggregation, config).getClass(), GroupBy.class);
}
Also used : Aggregation(com.yahoo.bullet.parsing.Aggregation) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 48 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.

the class AggregationOperationsTest method testCountDistinctStrategy.

@Test
public void testCountDistinctStrategy() {
    Aggregation aggregation = new Aggregation();
    BulletConfig config = new BulletConfig();
    aggregation.setType(Aggregation.Type.COUNT_DISTINCT);
    aggregation.setFields(singletonMap("field", "foo"));
    aggregation.configure(config);
    Assert.assertEquals(AggregationOperations.findStrategy(aggregation, config).getClass(), CountDistinct.class);
}
Also used : Aggregation(com.yahoo.bullet.parsing.Aggregation) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 49 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.

the class AggregationOperationsTest method testTopKStrategy.

@Test
public void testTopKStrategy() {
    Aggregation aggregation = new Aggregation();
    BulletConfig config = new BulletConfig();
    aggregation.setType(Aggregation.Type.TOP_K);
    aggregation.setFields(singletonMap("field", "foo"));
    aggregation.configure(config);
    Assert.assertEquals(AggregationOperations.findStrategy(aggregation, config).getClass(), TopK.class);
}
Also used : Aggregation(com.yahoo.bullet.parsing.Aggregation) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 50 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.

the class AggregationOperationsTest method testNullType.

@Test(expectedExceptions = NullPointerException.class)
public void testNullType() {
    Aggregation aggregation = new Aggregation();
    BulletConfig config = new BulletConfig();
    aggregation.setType(null);
    aggregation.configure(config);
    AggregationOperations.findStrategy(aggregation, config);
}
Also used : Aggregation(com.yahoo.bullet.parsing.Aggregation) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Aggregations

BulletConfig (com.yahoo.bullet.common.BulletConfig)101 Test (org.testng.annotations.Test)87 Aggregation (com.yahoo.bullet.parsing.Aggregation)37 List (java.util.List)25 Query (com.yahoo.bullet.parsing.Query)20 QueryUtils.makeAggregationQuery (com.yahoo.bullet.parsing.QueryUtils.makeAggregationQuery)17 BulletError (com.yahoo.bullet.common.BulletError)16 BulletRecord (com.yahoo.bullet.record.BulletRecord)16 Arrays.asList (java.util.Arrays.asList)16 Clip (com.yahoo.bullet.result.Clip)14 Collections.singletonList (java.util.Collections.singletonList)12 QueryUtils.makeProjectionFilterQuery (com.yahoo.bullet.parsing.QueryUtils.makeProjectionFilterQuery)11 QueryUtils.makeRawFullQuery (com.yahoo.bullet.parsing.QueryUtils.makeRawFullQuery)11 Map (java.util.Map)11 AggregationUtils.makeAttributes (com.yahoo.bullet.parsing.AggregationUtils.makeAttributes)10 Window (com.yahoo.bullet.parsing.Window)10 Concept (com.yahoo.bullet.result.Meta.Concept)10 RecordBox (com.yahoo.bullet.result.RecordBox)10 ArrayList (java.util.ArrayList)10 IntStream (java.util.stream.IntStream)10