Package gaej2011

Examples of gaej2011.GuestbookServiceTest


    @Override
    protected Navigation run() throws Exception {
        Key memoKey = asKey("memoKey");
        Memo memo = Datastore.get(MemoMeta.get(), memoKey);
        Set<String> keywords = YahooAPIService.parse(memo.getMemo());
        KeyWord keyWord = new KeyWord();
        keyWord.setKey(Datastore.createKey(memoKey, KeyWord.class, "1"));
        keyWord.setWords(keywords);
        Datastore.put(keyWord);
        return null;
    }
View Full Code Here


    private Key createTestData() {
        Key minutesKey = MinutesService.put(" テスト用議事録1");
        HashSet<String> keyWords = new HashSet<String>();
        Key memoKey1 = MemoService.put(minutesKey, " 本日は晴天なり");
        KeyWord keyWord1 = new KeyWord();
        keyWord1.setKey(Datastore.createKey(memoKey1, KeyWord.class, "1"));
        keyWords.add(" 本日");
        keyWords.add(" 晴天");
        keyWord1.setWords(keyWords);
        Datastore.put(keyWord1);
        Key memoKey2 = MemoService.put(minutesKey, " 本日は雨天なり");
        keyWords.clear();
        KeyWord keyWord2 = new KeyWord();
        keyWord2.setKey(Datastore.createKey(memoKey2, KeyWord.class, "1"));
        keyWords.add(" 本日");
        keyWords.add(" 雨天");
        keyWord2.setWords(keyWords);
        Datastore.put(keyWord2);
        Key memoKey3 = MemoService.put(minutesKey, " 明日も雨天なり");
        keyWords.clear();
        KeyWord keyWord3 = new KeyWord();
        keyWord3.setKey(Datastore.createKey(memoKey3, KeyWord.class, "1"));
        keyWords.add(" 明日");
        keyWords.add(" 雨天");
        keyWord3.setWords(keyWords);
        Datastore.put(keyWord3);
        return memoKey1;
    }
View Full Code Here

            LogServiceFactory.getLogService().fetch(query).iterator();
        List<LogDTO> logs = new ArrayList<LogDTO>(LIMIT);
        int count = 0;
        while (i.hasNext() && count++ < LIMIT) {
            RequestLogs log = i.next();
            LogDTO dto = new LogDTO();
            dto.setCombined(log.getCombined());
            dto.setOffset(log.getOffset());
            List<AppLogLine> logLines = log.getAppLogLines();
            for (AppLogLine logLine : logLines) {
                dto.getLogLevels().add(logLine.getLogLevel().name());
                dto.getLogLines().add(logLine.getLogMessage());
            }
            logs.add(dto);
        }
        response.getWriter().println(LogDTOMeta.get().modelsToJson(logs));
        response.flushBuffer();
View Full Code Here

import com.google.appengine.api.users.UserServiceFactory;

public class MemoService {

    public static Key put(Key minutesKey, String string) {
        Memo memo = new Memo();
        memo.setMinutes(minutesKey);
        memo.setMemo(string);
        memo.setCreatedAt(new Date());
        memo.setAuthor(UserServiceFactory.getUserService().getCurrentUser());
        Datastore.put(memo);
        Memcache.delete(minutesKey);
        Queue queue = QueueFactory.getDefaultQueue();
        queue.add(TaskOptions.Builder.withUrl("/tq/IncrementMemoCount").param(
            "minutesKey",
            Datastore.keyToString(minutesKey)));
        QueueFactory.getQueue("parse").add(
            TaskOptions.Builder.withUrl("/tq/Yahoo").param(
                "memoKey",
                Datastore.keyToString(memo.getKey())));
        return memo.getKey();
    }
View Full Code Here

        response.flushBuffer();
        return null;
    }

    static void pushMemo(Key memoKey) {
        Memo memo = Datastore.getOrNull(Memo.class, memoKey);
        if (memo == null) {
            return;
        }
        List<Key> channels =
            Datastore
                .query(MinutesChannel.class)
                .filter(
                    MinutesChannelMeta.get().minutesKey.equal(memo.getMinutes()))
                .asKeyList();
        ChannelService channelService =
            ChannelServiceFactory.getChannelService();
        String memoJson = MemoMeta.get().modelToJson(memo);
        for (Key channel : channels) {
View Full Code Here

    public void 議事録ごとに議事録に追加されたメモを古い順に一覧表示できる() throws NullPointerException,
            IllegalArgumentException, IOException, ServletException {
        Key minutesKey = MinutesService.put(" テスト用議事録1");
        Calendar calendar = Calendar.getInstance();
        for (int i = 0; i < 5; i++) { // 5 件保存しておく
            Memo memo = new Memo();
            memo.setMinutes(minutesKey);
            memo.setMemo(" メモ" + i);
            memo.setCreatedAt(calendar.getTime());
            Datastore.put(memo);
            calendar.add(Calendar.HOUR_OF_DAY, 1); // 1 時間進める
        }
        tester.request.setMethod("GET");
        tester.param("minutes", Datastore.keyToString(minutesKey));
View Full Code Here

        Key minutesKey = MinutesService.put(" テスト用議事録1");
        int before = tester.count(Memo.class);
        Key key = MemoService.put(minutesKey, " メモ1");
        int after = tester.count(Memo.class);
        assertThat("Memo が一件増える", after, is(before + 1));
        Memo memo = Datastore.get(Memo.class, key);
        assertThat(memo, is(notNullValue()));
        assertThat(" 議事録への参照が設定される", memo.getMinutes(), is(minutesKey));
        assertThat("memo が設定される", memo.getMemo(), is(" メモ1"));
        assertThat("createdAt が設定される", memo.getCreatedAt(), is(notNullValue()));
        assertThat("author が設定される", memo.getAuthor(), is(notNullValue()));
    }
View Full Code Here

    @Test
    public void 議事録ごとに議事録に追加されたメモを古い順に一覧表示できる() {
        Key minutesKey = MinutesService.put(" テスト用議事録1");
        Calendar calendar = Calendar.getInstance();
        for (int i = 0; i < 5; i++) { // 5 件保存しておく
            Memo memo = new Memo();
            memo.setMinutes(minutesKey);
            memo.setMemo(" メモ" + i);
            memo.setCreatedAt(calendar.getTime());
            Datastore.put(memo);
            calendar.add(Calendar.HOUR_OF_DAY, 1); // 1 時間進める
        }
        int count = 0;
        Date before = null;
        List<Memo> list = MemoService.list(minutesKey);
        for (Memo memo : list) {
            Date createdAt = memo.getCreatedAt();
            if (before != null) {
                assertThat(
                    " 古いものから取得できている",
                    createdAt.compareTo(before) > 0,
                    is(true));
View Full Code Here

public class YahooController extends Controller {

    @Override
    protected Navigation run() throws Exception {
        Key memoKey = asKey("memoKey");
        Memo memo = Datastore.get(MemoMeta.get(), memoKey);
        Set<String> keywords = YahooAPIService.parse(memo.getMemo());
        KeyWord keyWord = new KeyWord();
        keyWord.setKey(Datastore.createKey(memoKey, KeyWord.class, "1"));
        keyWord.setWords(keywords);
        Datastore.put(keyWord);
        return null;
View Full Code Here

import com.google.appengine.api.users.UserServiceFactory;

public class MinutesService {

    public static Key put(String string) {
        Minutes minutes = new Minutes();
        minutes.setTitle(string);
        minutes.setCreatedAt(new Date());
        minutes.setAuthor(UserServiceFactory.getUserService().getCurrentUser());
        Datastore.put(minutes);
        Memcache.delete(MEMCACHE_KEY_LIST);
        return minutes.getKey();
    }
View Full Code Here

TOP

Related Classes of gaej2011.GuestbookServiceTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.