Elffuss BraidHub

kikocis/java-driver public

Add/update tests for 'detached' TupleType/QueryBuilder instances.
Changeset1663962b818505653215f8a0071595c24767dbe22911121b141fedfbb3598496
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2015-08-17 13:33 -05:00
CommitterAndrew Tolbert <andrew.tolbert@datastax.com> · 2015-08-17 13:33 -05:00
Parentse8e1d8b945b9

Browse the files at this changeset

2 files changed

modified driver-core/src/test/java/com/datastax/driver/core/TupleTest.java +19 −0
@@ -22,6 +22,7 @@
2222 import com.google.common.base.Joiner;
2323 import org.testng.annotations.Test;
2424
25+import static org.assertj.core.api.Assertions.assertThat;
2526 import static org.testng.Assert.assertEquals;
2627 import static org.testng.Assert.fail;
2728
@@ -388,6 +389,24 @@
388389 }
389390 }
390391
392+ /**
393+ * Validates that tuple values generated from an attached type (cluster-provided TupleType) and
394+ * a detached type (using TupleType.of) are the same.
395+ *
396+ * @since 2.2.0
397+ */
398+ @Test(groups = "short")
399+ public void detachedTupleTypeTest() {
400+ TupleType detachedType = TupleType.of(TestUtils.getDesiredProtocolVersion(), CodecRegistry.DEFAULT_INSTANCE,
401+ DataType.cint(), DataType.text(), DataType.cfloat());
402+ TupleValue detachedValue = detachedType.newValue(1, "hello", 2.0f);
403+
404+ TupleType attachedType = cluster.getMetadata().newTupleType(DataType.cint(), DataType.text(), DataType.cfloat());
405+ TupleValue attachedValue = attachedType.newValue(1, "hello", 2.0f);
406+
407+ assertThat(detachedValue).isEqualTo(attachedValue);
408+ }
409+
391410 /**
392411 * Helper method for creating nested tuple schema
393412 * @param depth
modified driver-core/src/test/java/com/datastax/driver/core/querybuilder/QueryBuilderTest.java +1 −14
@@ -42,20 +42,7 @@
4242
4343 public class QueryBuilderTest {
4444
45- private QueryBuilder builder;
46-
47- @BeforeMethod(groups = "unit")
48- public void setUpQueryBuilder() throws Exception {
49- CodecRegistry codecRegistry = new CodecRegistry();
50- Cluster cluster = mock(Cluster.class);
51- Configuration configuration = mock(Configuration.class);
52- ProtocolOptions protocolOptions = mock(ProtocolOptions.class);
53- when(cluster.getConfiguration()).thenReturn(configuration);
54- when(configuration.getCodecRegistry()).thenReturn(codecRegistry);
55- when(configuration.getProtocolOptions()).thenReturn(protocolOptions);
56- when(protocolOptions.getProtocolVersion()).thenReturn(TestUtils.getDesiredProtocolVersion());
57- builder = new QueryBuilder(cluster);
58- }
45+ private QueryBuilder builder = new QueryBuilder(TestUtils.getDesiredProtocolVersion(), CodecRegistry.DEFAULT_INSTANCE);
5946
6047 @Test(groups = "unit")
6148 public void selectTest() throws Exception {