Skip to content

Commit

Permalink
Fix syntax warning in Cassandra test
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr committed Jan 5, 2020
1 parent 2738fef commit f79bb44
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ public static void createTableClusteringKeys(CassandraSession session, SchemaTab

public static void insertIntoTableClusteringKeys(CassandraSession session, SchemaTableName table, int rowsCount)
{
for (Integer rowNumber = 1; rowNumber <= rowsCount; rowNumber++) {
for (int rowNumber = 1; rowNumber <= rowsCount; rowNumber++) {
Insert insert = QueryBuilder.insertInto(table.getSchemaName(), table.getTableName())
.value("key", "key_" + rowNumber.toString())
.value("key", "key_" + rowNumber)
.value("clust_one", "clust_one")
.value("clust_two", "clust_two_" + rowNumber.toString())
.value("clust_three", "clust_three_" + rowNumber.toString());
.value("clust_two", "clust_two_" + rowNumber)
.value("clust_three", "clust_three_" + rowNumber);
session.execute(insert);
}
assertEquals(session.execute("SELECT COUNT(*) FROM " + table).all().get(0).getLong(0), rowsCount);
Expand All @@ -104,13 +104,13 @@ public static void createTableMultiPartitionClusteringKeys(CassandraSession sess

public static void insertIntoTableMultiPartitionClusteringKeys(CassandraSession session, SchemaTableName table)
{
for (Integer rowNumber = 1; rowNumber < 10; rowNumber++) {
for (int rowNumber = 1; rowNumber < 10; rowNumber++) {
Insert insert = QueryBuilder.insertInto(table.getSchemaName(), table.getTableName())
.value("partition_one", "partition_one_" + rowNumber.toString())
.value("partition_two", "partition_two_" + rowNumber.toString())
.value("partition_one", "partition_one_" + rowNumber)
.value("partition_two", "partition_two_" + rowNumber)
.value("clust_one", "clust_one")
.value("clust_two", "clust_two_" + rowNumber.toString())
.value("clust_three", "clust_three_" + rowNumber.toString());
.value("clust_two", "clust_two_" + rowNumber)
.value("clust_three", "clust_three_" + rowNumber);
session.execute(insert);
}
assertEquals(session.execute("SELECT COUNT(*) FROM " + table).all().get(0).getLong(0), 9);
Expand All @@ -132,7 +132,7 @@ public static void createTableClusteringKeysInequality(CassandraSession session,

public static void insertIntoTableClusteringKeysInequality(CassandraSession session, SchemaTableName table, Date date, int rowsCount)
{
for (Integer rowNumber = 1; rowNumber <= rowsCount; rowNumber++) {
for (int rowNumber = 1; rowNumber <= rowsCount; rowNumber++) {
Insert insert = QueryBuilder.insertInto(table.getSchemaName(), table.getTableName())
.value("key", "key_1")
.value("clust_one", "clust_one")
Expand Down Expand Up @@ -223,12 +223,12 @@ public static void createTableAllTypesPartitionKey(CassandraSession session, Sch

private static void insertTestData(CassandraSession session, SchemaTableName table, Date date, int rowsCount)
{
for (Integer rowNumber = 1; rowNumber <= rowsCount; rowNumber++) {
for (int rowNumber = 1; rowNumber <= rowsCount; rowNumber++) {
Insert insert = QueryBuilder.insertInto(table.getSchemaName(), table.getTableName())
.value("key", "key " + rowNumber.toString())
.value("key", "key " + rowNumber)
.value("typeuuid", UUID.fromString(format("00000000-0000-0000-0000-%012d", rowNumber)))
.value("typeinteger", rowNumber)
.value("typelong", rowNumber.longValue() + 1000)
.value("typelong", rowNumber + 1000)
.value("typebytes", ByteBuffer.wrap(Ints.toByteArray(rowNumber)).asReadOnlyBuffer())
.value("typetimestamp", date)
.value("typeansi", "ansi " + rowNumber)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ public void testPartitionCountOverride()
server.refreshSizeEstimates(KEYSPACE, tableName);

CassandraTokenSplitManager onlyConfigSplitsPerNode = new CassandraTokenSplitManager(session, SPLIT_SIZE, Optional.of(12_345L));
assertEquals(12_345L, onlyConfigSplitsPerNode.getTotalPartitionsCount(KEYSPACE, tableName, Optional.empty()));
assertEquals(onlyConfigSplitsPerNode.getTotalPartitionsCount(KEYSPACE, tableName, Optional.empty()), 12_345L);

CassandraTokenSplitManager onlySessionSplitsPerNode = new CassandraTokenSplitManager(session, SPLIT_SIZE, Optional.empty());
assertEquals(67_890L, onlySessionSplitsPerNode.getTotalPartitionsCount(KEYSPACE, tableName, Optional.of(67_890L)));
assertEquals(onlySessionSplitsPerNode.getTotalPartitionsCount(KEYSPACE, tableName, Optional.of(67_890L)), 67_890L);

CassandraTokenSplitManager sessionOverrideConfig = new CassandraTokenSplitManager(session, SPLIT_SIZE, Optional.of(12_345L));
assertEquals(67_890L, sessionOverrideConfig.getTotalPartitionsCount(KEYSPACE, tableName, Optional.of(67_890L)));
assertEquals(sessionOverrideConfig.getTotalPartitionsCount(KEYSPACE, tableName, Optional.of(67_890L)), 67_890L);

CassandraTokenSplitManager defaultSplitManager = new CassandraTokenSplitManager(session, SPLIT_SIZE, Optional.empty());
assertEquals(0, defaultSplitManager.getTotalPartitionsCount(KEYSPACE, tableName, Optional.empty()));
assertEquals(defaultSplitManager.getTotalPartitionsCount(KEYSPACE, tableName, Optional.empty()), 0);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,40 @@ public class TestCassandraCqlUtils
@Test
public void testValidSchemaName()
{
assertEquals("foo", validSchemaName("foo"));
assertEquals("\"select\"", validSchemaName("select"));
assertEquals(validSchemaName("foo"), "foo");
assertEquals(validSchemaName("select"), "\"select\"");
}

@Test
public void testValidTableName()
{
assertEquals("foo", validTableName("foo"));
assertEquals("\"Foo\"", validTableName("Foo"));
assertEquals("\"select\"", validTableName("select"));
assertEquals(validTableName("foo"), "foo");
assertEquals(validTableName("Foo"), "\"Foo\"");
assertEquals(validTableName("select"), "\"select\"");
}

@Test
public void testValidColumnName()
{
assertEquals("foo", validColumnName("foo"));
assertEquals("\"\"", validColumnName(CassandraCqlUtils.EMPTY_COLUMN_NAME));
assertEquals("\"\"", validColumnName(""));
assertEquals("\"select\"", validColumnName("select"));
assertEquals(validColumnName("foo"), "foo");
assertEquals(validColumnName(CassandraCqlUtils.EMPTY_COLUMN_NAME), "\"\"");
assertEquals(validColumnName(""), "\"\"");
assertEquals(validColumnName("select"), "\"select\"");
}

@Test
public void testQuote()
{
assertEquals("'foo'", quoteStringLiteral("foo"));
assertEquals("'Presto''s'", quoteStringLiteral("Presto's"));
assertEquals(quoteStringLiteral("foo"), "'foo'");
assertEquals(quoteStringLiteral("Presto's"), "'Presto''s'");
}

@Test
public void testQuoteJson()
{
assertEquals("\"foo\"", quoteStringLiteralForJson("foo"));
assertEquals("\"Presto's\"", quoteStringLiteralForJson("Presto's"));
assertEquals("\"xx\\\"xx\"", quoteStringLiteralForJson("xx\"xx"));
assertEquals(quoteStringLiteralForJson("foo"), "\"foo\"");
assertEquals(quoteStringLiteralForJson("Presto's"), "\"Presto's\"");
assertEquals(quoteStringLiteralForJson("xx\"xx"), "\"xx\\\"xx\"");
}

@Test
Expand All @@ -81,6 +81,6 @@ public void testAppendSelectColumns()
appendSelectColumns(sb, columns);
String str = sb.toString();

assertEquals("foo,bar,\"table\"", str);
assertEquals(str, "foo,bar,\"table\"");
}
}

0 comments on commit f79bb44

Please sign in to comment.