Skip to content

Commit ec4fca3

Browse files
committed
Add mapper test for composite keys.
1 parent cb20a6d commit ec4fca3

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.datastax.driver.mapping;
2+
3+
import java.util.Arrays;
4+
import java.util.Collection;
5+
6+
import com.datastax.driver.mapping.annotations.*;
7+
import org.testng.annotations.Test;
8+
9+
import com.datastax.driver.core.CCMBridge;
10+
11+
/**
12+
* Tests for the mapper with composite partition keys and multiple clustering columns.
13+
*/
14+
public class MapperCompositeKeyTest extends CCMBridge.PerClassSingleNodeCluster {
15+
16+
protected Collection<String> getTableDefinitions() {
17+
return Arrays.asList("CREATE TABLE test_table (pk1 int, pk2 int, cc1 int, cc2 int, PRIMARY KEY ((pk1, pk2), cc1, cc2))");
18+
}
19+
20+
@Table(keyspace = "ks", name = "test_table")
21+
public static class TestTable {
22+
@PartitionKey(0)
23+
private int pk1;
24+
25+
@PartitionKey(1)
26+
private int pk2;
27+
28+
@ClusteringColumn(0)
29+
private int cc1;
30+
31+
@ClusteringColumn(1)
32+
private int cc2;
33+
34+
public int getPk1() {
35+
return pk1;
36+
}
37+
38+
public void setPk1(int pk1) {
39+
this.pk1 = pk1;
40+
}
41+
42+
public int getPk2() {
43+
return pk2;
44+
}
45+
46+
public void setPk2(int pk2) {
47+
this.pk2 = pk2;
48+
}
49+
50+
public int getCc1() {
51+
return cc1;
52+
}
53+
54+
public void setCc1(int cc1) {
55+
this.cc1 = cc1;
56+
}
57+
58+
public int getCc2() {
59+
return cc2;
60+
}
61+
62+
public void setCc2(int cc2) {
63+
this.cc2 = cc2;
64+
}
65+
}
66+
67+
@Test(groups = "short")
68+
public void testCreateMapper() throws Exception {
69+
new MappingManager(session).mapper(TestTable.class);
70+
}
71+
}

0 commit comments

Comments
 (0)