Elffuss BraidHub

kikocis/java-driver public

d457d3dbaa2b · 2.3 KiBRawPermalink
1/*
2 * Copyright (C) 2012-2015 DataStax Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.datastax.driver.mapping;
17
18import com.datastax.driver.core.CCMBridge;
19import com.datastax.driver.mapping.annotations.ClusteringColumn;
20import com.datastax.driver.mapping.annotations.PartitionKey;
21import com.datastax.driver.mapping.annotations.Table;
22import org.testng.annotations.Test;
23
24import java.util.Arrays;
25import java.util.Collection;
26
27/**
28 * Tests for the mapper with composite partition keys and multiple clustering columns.
29 */
30public class MapperCompositeKeyTest extends CCMBridge.PerClassSingleNodeCluster {
31
32 protected Collection<String> getTableDefinitions() {
33 return Arrays.asList("CREATE TABLE test_table (pk1 int, pk2 int, cc1 int, cc2 int, PRIMARY KEY ((pk1, pk2), cc1, cc2))");
34 }
35
36 @Table(keyspace = "ks", name = "test_table")
37 public static class TestTable {
38 @PartitionKey(0)
39 private int pk1;
40
41 @PartitionKey(1)
42 private int pk2;
43
44 @ClusteringColumn(0)
45 private int cc1;
46
47 @ClusteringColumn(1)
48 private int cc2;
49
50 public int getPk1() {
51 return pk1;
52 }
53
54 public void setPk1(int pk1) {
55 this.pk1 = pk1;
56 }
57
58 public int getPk2() {
59 return pk2;
60 }
61
62 public void setPk2(int pk2) {
63 this.pk2 = pk2;
64 }
65
66 public int getCc1() {
67 return cc1;
68 }
69
70 public void setCc1(int cc1) {
71 this.cc1 = cc1;
72 }
73
74 public int getCc2() {
75 return cc2;
76 }
77
78 public void setCc2(int cc2) {
79 this.cc2 = cc2;
80 }
81 }
82
83 @Test(groups = "short")
84 public void testCreateMapper() throws Exception {
85 new MappingManager(session).mapper(TestTable.class);
86 }
87}