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