use of org.apereo.portal.events.tincan.om.LrsActor in project uPortal by Jasig.
the class LrsDataModelSerializeTest method testLrsActorSerialize.
@Test
public void testLrsActorSerialize() throws Exception {
final LrsActor lrsActor = new LrsActor("user@example.com", "John Doe");
final String result = this.objectMapper.writeValueAsString(lrsActor);
assertEquals("{\"mbox\":\"user@example.com\",\"name\":\"John Doe\",\"objectType\":\"Agent\"}", result);
}
use of org.apereo.portal.events.tincan.om.LrsActor in project uPortal by Jasig.
the class LrsDataModelSerializeTest method testLrsStatementSerialize.
@Test
public void testLrsStatementSerialize() throws Exception {
final LrsActor lrsActor = new LrsActor("user@example.com", "John Doe");
final UrnBuilder idBuilder = new UrnBuilder("UTF-8", "tincan", "uportal", "activities", "portlet", "fname");
final URI id = idBuilder.getUri();
final LrsObject lrsObject = new LrsObject(id, "Activity", ImmutableMap.of("name", new LocalizedString(new Locale("en", "us"), "Portlet Name"), "description", new LocalizedString(new Locale("en", "us"), "Portlet Description")));
final LrsStatement lrsStatement = new LrsStatement(lrsActor, LrsVerb.INITIALIZED, lrsObject);
final String result = this.objectMapper.writeValueAsString(lrsStatement);
assertEquals("{\"actor\":{\"mbox\":\"user@example.com\",\"name\":\"John Doe\",\"objectType\":\"Agent\"},\"verb\":{\"id\":\"http://adlnet.gov/expapi/verbs/initialized\",\"display\":{\"en-us\":\"initialized\"}},\"object\":{\"id\":\"urn:tincan:uportal:activities:portlet:fname\",\"objectType\":\"Activity\",\"definition\":{\"name\":{\"en-US\":\"Portlet Name\"},\"description\":{\"en-US\":\"Portlet Description\"}}}}", result);
}
use of org.apereo.portal.events.tincan.om.LrsActor in project uPortal by Jasig.
the class LrsActorService method getLrsActor.
@Override
public LrsActor getLrsActor(String userName) {
Element element = this.lrsActorCache.get(userName);
if (element != null) {
return (LrsActor) element.getObjectValue();
}
final String email;
final String name;
final IPersonAttributes person = personAttributeDao.getPerson(userName);
if (person == null) {
email = userName;
name = userName + "@example.com";
} else {
email = getEmail(person);
name = getName(person);
}
final LrsActor lrsActor = new LrsActor("mailto:" + email, name);
this.lrsActorCache.put(new Element(userName, lrsActor));
return lrsActor;
}
Aggregations