use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class Repositories method cacheRepositoryFactory.
@SuppressWarnings({ "rawtypes", "unchecked" })
private synchronized void cacheRepositoryFactory(String name) {
RepositoryFactoryInformation repositoryFactoryInformation = beanFactory.get().getBean(name, RepositoryFactoryInformation.class);
Class<?> domainType = ClassUtils.getUserClass(repositoryFactoryInformation.getRepositoryInformation().getDomainType());
RepositoryInformation information = repositoryFactoryInformation.getRepositoryInformation();
Set<Class<?>> alternativeDomainTypes = information.getAlternativeDomainTypes();
String beanName = BeanFactoryUtils.transformedBeanName(name);
Set<Class<?>> typesToRegister = new HashSet<>(alternativeDomainTypes.size() + 1);
typesToRegister.add(domainType);
typesToRegister.addAll(alternativeDomainTypes);
for (Class<?> type : typesToRegister) {
this.repositoryFactoryInfos.put(type, repositoryFactoryInformation);
this.repositoryBeanNames.put(type, beanName);
}
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class RepositoryFactorySupportUnitTests method rejectsRepositoryBaseClassWithInvalidConstructor.
// DATACMNS-763
@Test
@SuppressWarnings("rawtypes")
public void rejectsRepositoryBaseClassWithInvalidConstructor() {
RepositoryInformation information = mock(RepositoryInformation.class);
doReturn(CustomRepositoryBaseClass.class).when(information).getRepositoryBaseClass();
EntityInformation entityInformation = mock(EntityInformation.class);
exception.expect(IllegalStateException.class);
exception.expectMessage(entityInformation.getClass().getName());
exception.expectMessage(String.class.getName());
factory.getTargetRepositoryViaReflection(information, entityInformation, "Foo");
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class DefaultCrudMethodsUnitTests method getMethodsFor.
private static CrudMethods getMethodsFor(Class<?> repositoryInterface) {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(repositoryInterface);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, PagingAndSortingRepository.class, RepositoryComposition.empty());
return new DefaultCrudMethods(information);
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method usesCorrectSaveOverload.
// DATACMNS-943
@Test
public void usesCorrectSaveOverload() throws Exception {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(DummyRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, DummyRepositoryImpl.class, RepositoryComposition.empty());
Method method = DummyRepository.class.getMethod("saveAll", Iterable.class);
assertThat(information.getTargetClassMethod(method)).isEqualTo(DummyRepositoryImpl.class.getMethod("saveAll", Iterable.class));
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method ignoresStaticMethod.
// DATACMNS-939
@Test
public void ignoresStaticMethod() throws SecurityException, NoSuchMethodException {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(FooRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, RepositoryComposition.just(customImplementation));
Method method = FooRepository.class.getMethod("staticMethod");
assertThat(information.getQueryMethods()).doesNotContain(method);
}
Aggregations