@Test
public void insert_loggable_log() {
final String testKey = "message";
final String testValue = "hello world";
ActivityDto log = ActivityDto.createFor(new ActivityLog() {
@Override
public Map<String, String> getDetails() {
return ImmutableMap.of(testKey, testValue);
}
@Override
public String getAction() {
return "myAction";
}
})
.setAuthor("jUnit")
.setType(Activity.Type.QPROFILE);
dao.insert(session, log);
ActivityDto newDto = Iterables.getFirst(dao.findAll(session), null);
assertThat(newDto).isNotNull();
assertThat(newDto.getAuthor()).isEqualTo(log.getAuthor());
assertThat(newDto.getData()).isNotNull();
Map<String, String> details = KeyValueFormat.parse(newDto.getData());
assertThat(details.get(testKey)).isEqualTo(testValue);
}