use of org.springframework.roo.classpath.layers.MemberTypeAdditions in project spring-roo by spring-projects.
the class RepositoryJpaLayerProviderTest method testGetAdditionsWhenNoRepositoriesExist.
@Test
public void testGetAdditionsWhenNoRepositoriesExist() {
// Invoke
final MemberTypeAdditions additions = layerProvider.getMemberTypeAdditions(CALLER_MID, FIND_ALL_METHOD.name(), mockTargetEntity, mockIdType);
// Check
assertNull(additions);
}
use of org.springframework.roo.classpath.layers.MemberTypeAdditions in project spring-roo by spring-projects.
the class RepositoryJpaLayerProviderTest method assertMethodCall.
/**
* Asserts that the {@link RepositoryJpaLayerProvider} generates the
* expected call for the given method with the given parameters
*
* @param expectedMethodCall
* @param methodKey
* @param callerParameters
*/
private void assertMethodCall(final String expectedMethodCall, final MethodMetadataCustomDataKey methodKey, final MethodParameter... callerParameters) {
// Set up
setUpMockRepository();
// Invoke
final MemberTypeAdditions additions = layerProvider.getMemberTypeAdditions(CALLER_MID, methodKey.name(), mockTargetEntity, mockIdType, callerParameters);
// Check
assertEquals(expectedMethodCall, additions.getMethodCall());
}
use of org.springframework.roo.classpath.layers.MemberTypeAdditions in project spring-roo by spring-projects.
the class RepositoryJpaLayerProvider method getMethodAdditions.
/**
* Returns the additions that the caller needs to make in order to invoke
* the given method
*
* @param callerMID the caller's metadata ID (required)
* @param method the method being called (required)
* @param repositoryType the type of repository being called
* @param parameterNames the parameter names used by the caller
* @return a non-<code>null</code> set of additions
*/
private MemberTypeAdditions getMethodAdditions(final String callerMID, final RepositoryJpaLayerMethod method, final JavaType repositoryType, final List<MethodParameter> parameters) {
// Create a builder to hold the repository field to be copied into the
// caller
final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(callerMID);
final AnnotationMetadataBuilder autowiredAnnotation = new AnnotationMetadataBuilder(AUTOWIRED);
final String repositoryFieldName = StringUtils.uncapitalize(repositoryType.getSimpleTypeName());
cidBuilder.addField(new FieldMetadataBuilder(callerMID, 0, Arrays.asList(autowiredAnnotation), new JavaSymbolName(repositoryFieldName), repositoryType));
// Create the additions to invoke the given method on this field
final String methodCall = repositoryFieldName + "." + method.getCall(parameters);
return new MemberTypeAdditions(cidBuilder, method.getName(), methodCall, false, parameters);
}
use of org.springframework.roo.classpath.layers.MemberTypeAdditions in project spring-roo by spring-projects.
the class RepositoryJpaLayerProviderTest method testGetAdditionsForNonRepositoryLayerMethod.
@Test
public void testGetAdditionsForNonRepositoryLayerMethod() {
// Invoke
final MemberTypeAdditions additions = layerProvider.getMemberTypeAdditions(CALLER_MID, "bogus", mockTargetEntity, mockIdType);
// Check
assertNull(additions);
}
Aggregations