SGF-429 - GemfirePersistentProperty considers a BigDecimal property an entity.
(cherry picked from commit 6113bfbea146a1036352fcc93f955f52d087822a) Signed-off-by: John Blum <jblum@pivotal.io>
This commit is contained in:
@@ -15,19 +15,30 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.mapping;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link GemfirePersistentEntity}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author John Blum
|
||||
*/
|
||||
public class GemfirePersistentEntityUnitTests {
|
||||
|
||||
protected MappingContext<GemfirePersistentEntity<?>, GemfirePersistentProperty> getMappingContext() {
|
||||
return new GemfireMappingContext();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultsRegionNameToClassName() {
|
||||
GemfirePersistentEntity<UnannotatedRegion> entity = new GemfirePersistentEntity<UnannotatedRegion>(
|
||||
@@ -50,17 +61,60 @@ public class GemfirePersistentEntityUnitTests {
|
||||
assertThat(entity.getRegionName(), is("Foo"));
|
||||
}
|
||||
|
||||
static class UnannotatedRegion {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void bigDecimalPersistentPropertyIsNotEntity() {
|
||||
GemfirePersistentEntity<ExampleDomainObject> entity = (GemfirePersistentEntity<ExampleDomainObject>)
|
||||
getMappingContext().getPersistentEntity(ExampleDomainObject.class);
|
||||
|
||||
assertThat(entity.getRegionName(), is(equalTo("Example")));
|
||||
|
||||
GemfirePersistentProperty currency = entity.getPersistentProperty("currency");
|
||||
|
||||
assertThat(currency, is(notNullValue()));
|
||||
assertThat(currency.isEntity(), is(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void bigIntegerPersistentPropertyIsNotEntity() {
|
||||
GemfirePersistentEntity<ExampleDomainObject> entity = (GemfirePersistentEntity<ExampleDomainObject>)
|
||||
getMappingContext().getPersistentEntity(ExampleDomainObject.class);
|
||||
|
||||
assertThat(entity.getRegionName(), is(equalTo("Example")));
|
||||
|
||||
GemfirePersistentProperty bigNumber = entity.getPersistentProperty("bigNumber");
|
||||
|
||||
assertThat(bigNumber, is(notNullValue()));
|
||||
assertThat(bigNumber.isEntity(), is(false));
|
||||
}
|
||||
|
||||
static class UnannotatedRegion {
|
||||
}
|
||||
|
||||
@Region("Foo")
|
||||
static class AnnotatedRegion {
|
||||
|
||||
}
|
||||
|
||||
@Region
|
||||
static class UnnamedRegion {
|
||||
|
||||
}
|
||||
|
||||
@Region("Example")
|
||||
@SuppressWarnings("unused")
|
||||
static class ExampleDomainObject {
|
||||
|
||||
private BigDecimal currency;
|
||||
|
||||
private BigInteger bigNumber;
|
||||
|
||||
public BigDecimal getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
public BigInteger getBigNumber() {
|
||||
return bigNumber;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.mapping.model;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
|
||||
/**
|
||||
* The GemfireSimpleTypeHolderTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the GemfireSimpleTypeHolder class.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.mapping.model.GemfireSimpleTypeHolder
|
||||
* @see org.springframework.data.mapping.model.SimpleTypeHolder
|
||||
* @since 1.6.3
|
||||
*/
|
||||
public class GemfireSimpleTypeHolderTest {
|
||||
|
||||
private final GemfireSimpleTypeHolder holder = new GemfireSimpleTypeHolder(new SimpleTypeHolder());
|
||||
|
||||
@Test
|
||||
public void bigDecimalAndBigIntegerAreSimpleTypes() {
|
||||
assertThat(holder.isSimpleType(BigDecimal.class), is(true));
|
||||
assertThat(holder.isSimpleType(BigInteger.class), is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void personIsNotASimpleType() {
|
||||
assertThat(holder.isSimpleType(Person.class), is(false));
|
||||
}
|
||||
|
||||
class Person {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user