Search in sources :

Example 16 with PartTree

use of org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree in project spring-roo by spring-projects.

the class PartTreeUnitTest method identifiesFindFirstImplicit.

@Test
public void identifiesFindFirstImplicit() {
    PartTree partTree = new PartTree("findFirstByText", memberDetails);
    assertTrue(partTree.isValid() && partTree.getMaxResults() == 1);
    partTree = new PartTree("findTopByText", memberDetails);
    assertTrue(partTree.isValid() && partTree.getMaxResults() == 1);
}
Also used : PartTree(org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree) Test(org.junit.Test)

Example 17 with PartTree

use of org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree in project spring-roo by spring-projects.

the class PartTreeUnitTest method validateInParameters.

@Test
public void validateInParameters() throws Exception {
    List<FinderParameter> parameters = new ArrayList<FinderParameter>();
    parameters.add(new FinderParameter(new JavaType(List.class.getName(), 0, DataType.TYPE, null, Arrays.asList(new JavaType(Date.class.getName()))), new JavaSymbolName("dateList")));
    assertEqualsParameters(parameters, new PartTree("findByDateIn", memberDetails).getParameters());
}
Also used : JavaType(org.springframework.roo.model.JavaType) JavaSymbolName(org.springframework.roo.model.JavaSymbolName) FinderParameter(org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.FinderParameter) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) PartTree(org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree) Date(java.util.Date) Test(org.junit.Test)

Example 18 with PartTree

use of org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree in project spring-roo by spring-projects.

the class PartTreeUnitTest method test.

private void test(String prefix, String[] result) {
    List<String> options = new PartTree(prefix, memberDetails).getOptions();
    assertEqualsList(generateOptions(prefix, result), options);
}
Also used : PartTree(org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree)

Example 19 with PartTree

use of org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree in project spring-roo by spring-projects.

the class PartTreeUnitTest method validateReturnsTypeString.

@Test
public void validateReturnsTypeString() throws Exception {
    JavaType stringPageType = new JavaType("org.springframework.data.domain.Page", 0, DataType.TYPE, null, Arrays.asList(JavaType.STRING));
    assertEquals(stringPageType, new PartTree("findDistinctTextByText", memberDetails).getReturnType());
    assertEquals(stringPageType, new PartTree("findTextByText", memberDetails).getReturnType());
    assertEquals(stringPageType, new PartTree("findTop2TextByText", memberDetails).getReturnType());
    assertEquals(stringPageType, new PartTree("findDistinctTop10TextByText", memberDetails).getReturnType());
    assertEquals(stringPageType, new PartTree("findFirst2TextByText", memberDetails).getReturnType());
    assertEquals(JavaType.STRING, new PartTree("findTopTextByText", memberDetails).getReturnType());
    assertEquals(JavaType.STRING, new PartTree("findFirst1TextByText", memberDetails).getReturnType());
    assertEquals(JavaType.STRING, new PartTree("findDistinctFirstTextByText", memberDetails).getReturnType());
    assertEquals(JavaType.STRING, new PartTree("findDistinctTop1TextByText", memberDetails).getReturnType());
}
Also used : JavaType(org.springframework.roo.model.JavaType) PartTree(org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree) Test(org.junit.Test)

Example 20 with PartTree

use of org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree in project spring-roo by spring-projects.

the class PartTreeUnitTest method validateReturnsTypePrimitiveInteger.

@Test
public void validateReturnsTypePrimitiveInteger() throws Exception {
    JavaType intPageType = new JavaType("org.springframework.data.domain.Page", 0, DataType.TYPE, null, Arrays.asList(JavaType.INT_OBJECT));
    assertEquals(intPageType, new PartTree("findDistinctPrimitiveIntByText", memberDetails).getReturnType());
    assertEquals(intPageType, new PartTree("findPrimitiveIntByText", memberDetails).getReturnType());
    assertEquals(intPageType, new PartTree("findTop2PrimitiveIntByText", memberDetails).getReturnType());
    assertEquals(intPageType, new PartTree("findDistinctTop10PrimitiveIntByText", memberDetails).getReturnType());
    assertEquals(intPageType, new PartTree("findFirst2PrimitiveIntByText", memberDetails).getReturnType());
    assertEquals(JavaType.INT_PRIMITIVE, new PartTree("findTopPrimitiveIntByText", memberDetails).getReturnType());
    assertEquals(JavaType.INT_PRIMITIVE, new PartTree("findFirst1PrimitiveIntByText", memberDetails).getReturnType());
    assertEquals(JavaType.INT_PRIMITIVE, new PartTree("findDistinctFirstPrimitiveIntByText", memberDetails).getReturnType());
    assertEquals(JavaType.INT_PRIMITIVE, new PartTree("findDistinctTop1PrimitiveIntByText", memberDetails).getReturnType());
}
Also used : JavaType(org.springframework.roo.model.JavaType) PartTree(org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree) Test(org.junit.Test)

Aggregations

PartTree (org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.PartTree)26 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)10 JavaType (org.springframework.roo.model.JavaType)10 JavaSymbolName (org.springframework.roo.model.JavaSymbolName)8 FinderParameter (org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.FinderParameter)6 ClassOrInterfaceTypeDetails (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)6 List (java.util.List)4 MemberDetails (org.springframework.roo.classpath.scanner.MemberDetails)4 RooJavaType (org.springframework.roo.model.RooJavaType)4 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 JpaEntityMetadata (org.springframework.roo.addon.jpa.addon.entity.JpaEntityMetadata)3 FieldMetadata (org.springframework.roo.classpath.details.FieldMetadata)3 AnnotationMetadata (org.springframework.roo.classpath.details.annotations.AnnotationMetadata)3 Pair (org.apache.commons.lang3.tuple.Pair)2 RepositoryJpaMetadata (org.springframework.roo.addon.layers.repository.jpa.addon.RepositoryJpaMetadata)2 FinderMethod (org.springframework.roo.addon.layers.repository.jpa.addon.finder.parser.FinderMethod)2 MethodMetadata (org.springframework.roo.classpath.details.MethodMetadata)2 NestedAnnotationAttributeValue (org.springframework.roo.classpath.details.annotations.NestedAnnotationAttributeValue)2