Elffuss BraidHub

kikocis/java-driver public

9b39ff6a48bf · 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.CCMTestsSupport;
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
24/**
25 * Tests for the mapper with composite partition keys and multiple clustering columns.
26 */
27public class MapperCompositeKeyTest extends CCMTestsSupport {
28
29 @Override
30 public void onTestContextInitialized() {
31 execute("CREATE TABLE test_table (pk1 int, pk2 int, cc1 int, cc2 int, PRIMARY KEY ((pk1, pk2), cc1, cc2))");
32 }
33
34 @SuppressWarnings("unused")
35 @Table(name = "test_table")
36 public static class TestTable {
37 @PartitionKey(0)
38 private int pk1;
39
40 @PartitionKey(1)
41 private int pk2;
42
43 @ClusteringColumn(0)
44 private int cc1;
45
46 @ClusteringColumn(1)
47 private int cc2;
48
49 public int getPk1() {
50 return pk1;
51 }
52
53 public void setPk1(int pk1) {
54 this.pk1 = pk1;
55 }
56
57 public int getPk2() {
58 return pk2;
59 }
60
61 public void setPk2(int pk2) {
62 this.pk2 = pk2;
63 }
64
65 public int getCc1() {
66 return cc1;
67 }
68
69 public void setCc1(int cc1) {
70 this.cc1 = cc1;
71 }
72
73 public int getCc2() {
74 return cc2;
75 }
76
77 public void setCc2(int cc2) {
78 this.cc2 = cc2;
79 }
80 }
81
82 @Test(groups = "short")
83 public void testCreateMapper() throws Exception {
84 new MappingManager(session()).mapper(TestTable.class);
85 }
86}