SGF-609 - Adapt to changes in the Spring Data Commons API.

This commit is contained in:
John Blum
2017-03-31 12:33:21 -07:00
parent 4a46ee4c9c
commit 1a3909e948
9 changed files with 40 additions and 27 deletions

View File

@@ -182,10 +182,9 @@ public class CompoundCachePutCacheEvictIntegrationTests {
@Bean
GemfireRepositoryFactoryBean<PersonRepository, Person, Long> personRepository() {
GemfireRepositoryFactoryBean<PersonRepository, Person, Long> personRepository =
new GemfireRepositoryFactoryBean<PersonRepository, Person, Long>();
new GemfireRepositoryFactoryBean<>(PersonRepository.class);
personRepository.setGemfireMappingContext(new GemfireMappingContext());
personRepository.setRepositoryInterface(PersonRepository.class);
return personRepository;
}

View File

@@ -55,12 +55,11 @@ public class GemfireRepositoryFactoryBeanTest {
@Before
public void setup() {
repositoryFactoryBean = new GemfireRepositoryFactoryBean();
repositoryFactoryBean = new GemfireRepositoryFactoryBean<>(PersonRepository.class);
}
@Test
public void rejectsMappingContextNotSet() {
exception.expect(IllegalStateException.class);
exception.expectMessage("GemfireMappingContext");
@@ -70,19 +69,21 @@ public class GemfireRepositoryFactoryBeanTest {
@Test
@SuppressWarnings("unchecked")
public void initializesWithMappingContext() {
RegionAttributes<?, ?> mockRegionAttributes = mock(RegionAttributes.class);
RegionAttributes<?, ?> attributes = mock(RegionAttributes.class);
doReturn(Long.class).when(attributes).getKeyConstraint();
doReturn(Long.class).when(mockRegionAttributes).getKeyConstraint();
Region<?, ?> region = mock(Region.class);
doReturn("simple").when(region).getName();
doReturn(attributes).when(region).getAttributes();
Region<?, ?> mockRegion = mock(Region.class);
ApplicationContext applicationContext = mock(ApplicationContext.class);
doReturn(Collections.singletonMap("simple", region)).when(applicationContext).getBeansOfType(Region.class);
doReturn("simple").when(mockRegion).getName();
doReturn(mockRegionAttributes).when(mockRegion).getAttributes();
repositoryFactoryBean.setApplicationContext(applicationContext);
repositoryFactoryBean.setRepositoryInterface(PersonRepository.class);
ApplicationContext mockApplicationContext = mock(ApplicationContext.class);
doReturn(Collections.singletonMap("simple", mockRegion))
.when(mockApplicationContext).getBeansOfType(Region.class);
repositoryFactoryBean.setApplicationContext(mockApplicationContext);
repositoryFactoryBean.setGemfireMappingContext(new GemfireMappingContext());
repositoryFactoryBean.afterPropertiesSet();