From ec8a0155e8d7d3ef4109927d47e2e9372430f88f Mon Sep 17 00:00:00 2001 From: John Blum Date: Thu, 13 Dec 2018 12:13:50 -0800 Subject: [PATCH] DATAGEODE-163 - Fix failing entity Index configuration integration tests. Rename EnableIndexingConfigurationIntegrationTests to EnableOqlIndexingConfigurationIntegrationTests. Polish. --- ...ndexingConfigurationIntegrationTests.java} | 16 ++++++-- .../data/gemfire/test/model/Person.java | 39 +++++++++++-------- 2 files changed, 35 insertions(+), 20 deletions(-) rename src/test/java/org/springframework/data/gemfire/config/annotation/{EnableIndexingConfigurationIntegrationTests.java => EnableOqlIndexingConfigurationIntegrationTests.java} (87%) diff --git a/src/test/java/org/springframework/data/gemfire/config/annotation/EnableIndexingConfigurationIntegrationTests.java b/src/test/java/org/springframework/data/gemfire/config/annotation/EnableOqlIndexingConfigurationIntegrationTests.java similarity index 87% rename from src/test/java/org/springframework/data/gemfire/config/annotation/EnableIndexingConfigurationIntegrationTests.java rename to src/test/java/org/springframework/data/gemfire/config/annotation/EnableOqlIndexingConfigurationIntegrationTests.java index 55a24f89..c398e59b 100644 --- a/src/test/java/org/springframework/data/gemfire/config/annotation/EnableIndexingConfigurationIntegrationTests.java +++ b/src/test/java/org/springframework/data/gemfire/config/annotation/EnableOqlIndexingConfigurationIntegrationTests.java @@ -26,9 +26,12 @@ import org.apache.geode.cache.client.ClientRegionShortcut; import org.apache.geode.cache.query.Index; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; import org.springframework.data.gemfire.GemfireUtils; import org.springframework.data.gemfire.IndexType; import org.springframework.data.gemfire.mapping.annotation.Indexed; +import org.springframework.data.gemfire.test.model.Book; import org.springframework.data.gemfire.test.model.Person; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -49,7 +52,8 @@ import org.springframework.test.context.junit4.SpringRunner; */ @RunWith(SpringRunner.class) @ContextConfiguration -public class EnableIndexingConfigurationIntegrationTests { +@SuppressWarnings("unused") +public class EnableOqlIndexingConfigurationIntegrationTests { @Resource(name = "People") private Region people; @@ -91,8 +95,12 @@ public class EnableIndexingConfigurationIntegrationTests { } @ClientCacheApplication(logLevel = "none") - @EnableEntityDefinedRegions(basePackageClasses = Person.class, clientRegionShortcut = ClientRegionShortcut.LOCAL) + @EnableEntityDefinedRegions( + basePackageClasses = Person.class, + clientRegionShortcut = ClientRegionShortcut.LOCAL, + excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = Book.class) + ) @EnableIndexing - static class TestConfiguration { - } + static class TestConfiguration { } + } diff --git a/src/test/java/org/springframework/data/gemfire/test/model/Person.java b/src/test/java/org/springframework/data/gemfire/test/model/Person.java index 560407e8..6887af4e 100644 --- a/src/test/java/org/springframework/data/gemfire/test/model/Person.java +++ b/src/test/java/org/springframework/data/gemfire/test/model/Person.java @@ -49,6 +49,9 @@ import org.springframework.util.ObjectUtils; @SuppressWarnings("unused") public class Person implements Comparable, Serializable { + protected static final String PERSON_TO_STRING = + "{ @type = %1$s, id = %2$d, firstName = %3$s, lastName = %4$s, birthDate = %5$s, gender = %6$s}"; + protected static final String BIRTH_DATE_PATTERN = "yyyy/MM/dd"; private Date birthDate; @@ -101,7 +104,7 @@ public class Person implements Comparable, Serializable { } public Long getId() { - return id; + return this.id; } public void setId(Long id) { @@ -109,7 +112,7 @@ public class Person implements Comparable, Serializable { } public Date getBirthDate() { - return birthDate; + return this.birthDate; } public void setBirthDate(Date birthDate) { @@ -117,11 +120,11 @@ public class Person implements Comparable, Serializable { } public String getFirstName() { - return firstName; + return this.firstName; } public Gender getGender() { - return gender; + return this.gender; } public void setGender(Gender gender) { @@ -129,7 +132,7 @@ public class Person implements Comparable, Serializable { } public String getLastName() { - return lastName; + return this.lastName; } public String getName() { @@ -141,14 +144,17 @@ public class Person implements Comparable, Serializable { int result = nullSafeCompareTo(this.getLastName(), that.getLastName()); - result = (result != 0 ? result : nullSafeCompareTo(this.getFirstName(), that.getLastName())); - result = (result != 0 ? result : nullSafeCompareTo(this.getBirthDate(), that.getBirthDate())); + result = result != 0 ? result : nullSafeCompareTo(this.getFirstName(), that.getLastName()); + result = result != 0 ? result : nullSafeCompareTo(this.getBirthDate(), that.getBirthDate()); return result; } private > int nullSafeCompareTo(T comparableOne, T comparableTwo) { - return (comparableOne == null ? 1 : (comparableTwo == null ? -1 : comparableOne.compareTo(comparableTwo))); + + return comparableOne == null ? 1 + : comparableTwo == null ? -1 + : comparableOne.compareTo(comparableTwo); } @Override @@ -184,15 +190,16 @@ public class Person implements Comparable, Serializable { return hashValue; } - protected static String toString(Date dateTime, String DATE_FORMAT_PATTERN) { - return (dateTime == null ? null : new SimpleDateFormat(DATE_FORMAT_PATTERN).format(dateTime)); - } - @Override public String toString() { - return String.format( - "{ @type = %1$s, id = %2$d, firstName = %3$s, lastName = %4$s, birthDate = %5$s, gender = %6$s}", - getClass().getName(), getId(), getFirstName(), getLastName(), - toString(getBirthDate(), BIRTH_DATE_PATTERN), getGender()); + return String.format(PERSON_TO_STRING, getClass().getName(), getId(), getFirstName(), getLastName(), + toString(getBirthDate(), BIRTH_DATE_PATTERN), getGender()); + } + + protected static String toString(Date dateTime, String DATE_FORMAT_PATTERN) { + + return dateTime != null + ? new SimpleDateFormat(DATE_FORMAT_PATTERN).format(dateTime) + : null; } }