BAEL-53 - moved to java8 foreach

This commit is contained in:
Slavisa Baeldung 2016-09-20 16:00:07 +02:00
parent 4101ebd609
commit bc8fd9a260
3 changed files with 48 additions and 36 deletions

View File

@ -32,4 +32,18 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -5,6 +5,7 @@ import static org.junit.Assert.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@ -102,13 +103,9 @@ public class ElasticSearchUnitTests {
try {
response2.getHits();
response3.getHits();
SearchHit[] searchHits = response.getHits().getHits();
List<Person> results = new ArrayList<Person>();
for (SearchHit hit : searchHits) {
String sourceAsString = hit.getSourceAsString();
Person person = JSON.parseObject(sourceAsString, Person.class);
results.add(person);
}
List<SearchHit> searchHits = Arrays.asList(response.getHits().getHits());
final List<Person> results = new ArrayList<Person>();
searchHits.forEach(hit -> results.add(JSON.parseObject(hit.getSourceAsString(), Person.class)));
} catch (Exception e) {
isExecutedSuccessfully = false;
}

View File

@ -29,6 +29,7 @@
<module>dozer</module>
<module>dependency-injection</module>
<module>deltaspike</module>
<module>elasticsearch</module>
<module>enterprise-patterns</module>
<module>feign-client</module>