Search in sources :

Example 1 with MessageSignature

use of org.opencastproject.messages.MessageSignature in project opencast by opencast.

the class MessageSignatureDto method toMessageSignature.

/**
 * Returns the business object of this message signature
 *
 * @return the business object model of this message signature
 */
public MessageSignature toMessageSignature(UserDirectoryService userDirectoryService) {
    final Option<EmailAddress> reply;
    if (replyTo != null && replyToName != null) {
        reply = some(new EmailAddress(replyTo, replyToName));
    } else {
        reply = none();
    }
    User user = userDirectoryService.loadUser(creator);
    return new MessageSignature(id, name, user, new EmailAddress(sender, senderName), reply, signature, creationDate);
}
Also used : User(org.opencastproject.security.api.User) MessageSignature(org.opencastproject.messages.MessageSignature) EmailAddress(org.opencastproject.kernel.mail.EmailAddress)

Example 2 with MessageSignature

use of org.opencastproject.messages.MessageSignature in project opencast by opencast.

the class UserSettingsTest method toJsonInputSettingAndSignatureExpectedAllInJson.

@Test
public void toJsonInputSettingAndSignatureExpectedAllInJson() throws Exception {
    InputStream stream = SeriesEndpointTest.class.getResourceAsStream("/user_settings_test_example.json");
    InputStreamReader reader = new InputStreamReader(stream);
    JSONObject expected = (JSONObject) new JSONParser().parse(reader);
    User creator = EasyMock.createMock(User.class);
    EasyMock.expect(creator.getName()).andReturn("Users Name").anyTimes();
    EasyMock.expect(creator.getUsername()).andReturn("username12").anyTimes();
    EasyMock.expect(creator.getEmail()).andReturn("adam@fake.com").anyTimes();
    EasyMock.replay(creator);
    EmailAddress sender = new EmailAddress("adam@fake.com", "Other Name");
    Option<EmailAddress> replyTo = none();
    DateTime dateTime = new DateTime(1401465634101L);
    dateTime.toDateTime(DateTimeZone.UTC);
    // MessageSignature messageSignature = new MessageSignature(10L, "Adam McKenzie", creator, sender, replyTo,
    // "This is the signature", dateTime.toDate(), nil(Comment.class));
    Collection<MessageSignature> signatures = new LinkedList<MessageSignature>();
    // signatures.add(messageSignature);
    UserSetting userSetting = new UserSetting(98, "Test Key", "Test Value");
    UserSettings userSettings = new UserSettings();
    userSettings.setTotal(1);
    userSettings.addUserSetting(userSetting);
    assertThat(expected.toJSONString(), SameJSONAs.sameJSONAs(userSettings.toJson().toJson()));
}
Also used : User(org.opencastproject.security.api.User) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) EmailAddress(org.opencastproject.kernel.mail.EmailAddress) DateTime(org.joda.time.DateTime) LinkedList(java.util.LinkedList) JSONObject(org.json.simple.JSONObject) JSONParser(org.json.simple.parser.JSONParser) MessageSignature(org.opencastproject.messages.MessageSignature) SeriesEndpointTest(org.opencastproject.adminui.endpoint.SeriesEndpointTest) Test(org.junit.Test)

Aggregations

EmailAddress (org.opencastproject.kernel.mail.EmailAddress)2 MessageSignature (org.opencastproject.messages.MessageSignature)2 User (org.opencastproject.security.api.User)2 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 LinkedList (java.util.LinkedList)1 DateTime (org.joda.time.DateTime)1 JSONObject (org.json.simple.JSONObject)1 JSONParser (org.json.simple.parser.JSONParser)1 Test (org.junit.Test)1 SeriesEndpointTest (org.opencastproject.adminui.endpoint.SeriesEndpointTest)1