Elffuss BraidHub

kikocis/java-driver public

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