Author: jasha
Date: Sat Jul  7 21:04:56 2012
New Revision: 1358642

URL: http://svn.apache.org/viewvc?rev=1358642&view=rev
Log:
RAVE-703 Missing JpaPersonProperties in JpaPerson. Only return the fields that 
were requested.

Modified:
    
rave/trunk/rave-components/rave-jpa/src/main/java/org/apache/rave/portal/model/JpaPerson.java
    
rave/trunk/rave-components/rave-jpa/src/test/java/org/apache/rave/portal/repository/impl/JpaPersonRepositoryTest.java
    rave/trunk/rave-components/rave-jpa/src/test/resources/test_data.sql
    
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/main/java/org/apache/rave/opensocial/service/impl/FieldRestrictingPerson.java
    
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/test/java/org/apache/rave/opensocial/service/FieldRestrictingPersonTest.java
    
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/test/java/org/apache/rave/opensocial/service/PersonServiceTest.java

Modified: 
rave/trunk/rave-components/rave-jpa/src/main/java/org/apache/rave/portal/model/JpaPerson.java
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-jpa/src/main/java/org/apache/rave/portal/model/JpaPerson.java?rev=1358642&r1=1358641&r2=1358642&view=diff
==============================================================================
--- 
rave/trunk/rave-components/rave-jpa/src/main/java/org/apache/rave/portal/model/JpaPerson.java
 (original)
+++ 
rave/trunk/rave-components/rave-jpa/src/main/java/org/apache/rave/portal/model/JpaPerson.java
 Sat Jul  7 21:04:56 2012
@@ -16,12 +16,31 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.rave.portal.model;
 
 import org.apache.rave.persistence.BasicEntity;
 import org.apache.rave.portal.model.conversion.ConvertingListProxyFactory;
 
-import javax.persistence.*;
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -106,7 +125,7 @@ public class JpaPerson implements BasicE
     @JoinColumn(name="person_id", referencedColumnName = "entity_id")
     protected List<JpaOrganization> organizations;
 
-    @OneToMany(targetEntity = JpaPersonProperty.class)
+    @OneToMany(fetch = FetchType.EAGER, targetEntity = JpaPersonProperty.class)
     @JoinColumn(name = "person_id", referencedColumnName = "entity_id")
     protected List<JpaPersonProperty> properties;
 

Modified: 
rave/trunk/rave-components/rave-jpa/src/test/java/org/apache/rave/portal/repository/impl/JpaPersonRepositoryTest.java
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-jpa/src/test/java/org/apache/rave/portal/repository/impl/JpaPersonRepositoryTest.java?rev=1358642&r1=1358641&r2=1358642&view=diff
==============================================================================
--- 
rave/trunk/rave-components/rave-jpa/src/test/java/org/apache/rave/portal/repository/impl/JpaPersonRepositoryTest.java
 (original)
+++ 
rave/trunk/rave-components/rave-jpa/src/test/java/org/apache/rave/portal/repository/impl/JpaPersonRepositoryTest.java
 Sat Jul  7 21:04:56 2012
@@ -21,9 +21,7 @@ package org.apache.rave.portal.repositor
 
 import org.apache.rave.exception.NotSupportedException;
 import org.apache.rave.portal.model.JpaPerson;
-import org.apache.rave.portal.model.JpaWidgetComment;
 import org.apache.rave.portal.model.Person;
-import org.apache.rave.portal.model.WidgetComment;
 import org.apache.rave.portal.model.impl.PersonImpl;
 import org.apache.rave.portal.repository.PersonRepository;
 import org.junit.Test;
@@ -38,8 +36,11 @@ import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
 import java.util.List;
 
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 
@@ -224,5 +225,11 @@ public class JpaPersonRepositoryTest {
         person = repository.get(VALID_ID);
         assertThat(person, is(nullValue()));
     }
+    
+    @Test
+    public void read_properties() {
+        Person person = repository.get(VALID_ID);
+       assertThat(person.getProperties().size(), is(1)); 
+    }
 
 }

Modified: rave/trunk/rave-components/rave-jpa/src/test/resources/test_data.sql
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-jpa/src/test/resources/test_data.sql?rev=1358642&r1=1358641&r2=1358642&view=diff
==============================================================================
--- rave/trunk/rave-components/rave-jpa/src/test/resources/test_data.sql 
(original)
+++ rave/trunk/rave-components/rave-jpa/src/test/resources/test_data.sql Sat 
Jul  7 21:04:56 2012
@@ -48,6 +48,7 @@ set @person_seq = 'person';
 set @person_association_seq = 'person_association';
 set @groups_seq = 'groups';
 set @group_members_seq = 'group_members';
+set @person_properties_seq = 'person_properties';
 
 CREATE TABLE IF NOT EXISTS RAVE_PORTAL_SEQUENCES (seq_name VARCHAR(255) 
PRIMARY KEY NOT NULL, seq_count BIGINT(19));
 INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values (@page_seq, 1);
@@ -71,6 +72,7 @@ INSERT INTO RAVE_PORTAL_SEQUENCES(seq_na
 INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values 
(@person_association_seq, 1);
 INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values (@groups_seq, 1);
 INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values 
(@group_members_seq, 1);
+INSERT INTO RAVE_PORTAL_SEQUENCES(seq_name, seq_count) values 
(@person_properties_seq, 1);
 
 CREATE TABLE IF NOT EXISTS RAVE_SHINDIG_SEQUENCES (seq_name VARCHAR(255) 
PRIMARY KEY NOT NULL, seq_count BIGINT(19));
 INSERT INTO RAVE_SHINDIG_SEQUENCES(seq_name, seq_count) values 
(@token_info_seq, 1);
@@ -1259,3 +1261,8 @@ VALUES (@group_id_1, @user_id_1);
 
 INSERT INTO group_members(group_id, person_id)
 VALUES (@group_id_1, @user_id_5);
+
+set @next_person_property = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE 
seq_name = @person_properties_seq);
+INSERT INTO person_property(entity_id, type, value, person_id)
+VALUES (@next_person_property, 'foo', 'bar', @user_id_1);
+UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = 
@person_properties_seq;

Modified: 
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/main/java/org/apache/rave/opensocial/service/impl/FieldRestrictingPerson.java
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/main/java/org/apache/rave/opensocial/service/impl/FieldRestrictingPerson.java?rev=1358642&r1=1358641&r2=1358642&view=diff
==============================================================================
--- 
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/main/java/org/apache/rave/opensocial/service/impl/FieldRestrictingPerson.java
 (original)
+++ 
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/main/java/org/apache/rave/opensocial/service/impl/FieldRestrictingPerson.java
 Sat Jul  7 21:04:56 2012
@@ -20,21 +20,38 @@
 package org.apache.rave.opensocial.service.impl;
 
 import org.apache.rave.exception.NotSupportedException;
-import org.apache.rave.portal.model.*;
+import org.apache.rave.portal.model.PersonProperty;
 import org.apache.rave.portal.model.util.ModelUtils;
 import org.apache.rave.util.CollectionUtils;
 import org.apache.shindig.protocol.model.Enum;
 import org.apache.shindig.protocol.model.EnumImpl;
-import org.apache.shindig.social.core.model.*;
+import org.apache.shindig.social.core.model.AccountImpl;
 import org.apache.shindig.social.core.model.AddressImpl;
-import org.apache.shindig.social.opensocial.model.*;
+import org.apache.shindig.social.core.model.BodyTypeImpl;
+import org.apache.shindig.social.core.model.ListFieldImpl;
+import org.apache.shindig.social.core.model.NameImpl;
+import org.apache.shindig.social.core.model.UrlImpl;
+import org.apache.shindig.social.opensocial.model.Account;
 import org.apache.shindig.social.opensocial.model.Address;
+import org.apache.shindig.social.opensocial.model.BodyType;
+import org.apache.shindig.social.opensocial.model.Drinker;
+import org.apache.shindig.social.opensocial.model.ListField;
+import org.apache.shindig.social.opensocial.model.LookingFor;
+import org.apache.shindig.social.opensocial.model.Name;
+import org.apache.shindig.social.opensocial.model.NetworkPresence;
 import org.apache.shindig.social.opensocial.model.Organization;
+import org.apache.shindig.social.opensocial.model.Smoker;
+import org.apache.shindig.social.opensocial.model.Url;
 
 import java.io.Serializable;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import static org.apache.rave.util.CollectionUtils.getSingleValue;
 
@@ -43,9 +60,9 @@ import static org.apache.rave.util.Colle
  * the field set contains the requested field
  * <p/>
  * Usage of this wrapper is made possible by Shindig's use of a getter based 
serialization model
- *
+ * <p/>
  * NOTE: Setters will throw a {@link NotSupportedException} as Shindig's SPI 
has no method for persisting changes to
- *       a person.
+ * a person.
  */
 public class FieldRestrictingPerson implements 
org.apache.shindig.social.opensocial.model.Person, Serializable {
 
@@ -87,7 +104,7 @@ public class FieldRestrictingPerson impl
 
     @Override
     public List<Account> getAccounts() {
-        if(displayField(Field.ACCOUNTS)) {
+        if (displayField(Field.ACCOUNTS)) {
             List<PersonProperty> properties = 
getFromProperties(Field.ACCOUNTS);
             return convertAccounts(properties);
         }
@@ -154,8 +171,8 @@ public class FieldRestrictingPerson impl
     @Override
     public BodyType getBodyType() {
         BodyType type = null;
-        if(displayField(Field.BODY_TYPE)) {
-            Map<String,String> map = 
mapValuesByQualifier(getFromProperties(Field.BODY_TYPE));
+        if (displayField(Field.BODY_TYPE)) {
+            Map<String, String> map = 
mapValuesByQualifier(getFromProperties(Field.BODY_TYPE));
             type = new BodyTypeImpl();
             type.setBuild(map.get("build"));
             type.setEyeColor(map.get("eyeColor"));
@@ -204,16 +221,17 @@ public class FieldRestrictingPerson impl
     /**
      * Since addresses are stored as a first class relation to the Rave 
person, the simplest way to set current location
      * is to store a pointer in the properties to the qualifier for the 
address in the list.
-     *
+     * <p/>
      * NOTE: This requires that the qualifier be set on all addresses
+     *
      * @return a valid address if the qualifier is found; null otherwise
      */
     @Override
     public Address getCurrentLocation() {
         String qualifier = 
getSingleValueFromProperties(Field.CURRENT_LOCATION);
-        if(qualifier != null) {
-            for(org.apache.rave.portal.model.Address address : 
internal.getAddresses()) {
-                if(qualifier.equals(address.getQualifier())) {
+        if (qualifier != null) {
+            for (org.apache.rave.portal.model.Address address : 
internal.getAddresses()) {
+                if (qualifier.equals(address.getQualifier())) {
                     return convertAddress(address);
                 }
             }
@@ -239,9 +257,12 @@ public class FieldRestrictingPerson impl
 
     @Override
     public List<ListField> getEmails() {
+        if (!displayField(Field.EMAILS)) {
+            return null;
+        }
         List<ListField> fields = getListFromProperties(Field.EMAILS);
         //Override primary value as we will set a new primary with the 
registered address
-        for(ListField field : fields) {
+        for (ListField field : fields) {
             field.setPrimary(false);
         }
         //Set the e-mail used to register with Rave as the "primary" address
@@ -412,7 +433,7 @@ public class FieldRestrictingPerson impl
 
     @Override
     public List<org.apache.shindig.protocol.model.Enum<LookingFor>> 
getLookingFor() {
-        return getEnumsFromValues(getValuesFromProperties(Field.LOOKING_FOR));
+        return displayField(Field.LOOKING_FOR) ? 
getEnumsFromValues(getValuesFromProperties(Field.LOOKING_FOR)) : null;
     }
 
     @Override
@@ -704,9 +725,12 @@ public class FieldRestrictingPerson impl
 
     @Override
     public List<Url> getUrls() {
+        if (!displayField(Field.URLS)) {
+            return null;
+        }
         List<PersonProperty> properties = getFromProperties(Field.URLS);
         List<Url> urls = new ArrayList<Url>();
-        for(PersonProperty property : properties) {
+        for (PersonProperty property : properties) {
             urls.add(convertToUrl(property));
         }
         return urls;
@@ -759,7 +783,7 @@ public class FieldRestrictingPerson impl
 
     private String getSingleValueFromProperties(Field field) {
         List<String> values = getValuesFromProperties(field);
-        return CollectionUtils.getSingleValue(values);
+        return values == null ? null : CollectionUtils.getSingleValue(values);
     }
 
     private boolean displayField(Field field) {
@@ -773,16 +797,16 @@ public class FieldRestrictingPerson impl
     }
 
     private List<String> getValuesFromProperties(Field field) {
-        return displayField(field) ? toValueList(getFromProperties(field)) : 
new ArrayList<String>();
+        return displayField(field) ? toValueList(getFromProperties(field)) : 
null;
     }
 
     private List<ListField> getListFromProperties(Field field) {
-        return displayField(field) ? 
convertFromProperties(getFromProperties(field)) : new ArrayList<ListField>();
+        return displayField(field) ? 
convertFromProperties(getFromProperties(field)) : null;
     }
 
     private static List<ListField> convertFromProperties(List<PersonProperty> 
properties) {
         List<ListField> fieldList = new ArrayList<ListField>();
-        for(PersonProperty property: properties) {
+        for (PersonProperty property : properties) {
             ListField field = new ListFieldImpl(property.getQualifier(), 
property.getValue());
             field.setPrimary(property.getPrimary());
             fieldList.add(field);
@@ -818,7 +842,7 @@ public class FieldRestrictingPerson impl
 
     private static Map<String, String> 
mapValuesByQualifier(List<PersonProperty> properties) {
         Map<String, String> propertyMap = new HashMap<String, String>();
-        for(PersonProperty property : properties) {
+        for (PersonProperty property : properties) {
             propertyMap.put(property.getQualifier(), property.getValue());
         }
         return propertyMap;
@@ -830,8 +854,8 @@ public class FieldRestrictingPerson impl
 
     private List<Address> 
convertAddresses(List<org.apache.rave.portal.model.Address> addresses) {
         List<Address> converted = new ArrayList<Address>();
-        if(addresses != null) {
-            for(org.apache.rave.portal.model.Address address : addresses) {
+        if (addresses != null) {
+            for (org.apache.rave.portal.model.Address address : addresses) {
                 converted.add(convertAddress(address));
             }
         }
@@ -855,10 +879,10 @@ public class FieldRestrictingPerson impl
 
     private static Map<String, List<PersonProperty>> 
createPropertyMap(List<PersonProperty> properties) {
         Map<String, List<PersonProperty>> map = new HashMap<String, 
List<PersonProperty>>();
-        for(PersonProperty property : properties) {
+        for (PersonProperty property : properties) {
             List<PersonProperty> propertyList;
             String fieldType = property.getType();
-            if(map.containsKey(fieldType)) {
+            if (map.containsKey(fieldType)) {
                 propertyList = map.get(fieldType);
             } else {
                 propertyList = new ArrayList<PersonProperty>();
@@ -871,7 +895,7 @@ public class FieldRestrictingPerson impl
 
     private static List<Account> convertAccounts(List<PersonProperty> 
properties) {
         List<Account> accounts = new ArrayList<Account>();
-        for(PersonProperty property : properties) {
+        for (PersonProperty property : properties) {
             Account account = convertToAccount(property);
             accounts.add(account);
         }
@@ -888,8 +912,8 @@ public class FieldRestrictingPerson impl
 
     private List<Organization> 
convertOrganizations(List<org.apache.rave.portal.model.Organization> 
organizations) {
         List<Organization> converted = new ArrayList<Organization>();
-        if(organizations != null) {
-            for(org.apache.rave.portal.model.Organization org : organizations) 
{
+        if (organizations != null) {
+            for (org.apache.rave.portal.model.Organization org : 
organizations) {
                 converted.add(convertOrganization(org));
             }
         }

Modified: 
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/test/java/org/apache/rave/opensocial/service/FieldRestrictingPersonTest.java
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/test/java/org/apache/rave/opensocial/service/FieldRestrictingPersonTest.java?rev=1358642&r1=1358641&r2=1358642&view=diff
==============================================================================
--- 
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/test/java/org/apache/rave/opensocial/service/FieldRestrictingPersonTest.java
 (original)
+++ 
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/test/java/org/apache/rave/opensocial/service/FieldRestrictingPersonTest.java
 Sat Jul  7 21:04:56 2012
@@ -30,14 +30,26 @@ import org.apache.rave.portal.model.util
 import org.apache.shindig.protocol.model.EnumImpl;
 import org.apache.shindig.social.core.model.BodyTypeImpl;
 import org.apache.shindig.social.core.model.UrlImpl;
-import org.apache.shindig.social.opensocial.model.*;
+import org.apache.shindig.social.opensocial.model.Account;
+import org.apache.shindig.social.opensocial.model.Address;
+import org.apache.shindig.social.opensocial.model.Drinker;
+import org.apache.shindig.social.opensocial.model.ListField;
+import org.apache.shindig.social.opensocial.model.LookingFor;
+import org.apache.shindig.social.opensocial.model.NetworkPresence;
+import org.apache.shindig.social.opensocial.model.Person;
 import org.junit.Test;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.*;
-
-import static org.hamcrest.CoreMatchers.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 
@@ -156,7 +168,7 @@ public class FieldRestrictingPersonTest 
     @Test
     public void getActivities_notset() {
         Person p = new FieldRestrictingPerson(getTestPerson(), 
getFieldSet(Person.Field.AGE, Person.Field.BOOKS));
-        assertThat(p.getActivities().isEmpty(), is(true));
+        assertThat(p.getActivities(), is(nullValue()));
     }
     @Test
     public void getBooks_set() {

Modified: 
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/test/java/org/apache/rave/opensocial/service/PersonServiceTest.java
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/test/java/org/apache/rave/opensocial/service/PersonServiceTest.java?rev=1358642&r1=1358641&r2=1358642&view=diff
==============================================================================
--- 
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/test/java/org/apache/rave/opensocial/service/PersonServiceTest.java
 (original)
+++ 
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/test/java/org/apache/rave/opensocial/service/PersonServiceTest.java
 Sat Jul  7 21:04:56 2012
@@ -23,7 +23,9 @@ import com.google.common.collect.Lists;
 import org.apache.rave.opensocial.repository.OpenSocialPersonRepository;
 import org.apache.rave.opensocial.service.impl.DefaultPersonService;
 import org.apache.rave.opensocial.service.impl.FieldRestrictingPerson;
+import org.apache.rave.portal.model.PersonProperty;
 import org.apache.rave.portal.model.impl.PersonImpl;
+import org.apache.rave.portal.model.impl.PersonPropertyImpl;
 import org.apache.shindig.auth.SecurityToken;
 import org.apache.shindig.protocol.ProtocolException;
 import org.apache.shindig.protocol.RestfulCollection;
@@ -34,22 +36,29 @@ import org.apache.shindig.social.opensoc
 import org.apache.shindig.social.opensocial.spi.PersonService;
 import org.apache.shindig.social.opensocial.spi.UserId;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 
-import static org.easymock.EasyMock.*;
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.CoreMatchers.not;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
 import static org.junit.Assert.assertThat;
 
 public class PersonServiceTest {
 
+    private static final String TAG = "foo";
     private static final String DISPLAY_NAME = "ABCDE";
     private static final String HAPPIEST_WHEN = "Sleeping";
     private static final String ID_2 = "1235";
@@ -68,19 +77,19 @@ public class PersonServiceTest {
     }
 
     @Test
-    @Ignore
     public void getPerson_allFields() throws ExecutionException, 
InterruptedException {
         UserId id = new UserId(UserId.Type.userId, ID_1);
         Set<String> fields = new HashSet<String>();
 
-        org.apache.rave.portal.model.Person dbPerson = getDbPerson();
+        org.apache.rave.portal.model.Person dbPerson = getDbPerson(ID_1);
         expect(repository.findByUsername(ID_1)).andReturn(dbPerson);
         replay(repository);
 
         Future<Person> personFuture = service.getPerson(id, fields, token);
-        assertThat(personFuture, is(not(nullValue())));
+        assertThat(personFuture, is(notNullValue()));
         Person person = personFuture.get();
-        assertThat(person, is(not(nullValue())));
+        assertThat(person, is(notNullValue()));
+        assertThat(person.getTags().size(), is(1));
         assertThat(person, is(instanceOf(FieldRestrictingPerson.class)));
         assertThat(person.getId(), is(equalTo(ID_1)));
         assertThat(person.getHappiestWhen(), is(equalTo(HAPPIEST_WHEN)));
@@ -99,9 +108,9 @@ public class PersonServiceTest {
         replay(repository);
 
         Future<Person> personFuture = service.getPerson(id, fields, token);
-        assertThat(personFuture, is(not(nullValue())));
+        assertThat(personFuture, is(notNullValue()));
         Person person = personFuture.get();
-        assertThat(person, is(not(nullValue())));
+        assertThat(person, is(notNullValue()));
         assertThat(person, is(instanceOf(FieldRestrictingPerson.class)));
         assertThat(person.getId(), is(equalTo(ID_1)));
         assertThat(person.getHappiestWhen(), is(nullValue()));
@@ -109,18 +118,17 @@ public class PersonServiceTest {
     }
 
     @Test
-    @Ignore
     public void getPerson_nullFields() throws ExecutionException, 
InterruptedException {
         UserId id = new UserId(UserId.Type.userId, ID_1);
 
-        org.apache.rave.portal.model.Person dbPerson = getDbPerson();
+        org.apache.rave.portal.model.Person dbPerson = getDbPerson(ID_1);
         expect(repository.findByUsername(ID_1)).andReturn(dbPerson);
         replay(repository);
 
         Future<Person> personFuture = service.getPerson(id, null, token);
-        assertThat(personFuture, is(not(nullValue())));
+        assertThat(personFuture, is(notNullValue()));
         Person person = personFuture.get();
-        assertThat(person, is(not(nullValue())));
+        assertThat(personFuture, is(notNullValue()));
         assertThat(person, is(instanceOf(FieldRestrictingPerson.class)));
         assertThat(person.getId(), is(equalTo(ID_1)));
         assertThat(person.getHappiestWhen(), is(equalTo(HAPPIEST_WHEN)));
@@ -128,21 +136,20 @@ public class PersonServiceTest {
     }
 
     @Test
-    @Ignore
     public void getPerson_viewer() throws ExecutionException, 
InterruptedException {
         UserId id = new UserId(UserId.Type.viewer, ID_2);
 
         expect(token.getViewerId()).andReturn(ID_1);
         replay(token);
 
-        org.apache.rave.portal.model.Person dbPerson = getDbPerson();
+        org.apache.rave.portal.model.Person dbPerson = getDbPerson(ID_1);
         expect(repository.findByUsername(ID_1)).andReturn(dbPerson);
         replay(repository);
 
         Future<Person> personFuture = service.getPerson(id, null, token);
-        assertThat(personFuture, is(not(nullValue())));
+        assertThat(personFuture, is(notNullValue()));
         Person person = personFuture.get();
-        assertThat(person, is(not(nullValue())));
+        assertThat(person, is(notNullValue()));
         assertThat(person, is(instanceOf(FieldRestrictingPerson.class)));
         assertThat(person.getId(), is(equalTo(ID_1)));
         assertThat(person.getHappiestWhen(), is(equalTo(HAPPIEST_WHEN)));
@@ -172,13 +179,12 @@ public class PersonServiceTest {
         replay(repository);
 
         Future<RestfulCollection<Person>> people = service.getPeople(ids, 
groupId, null, null, token);
-        assertThat(people, is(not(nullValue())));
+        assertThat(people, is(notNullValue()));
         assertThat(people.get().getTotalResults(), is(equalTo(1)));
         assertThat(people.get().getList().get(0).getId(), is(equalTo(self)));
     }
 
     @Test
-    @Ignore
     public void getPeople_all() throws ExecutionException, 
InterruptedException {
         Set<UserId> ids = getUserIdSet();
         GroupId groupId = new GroupId(GroupId.Type.all, GROUP_ID);
@@ -186,10 +192,12 @@ public class PersonServiceTest {
 
         
expect(repository.findAllConnectedPeople(ID_2)).andReturn(getDbPersonList());
         
expect(repository.findAllConnectedPeople(ID_3)).andReturn(getDbPersonList());
+        expect(repository.findByUsername(ID_2)).andReturn(getDbPerson(ID_2));
+        expect(repository.findByUsername(ID_3)).andReturn(getDbPerson(ID_3));
         replay(repository);
 
         Future<RestfulCollection<Person>> people = service.getPeople(ids, 
groupId, null, null, token);
-        assertThat(people, is(not(nullValue())));
+        assertThat(people, is(notNullValue()));
         assertThat(people.get().getList().get(0), 
is(instanceOf(FieldRestrictingPerson.class)));
         assertThat(hasUniqueValues(people), is(true));
         verify(repository);
@@ -209,7 +217,7 @@ public class PersonServiceTest {
         replay(repository);
 
         Future<RestfulCollection<Person>> people = service.getPeople(ids, 
groupId, null, null, token);
-        assertThat(people, is(not(nullValue())));
+        assertThat(people, is(notNullValue()));
         assertThat(people.get().getList().get(0), 
is(instanceOf(FieldRestrictingPerson.class)));
         assertThat(hasUniqueValues(people), is(true));
         verify(repository);
@@ -224,7 +232,7 @@ public class PersonServiceTest {
         replay(repository);
 
         Future<RestfulCollection<Person>> people = service.getPeople(ids, 
groupId, null, null, token);
-        assertThat(people, is(not(nullValue())));
+        assertThat(people, is(notNullValue()));
         assertThat(people.get().getList().get(0), 
is(instanceOf(FieldRestrictingPerson.class)));
         assertThat(hasUniqueValues(people), is(true));
         verify(repository);
@@ -247,7 +255,7 @@ public class PersonServiceTest {
         replay(repository);
 
         Future<RestfulCollection<Person>> people = service.getPeople(ids, 
groupId, options, null, token);
-        assertThat(people, is(not(nullValue())));
+        assertThat(people, is(notNullValue()));
         verify(repository);
     }
 
@@ -272,7 +280,7 @@ public class PersonServiceTest {
         replay(repository);
 
         Future<RestfulCollection<Person>> people = service.getPeople(ids, 
groupId, options, null, token);
-        assertThat(people, is(not(nullValue())));
+        assertThat(people, is(notNullValue()));
         verify(repository);
     }
 
@@ -296,7 +304,7 @@ public class PersonServiceTest {
         replay(repository);
 
         Future<RestfulCollection<Person>> people = service.getPeople(ids, 
groupId, options, null, token);
-        assertThat(people, is(not(nullValue())));
+        assertThat(people, is(notNullValue()));
         verify(repository);
     }
 
@@ -320,7 +328,7 @@ public class PersonServiceTest {
         replay(repository);
 
         Future<RestfulCollection<Person>> people = service.getPeople(ids, 
groupId, options, null, token);
-        assertThat(people, is(not(nullValue())));
+        assertThat(people, is(notNullValue()));
         verify(repository);
     }
 
@@ -344,7 +352,7 @@ public class PersonServiceTest {
         replay(repository);
 
         Future<RestfulCollection<Person>> people = service.getPeople(ids, 
groupId, options, null, token);
-        assertThat(people, is(not(nullValue())));
+        assertThat(people, is(notNullValue()));
         verify(repository);
     }
 
@@ -368,7 +376,7 @@ public class PersonServiceTest {
         replay(repository);
 
         Future<RestfulCollection<Person>> people = service.getPeople(ids, 
groupId, options, null, token);
-        assertThat(people, is(not(nullValue())));
+        assertThat(people, is(notNullValue()));
         verify(repository);
     }
 
@@ -388,7 +396,7 @@ public class PersonServiceTest {
         replay(repository);
 
         Future<RestfulCollection<Person>> people = service.getPeople(ids, 
groupId, options, null, token);
-        assertThat(people, is(not(nullValue())));
+        assertThat(people, is(notNullValue()));
         verify(repository);
     }
 
@@ -413,7 +421,7 @@ public class PersonServiceTest {
         replay(repository);
 
         Future<RestfulCollection<Person>> people = service.getPeople(ids, 
groupId, options, null, token);
-        assertThat(people, is(not(nullValue())));
+        assertThat(people, is(notNullValue()));
         verify(repository);
     }
 
@@ -438,7 +446,7 @@ public class PersonServiceTest {
         replay(repository);
 
         Future<RestfulCollection<Person>> people = service.getPeople(ids, 
groupId, options, null, token);
-        assertThat(people, is(not(nullValue())));
+        assertThat(people, is(notNullValue()));
         verify(repository);
     }
 
@@ -459,7 +467,7 @@ public class PersonServiceTest {
         replay(repository);
 
         Future<RestfulCollection<Person>> people = service.getPeople(ids, 
groupId, options, null, token);
-        assertThat(people, is(not(nullValue())));
+        assertThat(people, is(notNullValue()));
         verify(repository);
     }
 
@@ -499,6 +507,10 @@ public class PersonServiceTest {
         PersonImpl dbPerson = new PersonImpl();
         dbPerson.setUsername(id);
         dbPerson.setDisplayName(DISPLAY_NAME);
+        List<PersonProperty> properties = new ArrayList<PersonProperty>();
+        properties.add(new PersonPropertyImpl(1L, 
Person.Field.TAGS.toString(), TAG, null, null, null));
+        properties.add(new PersonPropertyImpl(2L, 
Person.Field.HAPPIEST_WHEN.toString(), HAPPIEST_WHEN, null, null, null));
+        dbPerson.setProperties(properties);
         return dbPerson;
     }
 


Reply via email to