DATAGEODE-4 - Adapt to API changes in repository interfaces.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.client;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -82,7 +82,6 @@ public class GemFireDataSourceIntegrationTests extends ClientServerIntegrationTe
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unused")
|
||||
public void gemfireServerDataSourceCreated() {
|
||||
Pool pool = applicationContext.getBean("gemfirePool", Pool.class);
|
||||
|
||||
@@ -108,7 +107,7 @@ public class GemFireDataSourceIntegrationTests extends ClientServerIntegrationTe
|
||||
|
||||
assertThat(repository.save(daveMathews)).isSameAs(daveMathews);
|
||||
|
||||
Optional<Person> result = repository.findOne(1L);
|
||||
Optional<Person> result = repository.findById(1L);
|
||||
|
||||
assertThat(result.isPresent()).isTrue();
|
||||
assertThat(result.get().getFirstname()).isEqualTo("Dave");
|
||||
|
||||
@@ -49,7 +49,7 @@ public class RepositoryClient {
|
||||
}
|
||||
|
||||
public Person find(Long id) {
|
||||
return getPersonRepository().findOne(id).orElse(null);
|
||||
return getPersonRepository().findById(id).orElse(null);
|
||||
}
|
||||
|
||||
public Person save(Person person) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.data.gemfire.repository.sample;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -72,7 +72,7 @@ public class AnimalRepositoryTest {
|
||||
assertThat(catRepo.count()).isEqualTo(3L);
|
||||
assertThat(dogRepo.count()).isEqualTo(2L);
|
||||
|
||||
Optional<Animal> foundFelix = catRepo.findOne(1L);
|
||||
Optional<Animal> foundFelix = catRepo.findById(1L);
|
||||
|
||||
assertThat(foundFelix.isPresent()).isTrue();
|
||||
assertThat(foundFelix.get()).isEqualTo(felix);
|
||||
@@ -85,7 +85,7 @@ public class AnimalRepositoryTest {
|
||||
|
||||
assertThat(foundCerberusTheCat).isEqualTo(cerberus);
|
||||
assertThat(catRepo.findBy("Cerberus")).isEqualTo(foundCerberusTheCat);
|
||||
assertThat(catRepo.findOne(3L).orElse(null)).isEqualTo(foundCerberusTheCat);
|
||||
assertThat(catRepo.findById(3L).orElse(null)).isEqualTo(foundCerberusTheCat);
|
||||
|
||||
Animal foundFido = dogRepo.findBy("Fido");
|
||||
|
||||
@@ -95,6 +95,6 @@ public class AnimalRepositoryTest {
|
||||
|
||||
assertThat(foundCerberusTheDog).isEqualTo(cerberus);
|
||||
assertThat(dogRepo.findBy("Cerberus")).isEqualTo(foundCerberusTheDog);
|
||||
assertThat(dogRepo.findOne(3L).orElse(null)).isEqualTo(foundCerberusTheDog);
|
||||
assertThat(dogRepo.findById(3L).orElse(null)).isEqualTo(foundCerberusTheDog);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,7 @@
|
||||
package org.springframework.data.gemfire.repository.sample;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -207,7 +204,7 @@ public class SubRegionRepositoryIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void testSubregionRepositoryInteractions() {
|
||||
assertThat(programmersRepo.findOne("JamesGosling").orElse(null)).isEqualTo(PROGRAMMER_USER_DATA.get("JamesGosling"));
|
||||
assertThat(programmersRepo.findById("JamesGosling").orElse(null)).isEqualTo(PROGRAMMER_USER_DATA.get("JamesGosling"));
|
||||
|
||||
List<Programmer> javaProgrammers = programmersRepo.findDistinctByProgrammingLanguageOrderByUsernameAsc("Java");
|
||||
|
||||
@@ -256,8 +253,8 @@ public class SubRegionRepositoryIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void testIdenticallyNamedSubregionDataAccess() {
|
||||
assertThat(adminUserRepo.findOne("supertool").orElse(null)).isEqualTo(getAdminUser("supertool"));
|
||||
assertThat(guestUserRepo.findOne("joeblow").orElse(null)).isEqualTo(getGuestUser("joeblow"));
|
||||
assertThat(adminUserRepo.findById("supertool").orElse(null)).isEqualTo(getAdminUser("supertool"));
|
||||
assertThat(guestUserRepo.findById("joeblow").orElse(null)).isEqualTo(getGuestUser("joeblow"));
|
||||
|
||||
List<RootUser> rootUsers = adminUserRepo.findDistinctByUsername("zeus");
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.data.gemfire.repository.support;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -97,7 +97,7 @@ public class SimpleGemfireRepositoryIntegrationTests {
|
||||
template.put(carter.getId(), carter);
|
||||
template.put(leroi.getId(), leroi);
|
||||
|
||||
Collection<Person> result = repository.findAll(Arrays.asList(carter.getId(), leroi.getId()));
|
||||
Collection<Person> result = repository.findAllById(Arrays.asList(carter.getId(), leroi.getId()));
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.size()).isEqualTo(2);
|
||||
@@ -106,7 +106,7 @@ public class SimpleGemfireRepositoryIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void findAllWithIdsReturnsNoMatches() {
|
||||
Collection<Person> results = repository.findAll(Arrays.asList(1L, 2L));
|
||||
Collection<Person> results = repository.findAllById(Arrays.asList(1L, 2L));
|
||||
|
||||
assertThat(results).isNotNull();
|
||||
assertThat(results).isEmpty();
|
||||
@@ -121,7 +121,7 @@ public class SimpleGemfireRepositoryIntegrationTests {
|
||||
template.put(kurt.getId(), kurt);
|
||||
template.put(eddie.getId(), eddie);
|
||||
|
||||
Collection<Person> results = repository.findAll(Arrays.asList(0L, 1L, 2L, 4L));
|
||||
Collection<Person> results = repository.findAllById(Arrays.asList(0L, 1L, 2L, 4L));
|
||||
|
||||
assertThat(results).isNotNull();
|
||||
assertThat(results).hasSize(2);
|
||||
@@ -148,13 +148,13 @@ public class SimpleGemfireRepositoryIntegrationTests {
|
||||
|
||||
assertThat(repository.save(oliverGierke)).isEqualTo(oliverGierke);
|
||||
assertThat(repository.count()).isEqualTo(1L);
|
||||
assertThat(repository.findOne(oliverGierke.getId()).orElse(null)).isEqualTo(oliverGierke);
|
||||
assertThat(repository.findById(oliverGierke.getId()).orElse(null)).isEqualTo(oliverGierke);
|
||||
assertThat(repository.findAll()).isEqualTo(Collections.singletonList(oliverGierke));
|
||||
|
||||
repository.delete(oliverGierke);
|
||||
|
||||
assertThat(repository.count()).isEqualTo(0L);
|
||||
assertThat(repository.findOne(oliverGierke.getId()).orElse(null)).isNull();
|
||||
assertThat(repository.findById(oliverGierke.getId()).orElse(null)).isNull();
|
||||
assertThat(repository.findAll()).isEmpty();
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ public class SimpleGemfireRepositoryIntegrationTests {
|
||||
Person jonBloom = new Person(2L, "Jon", "Bloom");
|
||||
Person juanBlume = new Person(3L, "Juan", "Blume");
|
||||
|
||||
repository.save(Arrays.asList(johnBlum, jonBloom, juanBlume));
|
||||
repository.saveAll(Arrays.asList(johnBlum, jonBloom, juanBlume));
|
||||
|
||||
assertThat(template.getRegion().size()).isEqualTo(3);
|
||||
assertThat(template.<Long, Person>get(johnBlum.getId())).isEqualTo(johnBlum);
|
||||
|
||||
@@ -16,10 +16,7 @@
|
||||
|
||||
package org.springframework.data.gemfire.repository.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
@@ -152,7 +149,7 @@ public class SimpleGemfireRepositoryTransactionalIntegrationTest {
|
||||
public void saveAll(final Iterable<Customer> customers) {
|
||||
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override protected void doInTransactionWithoutResult(final TransactionStatus status) {
|
||||
customerRepository.save(customers);
|
||||
customerRepository.saveAll(customers);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,19 +16,11 @@
|
||||
|
||||
package org.springframework.data.gemfire.repository.support;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -38,7 +30,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Function;
|
||||
@@ -120,21 +111,21 @@ public class SimpleGemfireRepositoryUnitTests {
|
||||
protected EntityInformation<Animal, Long> mockEntityInformation() {
|
||||
EntityInformation<Animal, Long> mockEntityInformation = mock(EntityInformation.class);
|
||||
|
||||
doAnswer(new Answer<Optional<Long>>() {
|
||||
doAnswer(new Answer<Long>() {
|
||||
private final AtomicLong idSequence = new AtomicLong(0L);
|
||||
|
||||
@Override
|
||||
public Optional<Long> answer(InvocationOnMock invocation) throws Throwable {
|
||||
public Long answer(InvocationOnMock invocation) throws Throwable {
|
||||
Animal argument = invocation.getArgument(0);
|
||||
argument.setId(resolveId(argument.getId()));
|
||||
return Optional.of(argument.getId());
|
||||
return argument.getId();
|
||||
|
||||
}
|
||||
|
||||
private Long resolveId(Long id) {
|
||||
return (id != null ? id : idSequence.incrementAndGet());
|
||||
}
|
||||
}).when(mockEntityInformation).getId(any(Animal.class));
|
||||
}).when(mockEntityInformation).getRequiredId(any(Animal.class));
|
||||
|
||||
return mockEntityInformation;
|
||||
}
|
||||
@@ -213,7 +204,7 @@ public class SimpleGemfireRepositoryUnitTests {
|
||||
SimpleGemfireRepository<Animal, Long> repository =
|
||||
new SimpleGemfireRepository<>(newGemfireTemplate(mockRegion), mockEntityInformation());
|
||||
|
||||
Iterable<Animal> savedAnimals = repository.save(animals);
|
||||
Iterable<Animal> savedAnimals = repository.saveAll(animals);
|
||||
|
||||
assertThat(savedAnimals).isNotNull();
|
||||
|
||||
@@ -267,8 +258,8 @@ public class SimpleGemfireRepositoryUnitTests {
|
||||
SimpleGemfireRepository<Animal, Long> repository =
|
||||
new SimpleGemfireRepository<>(newGemfireTemplate(mockRegion), mockEntityInformation());
|
||||
|
||||
assertThat(repository.exists(1L)).isTrue();
|
||||
assertThat(repository.exists(10L)).isFalse();
|
||||
assertThat(repository.existsById(1L)).isTrue();
|
||||
assertThat(repository.existsById(10L)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -283,8 +274,8 @@ public class SimpleGemfireRepositoryUnitTests {
|
||||
SimpleGemfireRepository<Animal, Long> repository =
|
||||
new SimpleGemfireRepository<>(newGemfireTemplate(mockRegion), mockEntityInformation());
|
||||
|
||||
assertThat(repository.findOne(1L).orElse(null)).isEqualTo(dog);
|
||||
assertThat(repository.findOne(10L).isPresent()).isFalse();
|
||||
assertThat(repository.findById(1L).orElse(null)).isEqualTo(dog);
|
||||
assertThat(repository.findById(10L).isPresent()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -305,7 +296,7 @@ public class SimpleGemfireRepositoryUnitTests {
|
||||
SimpleGemfireRepository<Animal, Long> repository = new SimpleGemfireRepository<>(
|
||||
newGemfireTemplate(mockRegion), mockEntityInformation());
|
||||
|
||||
Collection<Animal> animalsFound = repository.findAll(Arrays.asList(1L, 3L));
|
||||
Collection<Animal> animalsFound = repository.findAllById(Arrays.asList(1L, 3L));
|
||||
|
||||
assertThat(animalsFound).isNotNull();
|
||||
assertThat(animalsFound).hasSize(2);
|
||||
@@ -332,7 +323,7 @@ public class SimpleGemfireRepositoryUnitTests {
|
||||
SimpleGemfireRepository<Animal, Long> repository =
|
||||
new SimpleGemfireRepository<>(newGemfireTemplate(mockRegion), mockEntityInformation());
|
||||
|
||||
Collection<Animal> animalsFound = repository.findAll(Arrays.asList(1L, 2L, 3L));
|
||||
Collection<Animal> animalsFound = repository.findAllById(Arrays.asList(1L, 2L, 3L));
|
||||
|
||||
assertThat(animalsFound).isNotNull();
|
||||
assertThat(animalsFound).isEmpty();
|
||||
@@ -362,7 +353,7 @@ public class SimpleGemfireRepositoryUnitTests {
|
||||
SimpleGemfireRepository<Animal, Long> repository =
|
||||
new SimpleGemfireRepository<>(newGemfireTemplate(mockRegion), mockEntityInformation());
|
||||
|
||||
Collection<Animal> animalsFound = repository.findAll(Arrays.asList(0L, 1L, 2L, 4L));
|
||||
Collection<Animal> animalsFound = repository.findAllById(Arrays.asList(0L, 1L, 2L, 4L));
|
||||
|
||||
assertThat(animalsFound).isNotNull();
|
||||
assertThat(animalsFound).hasSize(2);
|
||||
@@ -378,7 +369,7 @@ public class SimpleGemfireRepositoryUnitTests {
|
||||
SimpleGemfireRepository<Animal, Long> repository =
|
||||
new SimpleGemfireRepository<>(newGemfireTemplate(mockRegion), mockEntityInformation());
|
||||
|
||||
repository.delete(1L);
|
||||
repository.deleteById(1L);
|
||||
|
||||
verify(mockRegion, times(1)).remove(eq(1L));
|
||||
}
|
||||
@@ -402,7 +393,7 @@ public class SimpleGemfireRepositoryUnitTests {
|
||||
SimpleGemfireRepository<Animal, Long> repository =
|
||||
new SimpleGemfireRepository<>(newGemfireTemplate(mockRegion), mockEntityInformation());
|
||||
|
||||
repository.delete(Arrays.asList(newAnimal(1L, "bird"), newAnimal(2L, "cat"),
|
||||
repository.deleteAll(Arrays.asList(newAnimal(1L, "bird"), newAnimal(2L, "cat"),
|
||||
newAnimal(3L, "dog")));
|
||||
|
||||
verify(mockRegion, times(1)).remove(eq(1L));
|
||||
|
||||
Reference in New Issue
Block a user