1 package org.unitedfront2.domain.communication;
2
3 import java.util.HashMap;
4 import java.util.Locale;
5 import java.util.Map;
6
7 import org.junit.Assert;
8 import org.junit.Test;
9 import org.springframework.beans.factory.annotation.Autowired;
10 import org.unitedfront2.domain.accesscontrol.OwnerOnly;
11 import org.unitedfront2.domain.accesscontrol.Public;
12 import org.unitedfront2.test.TransactionalTestCaseWithInitialData;
13
14 public class BlogEntryTableTest extends TransactionalTestCaseWithInitialData {
15
16 @Autowired private BlogEntryTable blogEntryTable;
17
18 @Test
19 public void testFindByCode見つかる() {
20 BlogEntry blogEntry = domainFactory.prototype(new BlogEntry(createEntry()));
21 blogEntry.store();
22
23 BlogEntry found = blogEntryTable.findByCode(blogEntry.getCode());
24 Assert.assertEquals(blogEntry, found);
25 }
26
27 private Message createEntry() {
28 MessageEntry entry = new MessageEntry();
29 entry.setSubject("今日の記事です。");
30 entry.setBody("これは今日の記事です。");
31 Map<Locale, MessageEntry> entryMap
32 = new HashMap<Locale, MessageEntry>();
33 entryMap.put(Locale.JAPANESE, entry);
34 Message article = domainFactory.prototype(new Message(null, entryMap,
35 simpleUser1.getId(), simpleUser1.getId(),
36 domainFactory.prototype(Public.class),
37 domainFactory.prototype(OwnerOnly.class)));
38 return article;
39 }
40 }