Search in sources :

Example 1 with MockJDBCSource

use of org.xbib.elasticsearch.jdbc.strategy.mock.MockJDBCSource in project elasticsearch-jdbc by jprante.

the class ColumnStrategyContextTests method testReadLastRunTime.

@Test
@Parameters({ "existedWhereClause" })
@SuppressWarnings("unchecked")
public void testReadLastRunTime(String resource) throws Exception {
    Settings settings = createSettings(resource);
    final DateTime lastRunAt = new DateTime(new DateTime().getMillis() - 600);
    context = newContext();
    MockJDBCSource source = new MockJDBCSource() {

        @Override
        public void fetch() {
            DateTime readlastRunAt = context.getLastRunTimestamp();
            assertNotNull(readlastRunAt);
            assertEquals(readlastRunAt, lastRunAt);
        }
    };
    MockSink mockSink = new MockSink();
    context.setSettings(settings).setSink(mockSink).setSource(source);
    //mockSink.setIngestFactory(createIngestFactory(settings));
    context.setLastRunTimeStamp(lastRunAt);
    context.execute();
}
Also used : MockSink(org.xbib.elasticsearch.jdbc.strategy.mock.MockSink) MockJDBCSource(org.xbib.elasticsearch.jdbc.strategy.mock.MockJDBCSource) Settings(org.elasticsearch.common.settings.Settings) DateTime(org.joda.time.DateTime) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 2 with MockJDBCSource

use of org.xbib.elasticsearch.jdbc.strategy.mock.MockJDBCSource in project elasticsearch-jdbc by jprante.

the class ColumnStrategyContextTests method testWriteLastRunTime.

@Test
@Parameters({ "existedWhereClause" })
@SuppressWarnings("unchecked")
public void testWriteLastRunTime(String resource) throws Exception {
    Settings settings = createSettings(resource);
    context = newContext();
    MockJDBCSource source = new MockJDBCSource() {

        @Override
        public void fetch() {
        }
    };
    MockSink mockSink = new MockSink();
    context.setSettings(settings).setSink(mockSink).setSource(source);
    //mockSink.setIngestFactory(createIngestFactory(settings));
    context.execute();
    assertNotNull(context.getLastRunTimestamp());
}
Also used : MockSink(org.xbib.elasticsearch.jdbc.strategy.mock.MockSink) MockJDBCSource(org.xbib.elasticsearch.jdbc.strategy.mock.MockJDBCSource) Settings(org.elasticsearch.common.settings.Settings) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Aggregations

Settings (org.elasticsearch.common.settings.Settings)2 Parameters (org.testng.annotations.Parameters)2 Test (org.testng.annotations.Test)2 MockJDBCSource (org.xbib.elasticsearch.jdbc.strategy.mock.MockJDBCSource)2 MockSink (org.xbib.elasticsearch.jdbc.strategy.mock.MockSink)2 DateTime (org.joda.time.DateTime)1