use of org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree in project spring-roo by spring-projects.
the class PartTreeUnitTest method validateReturnTypeEntity.
@Test
public void validateReturnTypeEntity() throws Exception {
JavaType exampleType = new JavaType("Example");
JavaType examplePageType = new JavaType("org.springframework.data.domain.Page", 0, DataType.TYPE, null, Arrays.asList(exampleType));
assertEquals(examplePageType, new PartTree("findDistinctByText", memberDetails).getReturnType());
assertEquals(examplePageType, new PartTree("findByText", memberDetails).getReturnType());
assertEquals(examplePageType, new PartTree("findTop2ByText", memberDetails).getReturnType());
assertEquals(examplePageType, new PartTree("findDistinctTop10ByText", memberDetails).getReturnType());
assertEquals(examplePageType, new PartTree("findFirst2ByText", memberDetails).getReturnType());
assertEquals(exampleType, new PartTree("findTopByText", memberDetails).getReturnType());
assertEquals(exampleType, new PartTree("findTopFirst1ByText", memberDetails).getReturnType());
assertEquals(exampleType, new PartTree("findDistinctFirstByText", memberDetails).getReturnType());
assertEquals(exampleType, new PartTree("findDistinctTop1ByText", memberDetails).getReturnType());
}
use of org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree in project spring-roo by spring-projects.
the class PartTreeUnitTest method validateReturnsTypeInteger.
@Test
public void validateReturnsTypeInteger() throws Exception {
JavaType intPageType = new JavaType("org.springframework.data.domain.Page", 0, DataType.TYPE, null, Arrays.asList(JavaType.INT_OBJECT));
assertEquals(intPageType, new PartTree("findDistinctNumberByText", memberDetails).getReturnType());
assertEquals(intPageType, new PartTree("findNumberByText", memberDetails).getReturnType());
assertEquals(intPageType, new PartTree("findTop2NumberByText", memberDetails).getReturnType());
assertEquals(intPageType, new PartTree("findDistinctTop10NumberByText", memberDetails).getReturnType());
assertEquals(intPageType, new PartTree("findFirst2NumberByText", memberDetails).getReturnType());
assertEquals(JavaType.INT_OBJECT, new PartTree("findTopNumberByText", memberDetails).getReturnType());
assertEquals(JavaType.INT_OBJECT, new PartTree("findFirst1NumberByText", memberDetails).getReturnType());
assertEquals(JavaType.INT_OBJECT, new PartTree("findDistinctFirstNumberByText", memberDetails).getReturnType());
assertEquals(JavaType.INT_OBJECT, new PartTree("findDistinctTop1NumberByText", memberDetails).getReturnType());
}
use of org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree in project spring-roo by spring-projects.
the class PartTreeUnitTest method detectsDistinctCorrectly.
@Test
public void detectsDistinctCorrectly() throws Exception {
for (String prefix : QUERIES) {
PartTree partTree = new PartTree(prefix + "DistinctByText", memberDetails);
assertTrue(partTree.isValid() && partTree.isDistinct());
partTree = new PartTree(prefix + "DistinctTextByText", memberDetails);
assertTrue(partTree.isValid() && partTree.isDistinct());
partTree = new PartTree(prefix + "DistinctTop100TextByText", memberDetails);
assertTrue(partTree.isValid() && partTree.isDistinct());
partTree = new PartTree(prefix + "DistinctFirstByText", memberDetails);
assertTrue(partTree.isValid() && partTree.isDistinct());
partTree = new PartTree(prefix + "DistinctTopTextByText", memberDetails);
assertTrue(partTree.isValid() && partTree.isDistinct());
}
}
use of org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree in project spring-roo by spring-projects.
the class PartTreeUnitTest method validateReturnsTypeDate.
@Test
public void validateReturnsTypeDate() throws Exception {
JavaType dateType = new JavaType(Date.class);
JavaType datePageType = new JavaType("org.springframework.data.domain.Page", 0, DataType.TYPE, null, Arrays.asList(dateType));
assertEquals(datePageType, new PartTree("findDistinctDateByText", memberDetails).getReturnType());
assertEquals(datePageType, new PartTree("findDateByText", memberDetails).getReturnType());
assertEquals(datePageType, new PartTree("findTop2DateByText", memberDetails).getReturnType());
assertEquals(datePageType, new PartTree("findDistinctTop10DateByText", memberDetails).getReturnType());
assertEquals(datePageType, new PartTree("findFirst2DateByText", memberDetails).getReturnType());
assertEquals(dateType, new PartTree("findTopDateByText", memberDetails).getReturnType());
assertEquals(dateType, new PartTree("findFirst1DateByText", memberDetails).getReturnType());
assertEquals(dateType, new PartTree("findDistinctFirstDateByText", memberDetails).getReturnType());
assertEquals(dateType, new PartTree("findDistinctTop1DateByText", memberDetails).getReturnType());
}
use of org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree in project spring-roo by spring-projects.
the class PartTreeUnitTest method validateSeveralParameters.
@Test
public void validateSeveralParameters() throws Exception {
List<FinderParameter> parameters = new ArrayList<FinderParameter>();
parameters.add(new FinderParameter(JavaType.INT_OBJECT, new JavaSymbolName("number1")));
parameters.add(new FinderParameter(JavaType.INT_OBJECT, new JavaSymbolName("number2")));
assertEqualsParameters(parameters, new PartTree("findByNumberBetween", memberDetails).getParameters());
parameters.add(new FinderParameter(JavaType.INT_OBJECT, new JavaSymbolName("number3")));
parameters.add(new FinderParameter(JavaType.INT_OBJECT, new JavaSymbolName("number4")));
assertEqualsParameters(parameters, new PartTree("findByNumberBetweenAndNumberBetween", memberDetails).getParameters());
parameters.add(new FinderParameter(JavaType.INT_OBJECT, new JavaSymbolName("number5")));
assertEqualsParameters(parameters, new PartTree("countByNumberBetweenAndNumberBetweenAndNumberLessThan", memberDetails).getParameters());
}
Aggregations