cleanup format

This commit is contained in:
DOHA 2016-06-01 19:57:34 +02:00
parent 55c43d5801
commit 882a9b5d50
1 changed files with 19 additions and 27 deletions

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,17 @@ 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));
}
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 +96,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 +107,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;
}