kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 27f1861b6e829c36df1c13816f4086ce548820f6c298e5a47d2fad983732cdc7 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2015-03-04 19:27 -08:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-03-04 19:28 -08:00 |
| Parents | 62fd71450110 |
1 file changed
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperAccessorTest.java +22 −2
| @@ -9,13 +9,16 @@ | ||
| 9 | 9 | |
| 10 | 10 | import com.datastax.driver.core.CCMBridge; |
| 11 | 11 | import com.datastax.driver.core.ResultSet; |
| 12 | +import com.datastax.driver.core.Row; | |
| 12 | 13 | import com.datastax.driver.mapping.annotations.Accessor; |
| 14 | +import com.datastax.driver.mapping.annotations.Param; | |
| 13 | 15 | import com.datastax.driver.mapping.annotations.Query; |
| 14 | 16 | |
| 15 | 17 | public class MapperAccessorTest extends CCMBridge.PerClassSingleNodeCluster { |
| 16 | 18 | |
| 17 | - @Override protected Collection<String> getTableDefinitions() { | |
| 18 | - return Lists.newArrayList("CREATE TABLE foo (i int primary key)"); | |
| 19 | + @Override | |
| 20 | + protected Collection<String> getTableDefinitions() { | |
| 21 | + return Lists.newArrayList("CREATE TABLE foo (k int primary key, v text)"); | |
| 19 | 22 | } |
| 20 | 23 | |
| 21 | 24 | @Test(groups = "short") |
| @@ -36,9 +39,26 @@ | ||
| 36 | 39 | assertThat(accessor.hashCode()).isEqualTo(System.identityHashCode(accessor)); |
| 37 | 40 | } |
| 38 | 41 | |
| 42 | + @Test(groups = "short") | |
| 43 | + public void should_allow_null_parameter_in_accessor() { | |
| 44 | + FooAccessor accessor = new MappingManager(session) | |
| 45 | + .createAccessor(FooAccessor.class); | |
| 46 | + | |
| 47 | + accessor.insert(1, null); | |
| 48 | + Row row = session.execute("select * from foo where k = 1").one(); | |
| 49 | + | |
| 50 | + assertThat(row.getString("v")).isNull(); | |
| 51 | + } | |
| 52 | + | |
| 39 | 53 | @Accessor |
| 40 | 54 | public interface SystemAccessor { |
| 41 | 55 | @Query("select release_version from system.local") |
| 42 | 56 | ResultSet getCassandraVersion(); |
| 43 | 57 | } |
| 58 | + | |
| 59 | + @Accessor | |
| 60 | + public interface FooAccessor { | |
| 61 | + @Query("insert into foo (k, v) values (:k, :v)") | |
| 62 | + ResultSet insert(@Param("k") int k, @Param("v") String v); | |
| 63 | + } | |
| 44 | 64 | } |