Search in sources :

Example 1 with Store

use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project siddhi by wso2.

the class DefineTableTestCase method testQuery18.

@Test
public void testQuery18() {
    log.info("testTableDefinition18 - Table w/ ref and additional properties");
    Map<String, String> systemConfigs = new HashMap<>();
    systemConfigs.put("test1.type", "test");
    systemConfigs.put("test1.uri", "http://localhost");
    InMemoryConfigManager inMemoryConfigManager = new InMemoryConfigManager(null, systemConfigs);
    inMemoryConfigManager.extractSystemConfigs("test1");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setConfigManager(inMemoryConfigManager);
    siddhiManager.setExtension("store:test", TestStore.class);
    String siddhiApp = "" + "@store(ref='test1', uri='http://localhost:8080', table.name ='Foo')" + "define table testTable (symbol string, price int, volume float); ";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
    siddhiAppRuntime.shutdown();
    Map<String, String> expectedSystemConfigs = new HashMap<>();
    expectedSystemConfigs.put("type", "test");
    expectedSystemConfigs.put("uri", "http://localhost:8080");
    expectedSystemConfigs.put("table.name", "Foo");
    AssertJUnit.assertEquals("Test store initialization failure", expectedSystemConfigs, TestStore.systemConfigs);
}
Also used : InMemoryConfigManager(org.wso2.siddhi.core.util.config.InMemoryConfigManager) HashMap(java.util.HashMap) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 2 with Store

use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project siddhi by wso2.

the class DefineTableTestCase method testQuery21.

@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testQuery21() {
    log.info("testTableDefinition21 - Table w/ ref to an undefined store type");
    Map<String, String> systemConfigs = new HashMap<>();
    systemConfigs.put("test1.type", "testdb");
    systemConfigs.put("test1.uri", "http://localhost");
    InMemoryConfigManager inMemoryConfigManager = new InMemoryConfigManager(null, systemConfigs);
    inMemoryConfigManager.extractSystemConfigs("test2");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setConfigManager(inMemoryConfigManager);
    siddhiManager.setExtension("store:test", TestStore.class);
    String siddhiApp = "" + "@store(ref='test2', uri='http://localhost:8080', table.name ='Foo')" + "define table testTable (symbol string, price int, volume float); ";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
    siddhiAppRuntime.shutdown();
}
Also used : InMemoryConfigManager(org.wso2.siddhi.core.util.config.InMemoryConfigManager) HashMap(java.util.HashMap) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 3 with Store

use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project siddhi by wso2.

the class DefineTableTestCase method testQuery16.

@Test
public void testQuery16() {
    log.info("testTableDefinition16 - Table w/ ref");
    Map<String, String> systemConfigs = new HashMap<>();
    systemConfigs.put("test1.type", "test");
    systemConfigs.put("test1.uri", "http://localhost");
    InMemoryConfigManager inMemoryConfigManager = new InMemoryConfigManager(null, systemConfigs);
    inMemoryConfigManager.extractSystemConfigs("test1");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setConfigManager(inMemoryConfigManager);
    siddhiManager.setExtension("store:test", TestStore.class);
    String siddhiApp = "" + "@store(ref='test1')" + "define table testTable (symbol string, price int, volume float); ";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
    siddhiAppRuntime.shutdown();
    Map<String, String> expectedSystemConfigs = new HashMap<>();
    expectedSystemConfigs.put("type", "test");
    expectedSystemConfigs.put("uri", "http://localhost");
    AssertJUnit.assertEquals("Test store initialization failure", expectedSystemConfigs, TestStore.systemConfigs);
}
Also used : InMemoryConfigManager(org.wso2.siddhi.core.util.config.InMemoryConfigManager) HashMap(java.util.HashMap) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 4 with Store

use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitStore_input.

@Override
public Object visitStore_input(SiddhiQLParser.Store_inputContext ctx) {
    String sourceId = (String) visit(ctx.source_id());
    String alias = null;
    if (ctx.alias() != null) {
        alias = (String) visit(ctx.source_id());
    }
    Store store = InputStore.store(alias, sourceId);
    Expression expression = null;
    if (ctx.expression() != null) {
        expression = (Expression) visit(ctx.expression());
    }
    populateQueryContext(store, ctx);
    if (ctx.per() != null) {
        return store.on(expression, (Within) visit(ctx.within_time_range()), (Expression) visit(ctx.per()));
    } else if (expression != null) {
        return store.on(expression);
    } else {
        return store;
    }
}
Also used : Expression(org.wso2.siddhi.query.api.expression.Expression) Store(org.wso2.siddhi.query.api.execution.query.input.store.Store) InputStore(org.wso2.siddhi.query.api.execution.query.input.store.InputStore)

Example 5 with Store

use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project product-apim by wso2.

the class APIMgtBaseIntegrationIT method init.

@BeforeClass
public void init() throws AMIntegrationTestException {
    TokenInfo tokenInfo = TestUtil.getToken("admin", "admin");
    apiPublisherClient = new ApiClient(TestUtil.OAUTH2_SECURITY).setBasePath("https://" + TestUtil.getIpAddressOfContainer() + ":9443/api/am/publisher/v1.0");
    apiPublisherClient.setAccessToken(tokenInfo.getToken(), tokenInfo.getExpiryTime());
    apiStoreClient = new org.wso2.carbon.apimgt.rest.integration.tests.store.ApiClient(TestUtil.OAUTH2_SECURITY).setBasePath("https://" + TestUtil.getIpAddressOfContainer() + ":9443/api/am/store/v1.0");
    apiStoreClient.setAccessToken(tokenInfo.getToken(), tokenInfo.getExpiryTime());
    apiAdminClient = new org.wso2.carbon.apimgt.rest.integration.tests.admin.ApiClient(TestUtil.OAUTH2_SECURITY).setBasePath("https://" + TestUtil.getIpAddressOfContainer() + ":9443/api/am/admin/v1.0");
    apiAdminClient.setAccessToken(tokenInfo.getToken(), tokenInfo.getExpiryTime());
}
Also used : TokenInfo(org.wso2.carbon.apimgt.rest.integration.tests.util.TokenInfo) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

HashMap (java.util.HashMap)25 Test (org.testng.annotations.Test)21 ArrayList (java.util.ArrayList)18 CharonException (org.wso2.charon3.core.exceptions.CharonException)18 SCIMResponse (org.wso2.charon3.core.protocol.SCIMResponse)18 UserManager (org.wso2.charon3.core.extensions.UserManager)15 Produces (javax.ws.rs.Produces)14 ApiOperation (io.swagger.annotations.ApiOperation)12 ApiResponses (io.swagger.annotations.ApiResponses)12 Path (javax.ws.rs.Path)10 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)10 Map (java.util.Map)9 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)8 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)8 UserStoreException (org.wso2.carbon.user.api.UserStoreException)8 Consumes (javax.ws.rs.Consumes)7 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)7 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)7 Response (feign.Response)6 IOException (java.io.IOException)6