SGF-392 - Add support for OQL Query statement extensions in Repository Query methods via Annotations.

Test refactoring and cleaup.
(cherry picked from commit abc5722af5e26800a25215eca933abbc146e726a)

Signed-off-by: John Blum <jblum@pivotal.io>
This commit is contained in:
John Blum
2015-08-13 14:16:47 -07:00
parent 147714e0a5
commit 8a966bbdd4
4 changed files with 12 additions and 8 deletions

View File

@@ -26,6 +26,7 @@ import static org.mockito.Mockito.when;
import java.lang.reflect.Method;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -104,7 +105,7 @@ public class GemfireQueryMethodUnitTests {
assertThat(queryMethod.getLimit(), is(equalTo(expectedLimit)));
}
else {
assertThat(queryMethod.getLimit(), is(nullValue()));
assertThat(queryMethod.getLimit(), is(equalTo(Integer.MAX_VALUE)));
}
}
@@ -112,12 +113,15 @@ public class GemfireQueryMethodUnitTests {
assertLimitedQuery(queryMethod, null);
}
@Before
public void setup() {
when(metadata.getDomainType()).thenReturn((Class) Person.class);
when(metadata.getReturnedDomainClass(Mockito.any(Method.class))).thenReturn((Class) Person.class);
}
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void detectsAnnotatedQueryCorrectly() throws Exception {
when(metadata.getDomainType()).thenReturn((Class) Person.class);
when(metadata.getReturnedDomainClass(Mockito.any(Method.class))).thenReturn((Class) Person.class);
GemfireQueryMethod method = new GemfireQueryMethod(Sample.class.getMethod("annotated"), metadata, context);
assertThat(method.hasAnnotatedQuery(), is(true));
@@ -260,7 +264,7 @@ public class GemfireQueryMethodUnitTests {
interface AnnotatedQueryMethods {
@Trace
@Hint({ "IdIdx", "LastNameId" })
@Hint({ "IdIdx", "LastNameIdx" })
void queryWithHint();
@Import("org.example.app.domain.ExampleType")

View File

@@ -62,7 +62,7 @@ public class IncompatibleRegionKeyEntityIdAnimalRepositoryTest {
catch (BeanCreationException expected) {
//expected.printStackTrace(System.err);
assertTrue(expected.getCause() instanceof IllegalArgumentException);
assertEquals(String.format("The region referenced only supports keys of type %1$s but the entity to be stored has an id of type %2$s!",
assertEquals(String.format("The Region referenced only supports keys of type %1$s but the entity to be stored has an id of type %2$s!",
String.class, Long.class), expected.getCause().getMessage());
throw (IllegalArgumentException) expected.getCause();
}

View File

@@ -54,7 +54,7 @@ public class PlantRepositoryTest {
catch (BeanCreationException expected) {
//expected.printStackTrace(System.err);
assertTrue(expected.getCause() instanceof IllegalArgumentException);
assertEquals(String.format("The region referenced only supports keys of type %1$s but the entity to be stored has an id of type %2$s!",
assertEquals(String.format("The Region referenced only supports keys of type %1$s but the entity to be stored has an id of type %2$s!",
Long.class, String.class), expected.getCause().getMessage());
throw (IllegalArgumentException) expected.getCause();
}

View File

@@ -84,7 +84,7 @@ public class GemfireRepositoryFactoryUnitTests {
}
catch (IllegalStateException expected) {
assertThat(expected.getMessage(), Matchers.startsWith(
"Pagination is not supported by Gemfire repositories!"));
"Pagination is not supported by GemFire Repositories!"));
throw expected;
}
}