use of org.apereo.portal.events.tincan.UrnBuilder 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.UrnBuilder in project uPortal by Jasig.
the class AbstractPortalEventToLrsStatementConverter method buildUrn.
/**
* Build the URN for the LrsStatement. This method attaches creates the base URN. Additional
* elements can be attached.
*
* @param parts Additional URN elements.
* @return The formatted URI
*/
protected URI buildUrn(String... parts) {
UrnBuilder builder = new UrnBuilder("UTF-8", "tincan", "uportal", "activities");
builder.add(parts);
return builder.getUri();
}
use of org.apereo.portal.events.tincan.UrnBuilder in project uPortal by Jasig.
the class LrsDataModelSerializeTest method testLrsObjectSerialize.
@Test
public void testLrsObjectSerialize() throws Exception {
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 String result = this.objectMapper.writeValueAsString(lrsObject);
assertEquals("{\"id\":\"urn:tincan:uportal:activities:portlet:fname\",\"objectType\":\"Activity\",\"definition\":{\"name\":{\"en-US\":\"Portlet Name\"},\"description\":{\"en-US\":\"Portlet Description\"}}}", result);
}
Aggregations