Search in sources :

Example 1 with LrsActor

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);
}
Also used : LrsActor(org.apereo.portal.events.tincan.om.LrsActor) LocalizedString(org.apereo.portal.events.tincan.om.LocalizedString) Test(org.junit.Test)

Example 2 with LrsActor

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);
}
Also used : Locale(java.util.Locale) UrnBuilder(org.apereo.portal.events.tincan.UrnBuilder) LrsObject(org.apereo.portal.events.tincan.om.LrsObject) LrsActor(org.apereo.portal.events.tincan.om.LrsActor) LrsStatement(org.apereo.portal.events.tincan.om.LrsStatement) LocalizedString(org.apereo.portal.events.tincan.om.LocalizedString) LocalizedString(org.apereo.portal.events.tincan.om.LocalizedString) URI(java.net.URI) Test(org.junit.Test)

Example 3 with LrsActor

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;
}
Also used : IPersonAttributes(org.jasig.services.persondir.IPersonAttributes) Element(net.sf.ehcache.Element) LrsActor(org.apereo.portal.events.tincan.om.LrsActor)

Aggregations

LrsActor (org.apereo.portal.events.tincan.om.LrsActor)3 LocalizedString (org.apereo.portal.events.tincan.om.LocalizedString)2 Test (org.junit.Test)2 URI (java.net.URI)1 Locale (java.util.Locale)1 Element (net.sf.ehcache.Element)1 UrnBuilder (org.apereo.portal.events.tincan.UrnBuilder)1 LrsObject (org.apereo.portal.events.tincan.om.LrsObject)1 LrsStatement (org.apereo.portal.events.tincan.om.LrsStatement)1 IPersonAttributes (org.jasig.services.persondir.IPersonAttributes)1