001package org.xbib.elasticsearch.river.jdbc.strategy.simple;
002
003import org.elasticsearch.action.search.SearchResponse;
004import org.elasticsearch.index.query.QueryBuilders;
005import org.testng.annotations.Parameters;
006import org.testng.annotations.Test;
007import org.xbib.elasticsearch.river.jdbc.RiverSource;
008
009public class SimpleRiverStoredProcedureTests extends AbstractSimpleRiverTest {
010
011    @Override
012    public RiverSource newRiverSource() {
013        return new SimpleRiverSource();
014    }
015
016    @Override
017    public SimpleRiverContext newRiverContext() {
018        return new SimpleRiverContext();
019    }
020
021    @Test
022    @Parameters({"river8"})
023    public void testSimpleStoredProcedure(String riverResource)
024            throws Exception {
025        createRiver(riverResource);
026        waitForInactiveRiver();
027        assertHits("1", 5);
028        logger.info("got the five hits");
029    }
030
031    @Test
032    @Parameters({"river9"})
033    public void testRegisterStoredProcedure(String riverResource) throws Exception {
034        createRiver(riverResource);
035        waitForInactiveRiver();
036        assertHits("1", 1);
037        logger.info("got the hit");
038        SearchResponse response = client("1").prepareSearch("my_jdbc_river_index")
039                .setQuery(QueryBuilders.matchAllQuery()).execute().actionGet();
040        String resp = response.getHits().getHits()[0].getSource().toString();
041        logger.info("resp={}", resp);
042        assertEquals("{mySupplierName=Acme, Inc.}", resp);
043    }
044
045}