Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Kevin Gilmore
2016-06-03 07:28:26 -05:00
228 changed files with 8823 additions and 1144 deletions

View File

@@ -93,7 +93,7 @@
<java.version>1.7</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-framework.version>4.2.4.RELEASE</spring-framework.version>
<spring-data-couchbase.version>2.0.0.RELEASE</spring-data-couchbase.version>
<spring-data-couchbase.version>2.1.1.RELEASE</spring-data-couchbase.version>
<hibernate-validator.version>5.2.4.Final</hibernate-validator.version>
<joda-time.version>2.9.2</joda-time.version>
<logback.version>1.1.3</logback.version>

View File

@@ -27,28 +27,20 @@ public abstract class PersonServiceTest extends IntegrationTest {
static final String smith = "Smith";
static final String johnSmithId = "person:" + john + ":" + smith;
static final Person johnSmith = new Person(johnSmithId, john, smith);
static final JsonObject jsonJohnSmith = JsonObject.empty()
.put(typeField, Person.class.getName())
.put("firstName", john)
.put("lastName", smith)
.put("created", DateTime.now().getMillis());
static final JsonObject jsonJohnSmith = JsonObject.empty().put(typeField, Person.class.getName()).put("firstName", john).put("lastName", smith).put("created", DateTime.now().getMillis());
static final String foo = "Foo";
static final String bar = "Bar";
static final String foobarId = "person:" + foo + ":" + bar;
static final Person foobar = new Person(foobarId, foo, bar);
static final JsonObject jsonFooBar = JsonObject.empty()
.put(typeField, Person.class.getName())
.put("firstName", foo)
.put("lastName", bar)
.put("created", DateTime.now().getMillis());
static final JsonObject jsonFooBar = JsonObject.empty().put(typeField, Person.class.getName()).put("firstName", foo).put("lastName", bar).put("created", DateTime.now().getMillis());
PersonService personService;
@BeforeClass
public static void setupBeforeClass() {
Cluster cluster = CouchbaseCluster.create(MyCouchbaseConfig.NODE_LIST);
Bucket bucket = cluster.openBucket(MyCouchbaseConfig.BUCKET_NAME, MyCouchbaseConfig.BUCKET_PASSWORD);
final Cluster cluster = CouchbaseCluster.create(MyCouchbaseConfig.NODE_LIST);
final Bucket bucket = cluster.openBucket(MyCouchbaseConfig.BUCKET_NAME, MyCouchbaseConfig.BUCKET_PASSWORD);
bucket.upsert(JsonDocument.create(johnSmithId, jsonJohnSmith));
bucket.upsert(JsonDocument.create(foobarId, jsonFooBar));
bucket.close();
@@ -57,7 +49,7 @@ public abstract class PersonServiceTest extends IntegrationTest {
@Test
public void whenFindingPersonByJohnSmithId_thenReturnsJohnSmith() {
Person actualPerson = personService.findOne(johnSmithId);
final Person actualPerson = personService.findOne(johnSmithId);
assertNotNull(actualPerson);
assertNotNull(actualPerson.getCreated());
assertEquals(johnSmith, actualPerson);
@@ -65,7 +57,7 @@ public abstract class PersonServiceTest extends IntegrationTest {
@Test
public void whenFindingAllPersons_thenReturnsTwoOrMorePersonsIncludingJohnSmithAndFooBar() {
List<Person> resultList = personService.findAll();
final List<Person> resultList = personService.findAll();
assertNotNull(resultList);
assertFalse(resultList.isEmpty());
assertTrue(resultContains(resultList, johnSmith));
@@ -75,8 +67,8 @@ public abstract class PersonServiceTest extends IntegrationTest {
@Test
public void whenFindingByFirstNameJohn_thenReturnsOnlyPersonsNamedJohn() {
String expectedFirstName = john;
List<Person> resultList = personService.findByFirstName(expectedFirstName);
final String expectedFirstName = john;
final List<Person> resultList = personService.findByFirstName(expectedFirstName);
assertNotNull(resultList);
assertFalse(resultList.isEmpty());
assertTrue(allResultsContainExpectedFirstName(resultList, expectedFirstName));
@@ -84,17 +76,24 @@ public abstract class PersonServiceTest extends IntegrationTest {
@Test
public void whenFindingByLastNameSmith_thenReturnsOnlyPersonsNamedSmith() {
String expectedLastName = smith;
List<Person> resultList = personService.findByLastName(expectedLastName);
final String expectedLastName = smith;
final List<Person> resultList = personService.findByLastName(expectedLastName);
assertNotNull(resultList);
assertFalse(resultList.isEmpty());
assertTrue(allResultsContainExpectedLastName(resultList, expectedLastName));
}
@Test
public void whenFindingByFirstNameJohn_thenReturnsOnePersonNamedJohn() {
final String expectedFirstName = john;
final List<Person> resultList = personService.findByFirstName(expectedFirstName);
assertTrue(resultList.size() == 1);
}
private boolean resultContains(List<Person> resultList, Person person) {
boolean found = false;
for(Person p : resultList) {
if(p.equals(person)) {
for (final Person p : resultList) {
if (p.equals(person)) {
found = true;
break;
}
@@ -104,8 +103,8 @@ public abstract class PersonServiceTest extends IntegrationTest {
private boolean allResultsContainExpectedFirstName(List<Person> resultList, String firstName) {
boolean found = false;
for(Person p : resultList) {
if(p.getFirstName().equals(firstName)) {
for (final Person p : resultList) {
if (p.getFirstName().equals(firstName)) {
found = true;
break;
}
@@ -115,8 +114,8 @@ public abstract class PersonServiceTest extends IntegrationTest {
private boolean allResultsContainExpectedLastName(List<Person> resultList, String lastName) {
boolean found = false;
for(Person p : resultList) {
if(p.getLastName().equals(lastName)) {
for (final Person p : resultList) {
if (p.getLastName().equals(lastName)) {
found = true;
break;
}