DATAES-46 - Apply code formatting

This commit is contained in:
Mohsin Husen
2015-01-30 17:19:06 +00:00
parent bb62148bb7
commit d92137247f
19 changed files with 130 additions and 140 deletions

View File

@@ -168,11 +168,11 @@ public class NestedObjectTests {
final Map mapping = elasticsearchTemplate.getMapping(PersonMultipleLevelNested.class);
assertThat(mapping,is(notNullValue()));
assertThat(mapping, is(notNullValue()));
final Map propertyMap = (Map) mapping.get("properties");
assertThat(propertyMap,is(notNullValue()));
assertThat(propertyMap, is(notNullValue()));
final Map bestCarsAttributes = (Map) propertyMap.get("bestCars");
assertThat(bestCarsAttributes.get("include_in_parent"),is(notNullValue()));
assertThat(bestCarsAttributes.get("include_in_parent"), is(notNullValue()));
}
@@ -189,11 +189,11 @@ public class NestedObjectTests {
//then
final BoolQueryBuilder builder = boolQuery();
builder.must(nestedQuery("girlFriends", termQuery("girlFriends.type", "temp")))
.must(nestedQuery("girlFriends.cars", termQuery("girlFriends.cars.name", "Ford".toLowerCase())));
.must(nestedQuery("girlFriends.cars", termQuery("girlFriends.cars.name", "Ford".toLowerCase())));
final SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(builder)
.build();
.withQuery(builder)
.build();
final Page<PersonMultipleLevelNested> personIndexed = elasticsearchTemplate.queryForPage(searchQuery, PersonMultipleLevelNested.class);
assertThat(personIndexed, is(notNullValue()));
@@ -375,8 +375,8 @@ public class NestedObjectTests {
elasticsearchTemplate.refresh(Book.class, true);
//then
final SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(nestedQuery("buckets", termQuery("buckets.1", "test3")))
.build();
.withQuery(nestedQuery("buckets", termQuery("buckets.1", "test3")))
.build();
final Page<Book> books = elasticsearchTemplate.queryForPage(searchQuery, Book.class);
assertThat(books.getContent().size(), is(1));

View File

@@ -154,7 +154,7 @@ public class ElasticsearchTemplateCompletionTests {
assertThat(options.size(), is(2));
assertThat(options.get(0).getText().string(), isOneOf("Marchand", "Mohsin Husen"));
assertThat(options.get(1).getText().string(), isOneOf("Marchand", "Mohsin Husen"));
}
}
@Test
public void shouldFindSuggestionsForGivenCriteriaQueryUsingAnnotatedCompletionEntity() {
@@ -171,8 +171,8 @@ public class ElasticsearchTemplateCompletionTests {
//then
assertThat(options.size(), is(2));
assertThat(options.get(0).getText().string(), isOneOf("Marchand","Mohsin Husen"));
assertThat(options.get(1).getText().string(), isOneOf("Marchand","Mohsin Husen"));
assertThat(options.get(0).getText().string(), isOneOf("Marchand", "Mohsin Husen"));
assertThat(options.get(1).getText().string(), isOneOf("Marchand", "Mohsin Husen"));
}
@Test
@@ -193,14 +193,11 @@ public class ElasticsearchTemplateCompletionTests {
for (CompletionSuggestion.Entry.Option option : options) {
if (option.getText().string().equals("Mewes Kochheim1")) {
assertEquals(Double.MAX_VALUE, option.getPayloadAsDouble(), 0);
}
else if (option.getText().string().equals("Mewes Kochheim2")) {
} else if (option.getText().string().equals("Mewes Kochheim2")) {
assertEquals(Long.MAX_VALUE, option.getPayloadAsLong());
}
else if (option.getText().string().equals("Mewes Kochheim3")) {
} else if (option.getText().string().equals("Mewes Kochheim3")) {
assertEquals("Payload test", option.getPayloadAsString());
}
else if (option.getText().string().equals("Mewes Kochheim4")) {
} else if (option.getText().string().equals("Mewes Kochheim4")) {
assertEquals("Payload", option.getPayloadAsMap().get("someField1"));
assertEquals("test", option.getPayloadAsMap().get("someField2"));
} else {
@@ -227,14 +224,11 @@ public class ElasticsearchTemplateCompletionTests {
for (CompletionSuggestion.Entry.Option option : options) {
if (option.getText().string().equals("Mewes Kochheim1")) {
assertEquals(4, option.getScore(), 0);
}
else if (option.getText().string().equals("Mewes Kochheim2")) {
} else if (option.getText().string().equals("Mewes Kochheim2")) {
assertEquals(0, option.getScore(), 0);
}
else if (option.getText().string().equals("Mewes Kochheim3")) {
} else if (option.getText().string().equals("Mewes Kochheim3")) {
assertEquals(1, option.getScore(), 0);
}
else if (option.getText().string().equals("Mewes Kochheim4")) {
} else if (option.getText().string().equals("Mewes Kochheim4")) {
assertEquals(Integer.MAX_VALUE, option.getScore(), 0);
} else {
fail("Unexpected option");

View File

@@ -48,5 +48,4 @@ public class AbstractInheritedEntity {
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
}

View File

@@ -40,7 +40,7 @@ public class Person {
@Field(type = FieldType.Nested)
private List<Car> car;
@Field(type = FieldType.Nested, includeInParent=true)
@Field(type = FieldType.Nested, includeInParent = true)
private List<Book> books;
public String getId() {

View File

@@ -43,7 +43,7 @@ public class PersonMultipleLevelNested {
@Field(type = FieldType.Nested)
private List<Car> cars;
@Field(type = FieldType.Nested, includeInParent=true)
@Field(type = FieldType.Nested, includeInParent = true)
private List<Car> bestCars;
public String getId() {
@@ -85,5 +85,4 @@ public class PersonMultipleLevelNested {
public void setBestCars(List<Car> bestCars) {
this.bestCars = bestCars;
}
}

View File

@@ -37,6 +37,4 @@ public class SampleInheritedEntity extends AbstractInheritedEntity {
public void setMessage(String message) {
this.message = message;
}
}

View File

@@ -495,54 +495,55 @@ public class CustomMethodRepositoryTests {
assertThat(sampleEntities.size(), is(1));
}
@Test
public void shouldExecuteCustomMethodWithGeoPoint() {
// given
String documentId = randomNumeric(5);
SampleEntity sampleEntity = new SampleEntity();
sampleEntity.setId(documentId);
sampleEntity.setType("test");
sampleEntity.setRate(10);
sampleEntity.setMessage("foo");
sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));
@Test
public void shouldExecuteCustomMethodWithGeoPoint() {
// given
String documentId = randomNumeric(5);
SampleEntity sampleEntity = new SampleEntity();
sampleEntity.setId(documentId);
sampleEntity.setType("test");
sampleEntity.setRate(10);
sampleEntity.setMessage("foo");
sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));
repository.save(sampleEntity);
repository.save(sampleEntity);
// when
Page<SampleEntity> page = repository.findByLocation(new GeoPoint(45.7806d, 3.0875d), new PageRequest(0, 10));
// then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
}
@Test
public void shouldExecuteCustomMethodWithGeoPointAndString() {
// given
String documentId = randomNumeric(5);
SampleEntity sampleEntity = new SampleEntity();
sampleEntity.setId(documentId);
sampleEntity.setType("test");
sampleEntity.setRate(10);
sampleEntity.setMessage("foo");
sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));
// when
Page<SampleEntity> page = repository.findByLocation(new GeoPoint(45.7806d, 3.0875d), new PageRequest(0, 10));
// then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
}
repository.save(sampleEntity);
@Test
public void shouldExecuteCustomMethodWithGeoPointAndString() {
// given
String documentId = randomNumeric(5);
SampleEntity sampleEntity = new SampleEntity();
sampleEntity.setId(documentId);
sampleEntity.setType("test");
sampleEntity.setRate(10);
sampleEntity.setMessage("foo");
sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));
documentId = randomNumeric(5);
sampleEntity = new SampleEntity();
sampleEntity.setId(documentId);
sampleEntity.setType("test");
sampleEntity.setRate(10);
sampleEntity.setMessage("foo");
sampleEntity.setLocation(new GeoPoint(48.7806d, 3.0875d));
repository.save(sampleEntity);
repository.save(sampleEntity);
documentId = randomNumeric(5);
sampleEntity = new SampleEntity();
sampleEntity.setId(documentId);
sampleEntity.setType("test");
sampleEntity.setRate(10);
sampleEntity.setMessage("foo");
sampleEntity.setLocation(new GeoPoint(48.7806d, 3.0875d));
// when
Page<SampleEntity> page = repository.findByLocationAndMessage(new GeoPoint(45.7806d, 3.0875d), "foo", new PageRequest(0, 10));
// then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
}
repository.save(sampleEntity);
// when
Page<SampleEntity> page = repository.findByLocationAndMessage(new GeoPoint(45.7806d, 3.0875d), "foo", new PageRequest(0, 10));
// then
assertThat(page, is(notNullValue()));
assertThat(page.getTotalElements(), is(equalTo(1L)));
}
@Test
public void shouldExecuteCustomMethodWithWithinGeoPoint() {
@@ -1173,6 +1174,5 @@ public class CustomMethodRepositoryTests {
// then
assertThat(count, is(equalTo(1L)));
}
}

View File

@@ -75,7 +75,7 @@ public interface SampleCustomMethodRepository extends ElasticsearchRepository<Sa
Page<SampleEntity> findByLocationAndMessage(GeoPoint point, String msg, Pageable pageable);
Page<SampleEntity> findByLocationWithin(GeoPoint point, String distance, Pageable pageable);
Page<SampleEntity> findByLocationWithin(GeoPoint point, String distance, Pageable pageable);
Page<SampleEntity> findByLocationWithin(Point point, Distance distance, Pageable pageable);
@@ -126,5 +126,4 @@ public interface SampleCustomMethodRepository extends ElasticsearchRepository<Sa
long countByLocationNear(Point point, Distance distance);
long countByLocationNear(GeoPoint point, String distance);
}