Search in sources :

Example 71 with BulletConfig

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

the class PubSubTest method testConstructorRuntimeExceptionThrowsPubSubException.

@Test(expectedExceptions = PubSubException.class)
public void testConstructorRuntimeExceptionThrowsPubSubException() throws PubSubException {
    BulletConfig config = new BulletConfig("src/test/resources/test_config.yaml");
    config.set(MockPubSub.MOCK_MESSAGE_NAME, "");
    config.set(BulletConfig.PUBSUB_CONTEXT_NAME, "");
    PubSub.from(config);
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 72 with BulletConfig

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

the class PubSubTest method testMockPubSubCreation.

@Test
public void testMockPubSubCreation() throws PubSubException {
    BulletConfig config = new BulletConfig("src/test/resources/test_config.yaml");
    String mockMessage = UUID.randomUUID().toString();
    config.set(MockPubSub.MOCK_MESSAGE_NAME, mockMessage);
    PubSub testPubSub = PubSub.from(config);
    Assert.assertEquals(testPubSub.getClass(), MockPubSub.class);
    Assert.assertEquals(testPubSub.getSubscriber().receive().getContent(), mockMessage);
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 73 with BulletConfig

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

the class PubSubTest method testSwitchingContext.

@Test
public void testSwitchingContext() throws PubSubException {
    BulletConfig config = new BulletConfig("src/test/resources/test_config.yaml");
    config.set(MockPubSub.MOCK_MESSAGE_NAME, "");
    PubSub pubSub = PubSub.from(config);
    Assert.assertEquals(pubSub.getClass(), MockPubSub.class);
    Assert.assertEquals(pubSub.getContext(), PubSub.Context.QUERY_SUBMISSION);
    Assert.assertTrue(pubSub.getSubscriber().receive().getContent().isEmpty());
    // No switch
    pubSub.switchContext(PubSub.Context.QUERY_PROCESSING, new BulletConfig());
    Assert.assertEquals(pubSub.getContext(), PubSub.Context.QUERY_PROCESSING);
    Assert.assertTrue(pubSub.getSubscriber().receive().getContent().isEmpty());
    // Switch
    BulletConfig newConfig = new BulletConfig("src/test/resources/test_config.yaml");
    newConfig.set(MockPubSub.MOCK_MESSAGE_NAME, "foo");
    pubSub.switchContext(PubSub.Context.QUERY_SUBMISSION, newConfig);
    Assert.assertEquals(pubSub.getContext(), PubSub.Context.QUERY_SUBMISSION);
    Assert.assertEquals(pubSub.getSubscriber().receive().getContent(), "foo");
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 74 with BulletConfig

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

the class RESTPubSubTest method testGetPublishers.

@Test
public void testGetPublishers() throws PubSubException {
    BulletConfig config = new BulletConfig("src/test/resources/test_config.yaml");
    config.set(BulletConfig.PUBSUB_CONTEXT_NAME, "QUERY_SUBMISSION");
    RESTPubSub pubSub = new RESTPubSub(config);
    List<Publisher> publishers = pubSub.getPublishers(8);
    Assert.assertNotNull(publishers);
    Assert.assertTrue(publishers.get(0) instanceof RESTQueryPublisher);
    Assert.assertTrue(publishers.get(7) instanceof RESTQueryPublisher);
    config.set(BulletConfig.PUBSUB_CONTEXT_NAME, "QUERY_PROCESSING");
    pubSub = new RESTPubSub(config);
    publishers = pubSub.getPublishers(8);
    Assert.assertNotNull(publishers);
    Assert.assertTrue(publishers.get(0) instanceof RESTResultPublisher);
    Assert.assertTrue(publishers.get(7) instanceof RESTResultPublisher);
}
Also used : Publisher(com.yahoo.bullet.pubsub.Publisher) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 75 with BulletConfig

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

the class RESTPubSubTest method testGetSubscriber.

@Test
public void testGetSubscriber() throws PubSubException {
    BulletConfig config = new BulletConfig("src/test/resources/test_config.yaml");
    config.set(BulletConfig.PUBSUB_CONTEXT_NAME, "QUERY_SUBMISSION");
    RESTPubSub pubSub = new RESTPubSub(config);
    Subscriber subscriber = pubSub.getSubscriber();
    Assert.assertNotNull(subscriber);
    Assert.assertTrue(subscriber instanceof RESTSubscriber);
    config.set(BulletConfig.PUBSUB_CONTEXT_NAME, "QUERY_PROCESSING");
    pubSub = new RESTPubSub(config);
    subscriber = pubSub.getSubscriber();
    Assert.assertNotNull(subscriber);
    Assert.assertTrue(subscriber instanceof RESTSubscriber);
}
Also used : Subscriber(com.yahoo.bullet.pubsub.Subscriber) 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