added test for BigInteger / varint mapping

This commit is contained in:
Pete Cable
2015-01-26 17:18:15 -08:00
parent 2ea0f6c54d
commit 484e858393
3 changed files with 89 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
package org.springframework.data.cassandra.test.integration.querymethods.bigintparam;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.cassandra.config.SchemaAction;
import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
import org.springframework.data.cassandra.test.integration.support.AbstractSpringDataEmbeddedCassandraIntegrationTest;
import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.math.BigInteger;
import static org.junit.Assert.assertNotNull;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class BigIntParamIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
@Configuration
@EnableCassandraRepositories(basePackageClasses = BigThingRepo.class)
public static class Config extends IntegrationTestConfig {
@Override
public String[] getEntityBasePackages() {
return new String[] { BigThing.class.getPackage().getName() };
}
@Override
public SchemaAction getSchemaAction() {
return SchemaAction.RECREATE_DROP_UNUSED;
}
}
@Autowired
BigThingRepo repo;
@Test
public void testQueryWithReference() {
BigInteger number = new BigInteger("42");
BigThing saved = new BigThing(number);
repo.save(saved);
BigThing found = repo.findThingByBigInteger(new BigInteger("42"));
assertNotNull(found);
}
}

View File

@@ -0,0 +1,28 @@
package org.springframework.data.cassandra.test.integration.querymethods.bigintparam;
import org.springframework.cassandra.core.PrimaryKeyType;
import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
import org.springframework.data.cassandra.mapping.Table;
import java.math.BigInteger;
@Table
public class BigThing {
@PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
private BigInteger number;
public BigThing() {}
public BigThing(BigInteger number) {
setNumber(number);
}
public BigInteger getNumber() {
return number;
}
public void setNumber(BigInteger number) {
this.number = number;
}
}

View File

@@ -0,0 +1,13 @@
package org.springframework.data.cassandra.test.integration.querymethods.bigintparam;
import org.springframework.data.cassandra.repository.CassandraRepository;
import org.springframework.data.cassandra.repository.Query;
import java.math.BigInteger;
public interface BigThingRepo extends CassandraRepository<BigThing> {
@Query("SELECT * from bigthing where number = ?0")
BigThing findThingByBigInteger(BigInteger number);
}