diff --git a/src/test/java/com/basho/riak/client/api/commands/itest/ITestTimeSeries.java b/src/test/java/com/basho/riak/client/api/commands/itest/ITestTimeSeries.java index 472365191..1bb0c82cc 100644 --- a/src/test/java/com/basho/riak/client/api/commands/itest/ITestTimeSeries.java +++ b/src/test/java/com/basho/riak/client/api/commands/itest/ITestTimeSeries.java @@ -11,16 +11,13 @@ import com.basho.riak.client.core.operations.itest.ts.ITestTsBase; import com.basho.riak.client.core.query.Namespace; import com.basho.riak.client.core.query.timeseries.*; -import org.junit.FixMethodOrder; -import org.junit.Rule; -import org.junit.Test; +import org.junit.*; import org.junit.rules.ExpectedException; import org.junit.runners.MethodSorters; import java.util.*; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; -import java.util.stream.Stream; import static org.junit.Assert.*; import static org.junit.Assume.assumeTrue; @@ -58,11 +55,17 @@ public class ITestTimeSeries extends ITestTsBase private RiakFuture createTableAsync(final RiakClient client, String tableName) throws InterruptedException { - final TableDefinition tableDef = new TableDefinition(tableName, GeoCheckinWideTableDefinition.getFullColumnDescriptions()); + final TableDefinition tableDef = new TableDefinition(tableName, GeoCheckin_1_5_TableDefinition.getFullColumnDescriptions()); return createTableAsync(client, tableDef); } + @BeforeClass + public static void SetupCheck() + { + assertTrue(testTs_1_5_Features()); + } + @Rule public ExpectedException thrown= ExpectedException.none(); @@ -105,7 +108,7 @@ public void test_c_StoringData() throws ExecutionException, InterruptedException { RiakClient client = new RiakClient(cluster); - Store store = new Store.Builder(tableName).withRows(rows).build(); + Store store = new Store.Builder(tableName).withRows(ts_1_5_rows).build(); RiakFuture execFuture = client.executeAsync(store); @@ -158,7 +161,7 @@ public void test_f_QueryingDataWithMinimumPredicate() throws ExecutionException, assertEquals(8, queryResult.getColumnDescriptionsCopy().size()); assertEquals(1, queryResult.getRowsCount()); - assertRowMatches(rows.get(1), queryResult.iterator().next()); + assertRowMatches(ts_1_5_rows.get(1), queryResult.iterator().next()); } @Test @@ -179,7 +182,7 @@ public void test_g_QueryingDataWithExtraPredicate() throws ExecutionException, I assertEquals(8, queryResult.getColumnDescriptionsCopy().size()); assertEquals(1, queryResult.getRowsCount()); - assertRowMatches(rows.get(1), queryResult.iterator().next()); + assertRowMatches(ts_1_5_rows.get(1), queryResult.iterator().next()); } @Test @@ -200,8 +203,8 @@ public void test_h_QueryingDataAcrossManyQuantum() throws ExecutionException, In assertEquals(2, queryResult.getRowsCount()); final Iterator itor = queryResult.iterator(); - assertRowMatches(rows.get(1), itor.next()); - assertRowMatches(rows.get(2), itor.next()); + assertRowMatches(ts_1_5_rows.get(1), itor.next()); + assertRowMatches(ts_1_5_rows.get(2), itor.next()); } @Test @@ -256,7 +259,7 @@ public void test_k_TestStoringDataOutOfOrderResultsInError() throws ExecutionExc @Test public void test_l_TestFetchingSingleRowsWorks() throws ExecutionException, InterruptedException { - Row expectedRow = rows.get(7); + Row expectedRow = ts_1_5_rows.get(7); List keyCells = expectedRow.getCellsCopy().stream().limit(3).collect(Collectors.toList()); RiakClient client = new RiakClient(cluster); @@ -403,7 +406,7 @@ public void test_z_TestPBCErrorsReturnWhenSecurityIsOn() throws InterruptedExcep private static List GetCreatedTableFullDescriptions() { - return GeoCheckinWideTableDefinition.getFullColumnDescriptions().stream().collect(Collectors.toList()); + return GeoCheckin_1_5_TableDefinition.getFullColumnDescriptions().stream().collect(Collectors.toList()); } private static List toList(Iterator itor) diff --git a/src/test/java/com/basho/riak/client/core/operations/itest/ts/ITestTsBase.java b/src/test/java/com/basho/riak/client/core/operations/itest/ts/ITestTsBase.java index 21241983b..6d53e1f72 100644 --- a/src/test/java/com/basho/riak/client/core/operations/itest/ts/ITestTsBase.java +++ b/src/test/java/com/basho/riak/client/core/operations/itest/ts/ITestTsBase.java @@ -14,9 +14,12 @@ import org.junit.BeforeClass; import java.util.Arrays; +import java.util.LinkedList; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import java.util.function.Function; +import java.util.stream.Collectors; /** * Time Series Operation Integration Tests Base @@ -46,6 +49,7 @@ public abstract class ITestTsBase extends ITestAutoCleanupBase { protected final static String tableName = "GeoCheckin_Wide"; + protected final static String tableName_ts_1_5 = "GeoCheckin_Wide_1_5"; protected final static TableDefinition GeoCheckinWideTableDefinition = new TableDefinition(tableName, Arrays.asList( @@ -57,11 +61,20 @@ public abstract class ITestTsBase extends ITestAutoCleanupBase new FullColumnDescription("weather", ColumnDescription.ColumnType.VARCHAR, false), new FullColumnDescription("temperature", ColumnDescription.ColumnType.DOUBLE, true), new FullColumnDescription("uv_index", ColumnDescription.ColumnType.SINT64, true), - new FullColumnDescription("observed", ColumnDescription.ColumnType.BOOLEAN, false), - new FullColumnDescription("sensor_data", ColumnDescription.ColumnType.BLOB, true) + new FullColumnDescription("observed", ColumnDescription.ColumnType.BOOLEAN, false) ) ); + protected final static TableDefinition GeoCheckin_1_5_TableDefinition; + + static + { + final LinkedList geoCheckinColumns = + new LinkedList<>(GeoCheckinWideTableDefinition.getFullColumnDescriptions()); + geoCheckinColumns.add(new FullColumnDescription("sensor_data", ColumnDescription.ColumnType.BLOB, true)); + GeoCheckin_1_5_TableDefinition = new TableDefinition(tableName, geoCheckinColumns); + } + protected final static long now = 1443806900000L; // "now" protected final static long fiveMinsInMS = 5L * 60L * 1000L; protected final static long fiveMinsAgo = now - fiveMinsInMS; @@ -69,36 +82,54 @@ public abstract class ITestTsBase extends ITestAutoCleanupBase protected final static long fifteenMinsAgo = tenMinsAgo - fiveMinsInMS; protected final static long fifteenMinsInFuture = now + (fiveMinsInMS * 3L); - protected final static List rows = Arrays.asList( + protected final static List rows; + protected static final List ts_1_5_rows; + + private static Function convertToTs1_5Row = x -> + { + final List cells = new LinkedList<>(x.getCellsCopy()); + cells.add(null); + return new Row(cells); + }; + + static + { + rows = Arrays.asList( // "Normal" Data new Row(new Cell("hash1"), new Cell("user1"), Cell.newTimestamp(fifteenMinsAgo), - new Cell("cloudy"), new Cell(79.0), new Cell(1), new Cell(true), null), + new Cell("cloudy"), new Cell(79.0), new Cell(1), new Cell(true)), new Row(new Cell("hash1"), new Cell("user1"), Cell.newTimestamp(fiveMinsAgo), - new Cell("sunny"), new Cell(80.5), new Cell(2), new Cell(true), null), + new Cell("sunny"), new Cell(80.5), new Cell(2), new Cell(true)), new Row(new Cell("hash1"), new Cell("user1"), Cell.newTimestamp(now), - new Cell("sunny"), new Cell(81.0), new Cell(10), new Cell(false), null), + new Cell("sunny"), new Cell(81.0), new Cell(10), new Cell(false)), // Null Cell row new Row(new Cell("hash1"), new Cell("user2"), Cell.newTimestamp(fiveMinsAgo), - new Cell("cloudy"), null, null, new Cell(true), null), + new Cell("cloudy"), null, null, new Cell(true)), // Data for single reads / deletes new Row(new Cell("hash2"), new Cell("user4"), Cell.newTimestamp(fifteenMinsAgo), - new Cell("rain"), new Cell(79.0), new Cell(2), new Cell(false), null), + new Cell("rain"), new Cell(79.0), new Cell(2), new Cell(false)), new Row(new Cell("hash2"), new Cell("user4"), Cell.newTimestamp(fiveMinsAgo), - new Cell("wind"), new Cell(50.5), new Cell(3), new Cell(true), null), + new Cell("wind"), new Cell(50.5), new Cell(3), new Cell(true)), new Row(new Cell("hash2"), new Cell("user4"), Cell.newTimestamp(now), - new Cell("snow"), new Cell(20.0), new Cell(11), new Cell(true), null), - - - // Data for blob tests - new Row(new Cell("hash2"), new Cell("user4"), Cell.newTimestamp(now + 3), - new Cell("snow"), new Cell(20.0), new Cell(11), new Cell(true), new Cell(new byte[] {0,1,2,3,4,5,6,7})) - ); + new Cell("snow"), new Cell(20.0), new Cell(11), new Cell(true))); + + final LinkedList extendedRows = new LinkedList<>(); + extendedRows.addAll(rows.stream() + .map(convertToTs1_5Row) + .collect(Collectors.toList())); + // Data for blob tests + extendedRows.add(new Row(new Cell("hash2"), new Cell("user4"), Cell.newTimestamp(now + 3), + new Cell("snow"), new Cell(20.0), new Cell(11), new Cell(true), + new Cell(new byte[] {0,1,2,3,4,5,6,7}))); + + ts_1_5_rows = extendedRows; + } @BeforeClass public static void BeforeClass() throws ExecutionException, InterruptedException @@ -178,4 +209,23 @@ protected static QueryResult executeQuery(Query.Builder builder) throws Executio assertFutureSuccess(future); return future.get(); } + + protected static boolean testTs_1_5_Features() + { + final Namespace ns = new Namespace(tableName_ts_1_5, tableName_ts_1_5); + final FetchBucketPropsOperation fbp = new FetchBucketPropsOperation.Builder(ns).build(); + + final RiakFuture execute = cluster.execute(fbp); + try + { + final FetchBucketPropsOperation.Response response = execute.get(); + response.getBucketProperties(); + } + catch (Exception ex) + { + System.out.println(ex.toString()); + return false; + } + return true; + } }