use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method doesNotConsiderRedeclaredSaveMethodAQueryMethod.
// DATACMNS-151
@Test
public void doesNotConsiderRedeclaredSaveMethodAQueryMethod() throws Exception {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(ConcreteRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, RepositoryComposition.empty());
Method saveMethod = BaseRepository.class.getMethod("save", Object.class);
Method deleteMethod = BaseRepository.class.getMethod("delete", Object.class);
Iterable<Method> queryMethods = information.getQueryMethods();
assertThat(queryMethods).doesNotContain(saveMethod, deleteMethod);
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method discoversCustomlyImplementedCrudMethodWithoutGenericParameters.
// DATACMNS-1008, DATACMNS-912, DATACMNS-854
@Test
public void discoversCustomlyImplementedCrudMethodWithoutGenericParameters() throws Exception {
SimpleSaveRepositoryImpl customImplementation = new SimpleSaveRepositoryImpl();
RepositoryMetadata metadata = new DefaultRepositoryMetadata(SimpleSaveRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, RepositoryFactorySupport.class, RepositoryComposition.just(customImplementation).withMethodLookup(MethodLookups.forRepositoryTypes(metadata)));
Method customBaseRepositoryMethod = SimpleSaveRepository.class.getMethod("save", Object.class);
assertThat(information.isCustomMethod(customBaseRepositoryMethod)).isTrue();
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class DefaultRepositoryInformationUnitTests method detectsQueryMethodCorrectly.
// DATACMNS-193
@Test
public void detectsQueryMethodCorrectly() {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(ConcreteRepository.class);
RepositoryInformation information = new DefaultRepositoryInformation(metadata, CrudRepository.class, RepositoryComposition.empty());
Method queryMethod = getMethodFrom(ConcreteRepository.class, "findBySomethingDifferent");
assertThat(information.getQueryMethods()).contains(queryMethod);
assertThat(information.isQueryMethod(queryMethod)).isTrue();
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-data-commons by spring-projects.
the class EventPublishingRepositoryProxyPostProcessorUnitTests method doesNotAddAdviceIfDomainTypeDoesNotExposeEvents.
// DATACMNS-928
@Test
public void doesNotAddAdviceIfDomainTypeDoesNotExposeEvents() {
RepositoryInformation information = new DummyRepositoryInformation(CrudRepository.class);
RepositoryProxyPostProcessor processor = new EventPublishingRepositoryProxyPostProcessor(publisher);
ProxyFactory factory = mock(ProxyFactory.class);
processor.postProcess(factory, information);
verify(factory, never()).addAdvice(any(Advice.class));
}
use of org.springframework.data.repository.core.RepositoryInformation in project spring-cloud-gcp by spring-cloud.
the class DatastoreRepositoryFactoryTests method getTargetRepositoryTest.
@Test
public void getTargetRepositoryTest() {
RepositoryInformation repoInfo = mock(RepositoryInformation.class);
Mockito.<Class<?>>when(repoInfo.getRepositoryBaseClass()).thenReturn(SimpleDatastoreRepository.class);
Mockito.<Class<?>>when(repoInfo.getDomainType()).thenReturn(TestEntity.class);
Object repo = this.datastoreRepositoryFactory.getTargetRepository(repoInfo);
assertThat(repo.getClass()).isEqualTo(SimpleDatastoreRepository.class);
}
Aggregations