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:
@@ -26,6 +26,7 @@ import static org.mockito.Mockito.when;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
@@ -104,7 +105,7 @@ public class GemfireQueryMethodUnitTests {
|
|||||||
assertThat(queryMethod.getLimit(), is(equalTo(expectedLimit)));
|
assertThat(queryMethod.getLimit(), is(equalTo(expectedLimit)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assertThat(queryMethod.getLimit(), is(nullValue()));
|
assertThat(queryMethod.getLimit(), is(equalTo(Integer.MAX_VALUE)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,12 +113,15 @@ public class GemfireQueryMethodUnitTests {
|
|||||||
assertLimitedQuery(queryMethod, null);
|
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
|
@Test
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public void detectsAnnotatedQueryCorrectly() throws Exception {
|
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);
|
GemfireQueryMethod method = new GemfireQueryMethod(Sample.class.getMethod("annotated"), metadata, context);
|
||||||
|
|
||||||
assertThat(method.hasAnnotatedQuery(), is(true));
|
assertThat(method.hasAnnotatedQuery(), is(true));
|
||||||
@@ -260,7 +264,7 @@ public class GemfireQueryMethodUnitTests {
|
|||||||
interface AnnotatedQueryMethods {
|
interface AnnotatedQueryMethods {
|
||||||
|
|
||||||
@Trace
|
@Trace
|
||||||
@Hint({ "IdIdx", "LastNameId" })
|
@Hint({ "IdIdx", "LastNameIdx" })
|
||||||
void queryWithHint();
|
void queryWithHint();
|
||||||
|
|
||||||
@Import("org.example.app.domain.ExampleType")
|
@Import("org.example.app.domain.ExampleType")
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class IncompatibleRegionKeyEntityIdAnimalRepositoryTest {
|
|||||||
catch (BeanCreationException expected) {
|
catch (BeanCreationException expected) {
|
||||||
//expected.printStackTrace(System.err);
|
//expected.printStackTrace(System.err);
|
||||||
assertTrue(expected.getCause() instanceof IllegalArgumentException);
|
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());
|
String.class, Long.class), expected.getCause().getMessage());
|
||||||
throw (IllegalArgumentException) expected.getCause();
|
throw (IllegalArgumentException) expected.getCause();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class PlantRepositoryTest {
|
|||||||
catch (BeanCreationException expected) {
|
catch (BeanCreationException expected) {
|
||||||
//expected.printStackTrace(System.err);
|
//expected.printStackTrace(System.err);
|
||||||
assertTrue(expected.getCause() instanceof IllegalArgumentException);
|
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());
|
Long.class, String.class), expected.getCause().getMessage());
|
||||||
throw (IllegalArgumentException) expected.getCause();
|
throw (IllegalArgumentException) expected.getCause();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class GemfireRepositoryFactoryUnitTests {
|
|||||||
}
|
}
|
||||||
catch (IllegalStateException expected) {
|
catch (IllegalStateException expected) {
|
||||||
assertThat(expected.getMessage(), Matchers.startsWith(
|
assertThat(expected.getMessage(), Matchers.startsWith(
|
||||||
"Pagination is not supported by Gemfire repositories!"));
|
"Pagination is not supported by GemFire Repositories!"));
|
||||||
throw expected;
|
throw expected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user