Skip to content

Commit 8666c68

Browse files
committed
DATAGEODE-387 - Polishing.
Reorder methods according to interface order. Revert import ordering changes. Original pull request: #45.
1 parent cff7581 commit 8666c68

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

spring-data-geode/src/main/java/org/springframework/data/gemfire/repository/support/SimpleGemfireRepository.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,21 @@ public Optional<T> findById(@NonNull ID id) {
285285
return Optional.ofNullable(value);
286286
}
287287

288+
@Override
289+
public void deleteById(@NonNull ID id) {
290+
getTemplate().remove(id);
291+
}
292+
288293
@Override
289294
public void delete(@NonNull T entity) {
290295
deleteById(getEntityInformation().getRequiredId(entity));
291296
}
292297

298+
@Override
299+
public void deleteAllById(@NonNull Iterable<? extends ID> ids) {
300+
CollectionUtils.nullSafeIterable(ids).forEach(this::deleteById);
301+
}
302+
293303
@Override
294304
public void deleteAll() {
295305

@@ -311,16 +321,6 @@ public void deleteAll(@NonNull Iterable<? extends T> entities) {
311321
CollectionUtils.nullSafeIterable(entities).forEach(this::delete);
312322
}
313323

314-
@Override
315-
public void deleteAllById(Iterable<? extends ID> ids) {
316-
CollectionUtils.nullSafeIterable(ids).forEach(this::deleteById);
317-
}
318-
319-
@Override
320-
public void deleteById(@NonNull ID id) {
321-
getTemplate().remove(id);
322-
}
323-
324324
boolean isPartitioned(Region<?, ?> region) {
325325

326326
return region != null

spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/support/SimpleGemfireRepositoryIntegrationTests.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,24 @@
1515
*/
1616
package org.springframework.data.gemfire.repository.support;
1717

18-
import static java.util.Arrays.*;
19-
import static org.assertj.core.api.Assertions.*;
18+
import static org.assertj.core.api.Assertions.assertThat;
2019

20+
import java.util.Arrays;
2121
import java.util.Collections;
2222
import java.util.List;
2323

2424
import javax.annotation.Resource;
2525

26+
import org.junit.Before;
27+
import org.junit.Test;
28+
import org.junit.runner.RunWith;
29+
2630
import org.apache.geode.cache.GemFireCache;
2731
import org.apache.geode.cache.Region;
2832
import org.apache.geode.cache.RegionEvent;
2933
import org.apache.geode.cache.query.SelectResults;
3034
import org.apache.geode.cache.util.CacheListenerAdapter;
31-
import org.junit.Before;
32-
import org.junit.Test;
33-
import org.junit.runner.RunWith;
35+
3436
import org.springframework.beans.factory.annotation.Autowired;
3537
import org.springframework.context.annotation.Bean;
3638
import org.springframework.data.domain.Page;
@@ -111,7 +113,7 @@ public void findAllPaged() {
111113

112114
assertThat(this.repository.count()).isEqualTo(0);
113115

114-
List<Person> people = asList(new Person(1L, "Jon", "Doe"), new Person(2L, "Jane", "Doe"),
116+
List<Person> people = Arrays.asList(new Person(1L, "Jon", "Doe"), new Person(2L, "Jane", "Doe"),
115117
new Person(3L, "Cookie", "Doe"), new Person(4L, "Pie", "Doe"), new Person(5L, "Sour", "Doe"));
116118

117119
people.forEach(person -> this.template.put(person.getId(), person));
@@ -156,17 +158,17 @@ public void findAllWithIds() {
156158
this.template.put(carter.getId(), carter);
157159
this.template.put(leroi.getId(), leroi);
158160

159-
Iterable<Person> result = this.repository.findAllById(asList(carter.getId(), leroi.getId()));
161+
Iterable<Person> result = this.repository.findAllById(Arrays.asList(carter.getId(), leroi.getId()));
160162

161163
assertThat(result).isNotNull();
162164
assertThat(result).hasSize(2);
163-
assertThat(result).containsAll(asList(carter, leroi));
165+
assertThat(result).containsAll(Arrays.asList(carter, leroi));
164166
}
165167

166168
@Test
167169
public void findAllWithIdsReturnsNoMatches() {
168170

169-
Iterable<Person> results = this.repository.findAllById(asList(1L, 2L));
171+
Iterable<Person> results = this.repository.findAllById(Arrays.asList(1L, 2L));
170172

171173
assertThat(results).isNotNull();
172174
assertThat(results).isEmpty();
@@ -182,7 +184,7 @@ public void findAllWithIdsReturnsPartialMatches() {
182184
this.template.put(kurt.getId(), kurt);
183185
this.template.put(eddie.getId(), eddie);
184186

185-
Iterable<Person> results = this.repository.findAllById(asList(0L, 1L, 2L, 4L));
187+
Iterable<Person> results = this.repository.findAllById(Arrays.asList(0L, 1L, 2L, 4L));
186188

187189
assertThat(results).isNotNull();
188190
assertThat(results).hasSize(2);
@@ -226,14 +228,14 @@ public void deleteAllById() {
226228

227229
assertThat(this.repository.count()).isEqualTo(0);
228230

229-
List<Person> people = asList(new Person(1L, "Jon", "Doe"), new Person(2L, "Jane", "Doe"),
231+
List<Person> people = Arrays.asList(new Person(1L, "Jon", "Doe"), new Person(2L, "Jane", "Doe"),
230232
new Person(3L, "Cookie", "Doe"), new Person(4L, "Pie", "Doe"), new Person(5L, "Sour", "Doe"));
231233

232234
people.forEach(person -> this.template.put(person.getId(), person));
233235

234236
assertThat(this.repository.count()).isEqualTo(5);
235237

236-
this.repository.deleteAllById(asList(1L, 2L));
238+
this.repository.deleteAllById(Arrays.asList(1L, 2L));
237239

238240
assertThat(this.repository.count()).isEqualTo(3L);
239241
assertThat(this.repository.findAll()) //
@@ -250,7 +252,7 @@ public void saveEntities() {
250252
Person jonBloom = new Person(2L, "Jon", "Bloom");
251253
Person juanBlume = new Person(3L, "Juan", "Blume");
252254

253-
this.repository.saveAll(asList(johnBlum, jonBloom, juanBlume));
255+
this.repository.saveAll(Arrays.asList(johnBlum, jonBloom, juanBlume));
254256

255257
assertThat(this.template.getRegion().size()).isEqualTo(3);
256258
assertThat((Person) this.template.get(johnBlum.getId())).isEqualTo(johnBlum);

0 commit comments

Comments
 (0)