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);
}
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()));
}
Aggregations