public static CLevel parse(String value) { Preconditions.checkArgument(value != null && !value.isEmpty()); value = value.trim(); if (value.equals("1")) return ONE; else if (value.equals("2")) return TWO; else if (value.equals("3")) return THREE; else { for (CLevel c : values()) { if (c.toString().equalsIgnoreCase(value) || ("CL_" + c.toString()).equalsIgnoreCase(value)) return c; } } throw new IllegalArgumentException("Unrecognized cassandra consistency level: " + value); } }
@Test public void testWriteConsistencyLevel() { int levelsChecked = 0; // Test whether CassandraTransaction honors the write consistency level option for (CLevel writeLevel : CLevel.values()) { StandardBaseTransactionConfig.Builder b = new StandardBaseTransactionConfig.Builder(); ModifiableConfiguration mc = GraphDatabaseConfiguration.buildGraphConfiguration(); mc.set(CASSANDRA_WRITE_CONSISTENCY, writeLevel.name()); b.customOptions(mc); b.timestampProvider(TimestampProviders.MICRO); CassandraTransaction ct = new CassandraTransaction(b.build()); assertEquals(writeLevel, ct.getWriteConsistencyLevel()); levelsChecked++; } // Sanity check: if CLevel.values was empty, something is wrong with the test Preconditions.checkState(0 < levelsChecked); }
@Test public void testReadConsistencyLevel() { int levelsChecked = 0; // Test whether CassandraTransaction honors the write consistency level option for (CLevel writeLevel : CLevel.values()) { StandardBaseTransactionConfig.Builder b = new StandardBaseTransactionConfig.Builder(); ModifiableConfiguration mc = GraphDatabaseConfiguration.buildGraphConfiguration(); mc.set(CASSANDRA_READ_CONSISTENCY, writeLevel.name()); b.timestampProvider(TimestampProviders.MICRO); b.customOptions(mc); CassandraTransaction ct = new CassandraTransaction(b.build()); assertEquals(writeLevel, ct.getReadConsistencyLevel()); levelsChecked++; } // Sanity check: if CLevel.values was empty, something is wrong with the test Preconditions.checkState(0 < levelsChecked); }
public static CLevel parse(String value) { Preconditions.checkArgument(value != null && !value.isEmpty()); value = value.trim(); if (value.equals("1")) return ONE; else if (value.equals("2")) return TWO; else if (value.equals("3")) return THREE; else { for (CLevel c : values()) { if (c.toString().equalsIgnoreCase(value) || ("CL_" + c.toString()).equalsIgnoreCase(value)) return c; } } throw new IllegalArgumentException("Unrecognized cassandra consistency level: " + value); } }
public static CLevel parse(String value) { Preconditions.checkArgument(value != null && !value.isEmpty()); value = value.trim(); if (value.equals("1")) return ONE; else if (value.equals("2")) return TWO; else if (value.equals("3")) return THREE; else { for (CLevel c : values()) { if (c.toString().equalsIgnoreCase(value) || ("CL_" + c.toString()).equalsIgnoreCase(value)) return c; } } throw new IllegalArgumentException("Unrecognized cassandra consistency level: " + value); } }