Elffuss BraidHub

kikocis/java-driver public

Version restrict tests and add documentation

Also reorganized renamed some tests in MapperInvalidAnnotationTests for
consistency.
Changeset3948ebd3e3f1367ae740c9f2a6e5dcebe458bf4841d29c761fda8dc638f424ec
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2016-07-12 16:59 -05:00
Committerolim7t <omichallat+github@gmail.com> · 2016-07-22 09:51 -07:00
Parents941704f40983

Browse the files at this changeset

4 files changed

deleted driver-mapping/src/test/java/com/datastax/driver/mapping/MapperCaseSensitivenessTest.java +0 −180
@@ -1,180 +0,0 @@
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- */
16-package com.datastax.driver.mapping;
17-
18-import com.datastax.driver.core.CCMConfig;
19-import com.datastax.driver.core.CCMTestsSupport;
20-import com.datastax.driver.core.TestUtils;
21-import com.datastax.driver.mapping.annotations.*;
22-import com.google.common.base.Objects;
23-import org.testng.annotations.Test;
24-
25-import static com.datastax.driver.core.Metadata.quote;
26-import static org.assertj.core.api.Assertions.assertThat;
27-
28-/**
29- *
30- */
31-@CCMConfig(createKeyspace = false)
32-@SuppressWarnings({"unused", "WeakerAccess"})
33-public class MapperCaseSensitivenessTest extends CCMTestsSupport {
34-
35- static final String KS = "ks_MapperCaseSensitivenessTest";
36- static final String TABLE = "table_MapperCaseSensitivenessTest";
37- static final String TYPE = "udt_MapperCaseSensitivenessTest";
38-
39- UserNoKeyspace user = new UserNoKeyspace("id", new Address("street", "zip"));
40-
41- @Table(keyspace = KS, name = TABLE, caseSensitiveKeyspace = true, caseSensitiveTable = true)
42- static class User {
43-
44- @PartitionKey
45- @Column(caseSensitive = true)
46- private String userId;
47-
48- @Column(name = "Address", caseSensitive = true)
49- private Address address;
50-
51- public User() {
52- }
53-
54- public User(String userId, Address address) {
55- this.userId = userId;
56- this.address = address;
57- }
58-
59- public String getUserId() {
60- return userId;
61- }
62-
63- public void setUserId(String userId) {
64- this.userId = userId;
65- }
66-
67- public Address getAddress() {
68- return address;
69- }
70-
71- public void setAddress(Address address) {
72- this.address = address;
73- }
74-
75- @Override
76- public boolean equals(Object o) {
77- if (this == o) return true;
78- if (o == null || !(o instanceof User)) return false;
79- User user = (User) o;
80- return Objects.equal(userId, user.userId) &&
81- Objects.equal(address, user.address);
82- }
83-
84- @Override
85- public int hashCode() {
86- return Objects.hashCode(userId, address);
87- }
88- }
89-
90- @UDT(keyspace = KS, name = TYPE, caseSensitiveKeyspace = true, caseSensitiveType = true)
91- static class Address {
92-
93- @Field(name = "Street", caseSensitive = true)
94- private String street;
95-
96- @Field(caseSensitive = true)
97- private String zipCode;
98-
99- public Address() {
100- }
101-
102- public Address(String street, String zipCode) {
103- this.street = street;
104- this.zipCode = zipCode;
105- }
106-
107- public String getStreet() {
108- return street;
109- }
110-
111- public void setStreet(String street) {
112- this.street = street;
113- }
114-
115- public String getZipCode() {
116- return zipCode;
117- }
118-
119- public void setZipCode(String zipCode) {
120- this.zipCode = zipCode;
121- }
122-
123- @Override
124- public boolean equals(Object o) {
125- if (this == o) return true;
126- if (o == null || !(o instanceof Address)) return false;
127- Address address = (Address) o;
128- return Objects.equal(street, address.street) &&
129- Objects.equal(zipCode, address.zipCode);
130- }
131-
132- @Override
133- public int hashCode() {
134- return Objects.hashCode(getStreet(), getZipCode());
135- }
136- }
137-
138- @Table(name = TABLE, caseSensitiveKeyspace = true, caseSensitiveTable = true)
139- static class UserNoKeyspace extends User {
140-
141- public UserNoKeyspace() {
142- }
143-
144- public UserNoKeyspace(String id, Address address) {
145- super(id, address);
146- }
147-
148- }
149-
150- @UDT(name = TYPE, caseSensitiveKeyspace = true, caseSensitiveType = true)
151- static class AddressNoKeyspace extends Address {
152-
153- }
154-
155- @Override
156- public void onTestContextInitialized() {
157- execute(String.format(TestUtils.CREATE_KEYSPACE_SIMPLE_FORMAT, quote(KS), 1));
158- useKeyspace(quote(KS));
159- execute(
160- "CREATE TYPE " + quote(TYPE) + " (\"Street\" text, \"zipCode\" text)",
161- "CREATE TABLE " + quote(TABLE) + " (\"userId\" text PRIMARY KEY, \"Address\" frozen<" + quote(TYPE) + ">)");
162- }
163-
164- @Test(groups = "short")
165- public void should_handle_case_sensitive_identifiers_when_keyspace_specified() throws Exception {
166- MappingManager mappingManager = new MappingManager(session());
167- Mapper<User> mapper = mappingManager.mapper(User.class);
168- mapper.save(user);
169- assertThat(mapper.get(user.getUserId())).isEqualTo(user);
170- }
171-
172- @Test(groups = "short")
173- public void should_handle_case_sensitive_identifiers_whitout_keyspace_specified() throws Exception {
174- MappingManager mappingManager = new MappingManager(session());
175- Mapper<UserNoKeyspace> mapper = mappingManager.mapper(UserNoKeyspace.class);
176- mapper.save(user);
177- assertThat(mapper.get(user.getUserId())).isEqualTo(user);
178- }
179-
180-}
added driver-mapping/src/test/java/com/datastax/driver/mapping/MapperCaseSensitivityTest.java +192 −0
@@ -0,0 +1,192 @@
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+ */
16+package com.datastax.driver.mapping;
17+
18+import com.datastax.driver.core.CCMConfig;
19+import com.datastax.driver.core.CCMTestsSupport;
20+import com.datastax.driver.core.TestUtils;
21+import com.datastax.driver.core.utils.CassandraVersion;
22+import com.datastax.driver.mapping.annotations.*;
23+import com.google.common.base.Objects;
24+import org.testng.annotations.Test;
25+
26+import static com.datastax.driver.core.Metadata.quote;
27+import static org.assertj.core.api.Assertions.assertThat;
28+
29+@CCMConfig(createKeyspace = false)
30+@CassandraVersion(major = 2.1)
31+public class MapperCaseSensitivityTest extends CCMTestsSupport {
32+
33+ static final String KS = "ks_MapperCaseSensitivityTest";
34+ static final String TABLE = "table_MapperCaseSensitivityTest";
35+ static final String TYPE = "udt_MapperCaseSensitivityTest";
36+
37+ UserNoKeyspace user = new UserNoKeyspace("id", new Address("street", "zip"));
38+
39+ @Table(keyspace = KS, name = TABLE, caseSensitiveKeyspace = true, caseSensitiveTable = true)
40+ static class User {
41+
42+ @PartitionKey
43+ @Column(caseSensitive = true)
44+ private String userId;
45+
46+ @Column(name = "Address", caseSensitive = true)
47+ private Address address;
48+
49+ public User() {
50+ }
51+
52+ public User(String userId, Address address) {
53+ this.userId = userId;
54+ this.address = address;
55+ }
56+
57+ public String getUserId() {
58+ return userId;
59+ }
60+
61+ public void setUserId(String userId) {
62+ this.userId = userId;
63+ }
64+
65+ public Address getAddress() {
66+ return address;
67+ }
68+
69+ public void setAddress(Address address) {
70+ this.address = address;
71+ }
72+
73+ @Override
74+ public boolean equals(Object o) {
75+ if (this == o) return true;
76+ if (o == null || !(o instanceof User)) return false;
77+ User user = (User) o;
78+ return Objects.equal(userId, user.userId) &&
79+ Objects.equal(address, user.address);
80+ }
81+
82+ @Override
83+ public int hashCode() {
84+ return Objects.hashCode(userId, address);
85+ }
86+ }
87+
88+ @UDT(keyspace = KS, name = TYPE, caseSensitiveKeyspace = true, caseSensitiveType = true)
89+ static class Address {
90+
91+ @Field(name = "Street", caseSensitive = true)
92+ private String street;
93+
94+ @Field(caseSensitive = true)
95+ private String zipCode;
96+
97+ public Address() {
98+ }
99+
100+ public Address(String street, String zipCode) {
101+ this.street = street;
102+ this.zipCode = zipCode;
103+ }
104+
105+ public String getStreet() {
106+ return street;
107+ }
108+
109+ public void setStreet(String street) {
110+ this.street = street;
111+ }
112+
113+ public String getZipCode() {
114+ return zipCode;
115+ }
116+
117+ public void setZipCode(String zipCode) {
118+ this.zipCode = zipCode;
119+ }
120+
121+ @Override
122+ public boolean equals(Object o) {
123+ if (this == o) return true;
124+ if (o == null || !(o instanceof Address)) return false;
125+ Address address = (Address) o;
126+ return Objects.equal(street, address.street) &&
127+ Objects.equal(zipCode, address.zipCode);
128+ }
129+
130+ @Override
131+ public int hashCode() {
132+ return Objects.hashCode(getStreet(), getZipCode());
133+ }
134+ }
135+
136+ @Table(name = TABLE, caseSensitiveKeyspace = true, caseSensitiveTable = true)
137+ static class UserNoKeyspace extends User {
138+
139+ public UserNoKeyspace() {
140+ }
141+
142+ public UserNoKeyspace(String id, Address address) {
143+ super(id, address);
144+ }
145+
146+ }
147+
148+ @UDT(name = TYPE, caseSensitiveKeyspace = true, caseSensitiveType = true)
149+ static class AddressNoKeyspace extends Address {
150+
151+ }
152+
153+ @Override
154+ public void onTestContextInitialized() {
155+ execute(String.format(TestUtils.CREATE_KEYSPACE_SIMPLE_FORMAT, quote(KS), 1));
156+ useKeyspace(quote(KS));
157+ execute(
158+ "CREATE TYPE " + quote(TYPE) + " (\"Street\" text, \"zipCode\" text)",
159+ "CREATE TABLE " + quote(TABLE) + " (\"userId\" text PRIMARY KEY, \"Address\" frozen<" + quote(TYPE) + ">)");
160+ }
161+
162+ /**
163+ * Validates that case sensitive identifiers for fields, types, columns, tables and keyspaces work with the mapper
164+ * when the keyspace name is specified on the mapped class.
165+ *
166+ * @jira_ticket JAVA-564
167+ * @test_category object_mapper
168+ */
169+ @Test(groups = "short")
170+ public void should_handle_case_sensitive_identifiers_when_keyspace_specified() throws Exception {
171+ MappingManager mappingManager = new MappingManager(session());
172+ Mapper<User> mapper = mappingManager.mapper(User.class);
173+ mapper.save(user);
174+ assertThat(mapper.get(user.getUserId())).isEqualTo(user);
175+ }
176+
177+ /**
178+ * Validates that case sensitive identifiers for fields, types, columns, tables and keyspaces work with the mapper
179+ * when the keyspace name is *not* specified on the mapped class.
180+ *
181+ * @jira_ticket JAVA-564
182+ * @test_category object_mapper
183+ */
184+ @Test(groups = "short")
185+ public void should_handle_case_sensitive_identifiers_without_keyspace_specified() throws Exception {
186+ MappingManager mappingManager = new MappingManager(session());
187+ Mapper<UserNoKeyspace> mapper = mappingManager.mapper(UserNoKeyspace.class);
188+ mapper.save(user);
189+ assertThat(mapper.get(user.getUserId())).isEqualTo(user);
190+ }
191+
192+}
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperInvalidAnnotationsTest.java +56 −57
@@ -52,48 +52,46 @@
5252 static class Invalid1 {
5353 }
5454
55- @Table(name = "foo")
56- @UDT(name = "foo")
57- static class Invalid2 {
58- }
59-
60- @Table(name = "foo")
61- @Accessor
62- static class Invalid3 {
63- }
64-
65- @UDT(name = "foo")
66- @Accessor
67- static class Invalid4 {
55+ @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
56+ expectedExceptionsMessageRegExp =
57+ "@Table annotation was not found on class " +
58+ "com.datastax.driver.mapping.MapperInvalidAnnotationsTest\\$Invalid1")
59+ public void should_throw_IAE_when_Table_annotation_not_found_on_entity_class() throws Exception {
60+ AnnotationParser.parseEntity(Invalid1.class, mappingManager);
6861 }
6962
70- interface Invalid5 {
63+ @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
64+ expectedExceptionsMessageRegExp =
65+ "@UDT annotation was not found on class " +
66+ "com.datastax.driver.mapping.MapperInvalidAnnotationsTest\\$Invalid1")
67+ public void should_throw_IAE_when_UDT_annotation_not_found_on_udt_class() throws Exception {
68+ AnnotationParser.parseUDT(Invalid1.class, mappingManager);
7169 }
7270
7371 @Table(name = "foo")
74- @Accessor
75- interface Invalid6 {
76- }
77-
7872 @UDT(name = "foo")
79- @Accessor
80- interface Invalid7 {
73+ static class Invalid2 {
8174 }
8275
8376 @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
8477 expectedExceptionsMessageRegExp =
85- "@Table annotation was not found on class " +
86- "com.datastax.driver.mapping.MapperInvalidAnnotationsTest\\$Invalid1")
87- public void should_throw_IAE_when_Table_annotation_not_found_on_entity_class() throws Exception {
88- AnnotationParser.parseEntity(Invalid1.class, mappingManager);
78+ "Cannot have both @Table and @UDT on class " +
79+ "com.datastax.driver.mapping.MapperInvalidAnnotationsTest\\$Invalid2")
80+ public void should_throw_IAE_when_UDT_annotation_found_on_entity_class() throws Exception {
81+ AnnotationParser.parseEntity(Invalid2.class, mappingManager);
8982 }
9083
9184 @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
9285 expectedExceptionsMessageRegExp =
93- "Cannot have both @Table and @UDT on class " +
86+ "Cannot have both @UDT and @Table on class " +
9487 "com.datastax.driver.mapping.MapperInvalidAnnotationsTest\\$Invalid2")
95- public void should_throw_IAE_when_UDT_annotation_found_on_entity_class() throws Exception {
96- AnnotationParser.parseEntity(Invalid2.class, mappingManager);
88+ public void should_throw_IAE_when_Table_annotation_found_on_udt_class() throws Exception {
89+ AnnotationParser.parseUDT(Invalid2.class, mappingManager);
90+ }
91+
92+ @Table(name = "foo")
93+ @Accessor
94+ static class Invalid3 {
9795 }
9896
9997 @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
@@ -104,28 +102,28 @@
104102 AnnotationParser.parseEntity(Invalid3.class, mappingManager);
105103 }
106104
107- @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
108- expectedExceptionsMessageRegExp =
109- "@UDT annotation was not found on class " +
110- "com.datastax.driver.mapping.MapperInvalidAnnotationsTest\\$Invalid1")
111- public void should_throw_IAE_when_UDT_annotation_not_found_on_udt_class() throws Exception {
112- AnnotationParser.parseUDT(Invalid1.class, mappingManager);
105+ @UDT(name = "foo")
106+ @Accessor
107+ static class Invalid4 {
113108 }
114109
115110 @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
116111 expectedExceptionsMessageRegExp =
117- "Cannot have both @UDT and @Table on class " +
118- "com.datastax.driver.mapping.MapperInvalidAnnotationsTest\\$Invalid2")
119- public void should_throw_IAE_when_Table_annotation_found_on_udt_class() throws Exception {
120- AnnotationParser.parseUDT(Invalid2.class, mappingManager);
112+ "Cannot have both @UDT and @Accessor on class " +
113+ "com.datastax.driver.mapping.MapperInvalidAnnotationsTest\\$Invalid4")
114+ public void should_throw_IAE_when_Accessor_annotation_found_on_udt_class() throws Exception {
115+ AnnotationParser.parseUDT(Invalid4.class, mappingManager);
121116 }
122117
123118 @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
124119 expectedExceptionsMessageRegExp =
125- "Cannot have both @UDT and @Accessor on class " +
120+ "@Accessor annotation is only allowed on interfaces, got class " +
126121 "com.datastax.driver.mapping.MapperInvalidAnnotationsTest\\$Invalid4")
127- public void should_throw_IAE_when_Accessor_annotation_found_on_udt_class() throws Exception {
128- AnnotationParser.parseUDT(Invalid4.class, mappingManager);
122+ public void should_throw_IAE_when_Accessor_annotation_found_on_concrete_class() throws Exception {
123+ AnnotationParser.parseAccessor(Invalid4.class, mappingManager);
124+ }
125+
126+ interface Invalid5 {
129127 }
130128
131129 @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
@@ -136,6 +134,11 @@
136134 AnnotationParser.parseAccessor(Invalid5.class, mappingManager);
137135 }
138136
137+ @Table(name = "foo")
138+ @Accessor
139+ interface Invalid6 {
140+ }
141+
139142 @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
140143 expectedExceptionsMessageRegExp =
141144 "Cannot have both @Accessor and @Table on interface " +
@@ -144,6 +147,11 @@
144147 AnnotationParser.parseAccessor(Invalid6.class, mappingManager);
145148 }
146149
150+ @UDT(name = "foo")
151+ @Accessor
152+ interface Invalid7 {
153+ }
154+
147155 @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
148156 expectedExceptionsMessageRegExp =
149157 "Cannot have both @Accessor and @UDT on interface " +
@@ -152,14 +160,6 @@
152160 AnnotationParser.parseAccessor(Invalid7.class, mappingManager);
153161 }
154162
155- @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
156- expectedExceptionsMessageRegExp =
157- "@Accessor annotation is only allowed on interfaces, got class " +
158- "com.datastax.driver.mapping.MapperInvalidAnnotationsTest\\$Invalid4")
159- public void should_throw_IAE_when_Accessor_annotation_found_on_concrete_class() throws Exception {
160- AnnotationParser.parseAccessor(Invalid4.class, mappingManager);
161- }
162-
163163 @Table(name = "foo", keyspace = "ks")
164164 static class Invalid8 {
165165 @Field
@@ -169,7 +169,7 @@
169169 @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
170170 expectedExceptionsMessageRegExp =
171171 "Annotation @Field is not allowed on property 'invalid'")
172- public void should_not_allow_Field_on_entity_class() throws Exception {
172+ public void should_throw_IAE_when_Field_annotation_found_on_entity_class_field() throws Exception {
173173 AnnotationParser.parseEntity(Invalid8.class, mappingManager);
174174 }
175175
@@ -187,7 +187,7 @@
187187 @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
188188 expectedExceptionsMessageRegExp =
189189 "Annotation @Column is not allowed on property 'invalid'")
190- public void should_not_allow_Column_on_udt_class() throws Exception {
190+ public void should_throw_IAE_when_Column_annotation_found_on_udt_class_field() throws Exception {
191191 AnnotationParser.parseUDT(Invalid9.class, mappingManager);
192192 }
193193
@@ -203,7 +203,7 @@
203203 @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
204204 expectedExceptionsMessageRegExp =
205205 "Property 'invalid' cannot be annotated with both @PartitionKey and @ClusteringColumn")
206- public void should_not_allow_PartitionKey_and_ClusteringColumn_on_same_property() throws Exception {
206+ public void should_throw_IAE_when_PartitionKey_and_ClusteringColumn_on_same_property() throws Exception {
207207 AnnotationParser.parseEntity(Invalid10.class, mappingManager);
208208 }
209209
@@ -219,7 +219,7 @@
219219 @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
220220 expectedExceptionsMessageRegExp =
221221 "Property 'invalid' cannot be annotated with both @Column and @Computed")
222- public void should_not_allow_Computed_and_Column_on_same_property() throws Exception {
222+ public void should_throw_IAE_when_Computed_and_Column_on_same_property() throws Exception {
223223 AnnotationParser.parseEntity(Invalid11.class, mappingManager);
224224 }
225225
@@ -234,7 +234,7 @@
234234 @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
235235 expectedExceptionsMessageRegExp =
236236 "Property 'invalid': attribute 'value' of annotation @Computed is mandatory for computed properties")
237- public void should_not_allow_Computed_with_empty_value() throws Exception {
237+ public void should_throw_IAE_when_Computed_with_empty_value() throws Exception {
238238 AnnotationParser.parseEntity(Invalid12.class, mappingManager);
239239 }
240240
@@ -249,7 +249,7 @@
249249 @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
250250 expectedExceptionsMessageRegExp =
251251 "Invalid ordering value -1 for annotation @PartitionKey of property 'invalid', was expecting 0")
252- public void should_not_allow_PartitionKey_with_wrong_order() throws Exception {
252+ public void should_throw_IAE_when_PartitionKey_with_wrong_order() throws Exception {
253253 AnnotationParser.parseEntity(Invalid13.class, mappingManager);
254254 }
255255
@@ -264,7 +264,7 @@
264264 @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
265265 expectedExceptionsMessageRegExp =
266266 "Property 'notReadable' is not readable")
267- public void should_not_allow_unreadable_property() throws Exception {
267+ public void should_throw_IAE_when_unreadable_property() throws Exception {
268268 AnnotationParser.parseEntity(Invalid14.class, mappingManager);
269269 }
270270
@@ -280,9 +280,8 @@
280280 @Test(groups = "unit", expectedExceptions = IllegalArgumentException.class,
281281 expectedExceptionsMessageRegExp =
282282 "Property 'notWritable' is not writable")
283- public void should_not_allow_unwritable_property() throws Exception {
283+ public void should_throw_IAE_when_unwritable_property() throws Exception {
284284 AnnotationParser.parseEntity(Invalid15.class, mappingManager);
285285 }
286286
287-
288287 }
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperPolymorphismTest.java +40 −0
@@ -16,6 +16,7 @@
1616 package com.datastax.driver.mapping;
1717
1818 import com.datastax.driver.core.CCMTestsSupport;
19+import com.datastax.driver.core.utils.CassandraVersion;
1920 import com.datastax.driver.mapping.annotations.*;
2021 import com.google.common.base.Objects;
2122 import com.google.common.collect.Sets;
@@ -33,6 +34,7 @@
3334 * JAVA-636 Allow @Column annotations on getters/setters as well as fields
3435 */
3536 @SuppressWarnings({"unused", "WeakerAccess"})
37+@CassandraVersion(major = 2.1)
3638 public class MapperPolymorphismTest extends CCMTestsSupport {
3739
3840 Circle circle = new Circle(new Point2D(11, 22), 12.34);
@@ -446,6 +448,21 @@
446448
447449 }
448450
451+ /**
452+ * Validates that fields and methods from a parent class {@link Shape} are inherited for a mapped entity
453+ * class {@link Circle}.
454+ * <p/>
455+ * It also ensures that methods overridden in {@link Circle} are given precedence and that their annotations are
456+ * used. In the case of circle, the {@link Circle#getId()} method overrides the parent and specifies a
457+ * {@link Column} annotation that will be used instead of the parents annotation ('wrong').
458+ * <p/>
459+ * Lastly, it defines another column 'radius' that is defined by having {@link Circle#getRadius} and
460+ * {@link Circle#setRadius} properties, while it has a {@link Transient} field '_radius' that should not be pulled
461+ * in by the mapper.
462+ *
463+ * @test_category object_mapper
464+ * @jira_ticket JAVA-541, JAVA-636
465+ */
449466 @Test(groups = "short")
450467 public void should_save_and_retrieve_circle() throws Exception {
451468 MappingManager mappingManager = new MappingManager(session());
@@ -454,6 +471,14 @@
454471 assertThat(circleMapper.get(circle.getId())).isEqualTo(circle);
455472 }
456473
474+ /**
475+ * Validates that property methods such as {@link Rectangle#getWidth} and {@link Rectangle#getHeight} are not
476+ * considered as they are marked as {@link Transient}. It also ensures that overridden method
477+ * {@link Rectangle#getArea} inherits its parent's {@link Transient} annotation.
478+ *
479+ * @test_category object_mapper
480+ * @jira_ticket JAVA-541, JAVA-636
481+ */
457482 @Test(groups = "short")
458483 public void should_save_and_retrieve_rectangle() throws Exception {
459484 MappingManager mappingManager = new MappingManager(session());
@@ -462,6 +487,14 @@
462487 assertThat(rectangleMapper.get(rectangle.getId())).isEqualTo(rectangle);
463488 }
464489
490+ /**
491+ * Validates that {@link Square} inherits its properties from its parent class {@link Rectangle} and its parent's
492+ * class {@link Shape} and that its methods {@link Square#getBottomLeft} and {@link Square#getHeight} inherit
493+ * annotations from its parent.
494+ *
495+ * @test_category object_mapper
496+ * @jira_ticket JAVA-541, JAVA-636
497+ */
465498 @Test(groups = "short")
466499 public void should_save_and_retrieve_square() throws Exception {
467500 MappingManager mappingManager = new MappingManager(session());
@@ -470,6 +503,13 @@
470503 assertThat(squareMapper.get(square.getId())).isEqualTo(square);
471504 }
472505
506+ /**
507+ * Validates that {@link Sphere} inherits its properties from its parent class {@link Circle} and most importantly
508+ * can specialize the type of {@link Sphere#center} to a {@link Point3D} instead of a {@link Point2D}.
509+ *
510+ * @test_category object_mapper
511+ * @jira_ticket JAVA-541, JAVA-636
512+ */
473513 @Test(groups = "short")
474514 public void should_save_and_retrieve_sphere() throws Exception {
475515 MappingManager mappingManager = new MappingManager(session());