Package gaej2011

Examples of gaej2011.ReadOnlyDatastoreTest$ReadOnlyDelegate


    }

    public static void incrementMemoCount(Key minutesKey) {
        Transaction tx = Datastore.beginTransaction();
        try {
            Minutes minutes = Datastore.get(tx, meta, minutesKey);
            minutes.setMemoCount(minutes.getMemoCount() + 1);
            minutes.setUpdatedAt(new Date());
            ProspectiveSearchServiceFactory
                .getProspectiveSearchService()
                .match(meta.modelToEntity(minutes), "HotMinutes");
            Datastore.put(tx, minutes);
            tx.commit();
View Full Code Here


        int memoCount =
            Datastore
                .query(memoMeta)
                .filter(memoMeta.minutes.equal(minutesKey))
                .count();
        Minutes minutes = Datastore.get(meta, minutesKey);
        minutes.setMemoCount(memoCount);
        Datastore.put(minutes);
        Memcache.delete(MEMCACHE_KEY_LIST);
    }
View Full Code Here

        Key key = MinutesService.put(" テスト用議事録");
        // Minutes の件数が一件増えたことを確認する。
        int after = tester.count(Minutes.class);
        assertThat("Minutes が一件増える", after, is(before + 1));
        // 保存されたMinutes のtitle, createdAt, author に値が格納されていることを確認する。
        Minutes minutes = Datastore.get(Minutes.class, key);
        assertThat(minutes, is(notNullValue()));
        assertThat("title が設定される", minutes.getTitle(), is(" テスト用議事録"));
        assertThat(
            "createdAt が設定される",
            minutes.getCreatedAt(),
            is(notNullValue()));
        assertThat("author が設定される", minutes.getAuthor(), is(notNullValue()));
    }
View Full Code Here

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

    @Test
    public void メモ件数を加算する() {
        Key minutesKey = MinutesService.put(" テスト用議事録1");
        Memcache.put(MinutesService.MEMCACHE_KEY_LIST, "dummy");
        Minutes before = Datastore.get(Minutes.class, minutesKey);
        MinutesService.incrementMemoCount(minutesKey);
        Minutes after = Datastore.get(Minutes.class, minutesKey);
        assertThat(
            " メモ件数が1 増える",
            after.getMemoCount(),
            is(before.getMemoCount() + 1));
        assertThat(" 更新日時が設定される", after.getUpdatedAt(), is(notNullValue()));
        assertThat(
            " 議事録一覧のキャッシュがクリアされる",
            Memcache.contains(MinutesService.MEMCACHE_KEY_LIST),
            is(false));
    }
View Full Code Here

    @Test
    public void メモ件数を数えて保存するための更新対象を抽出する() {
        List<Key> minutesKeys = new ArrayList<Key>();
        Calendar calendar = Calendar.getInstance();
        for (int i = 0; i < 6; i++) { // 6 件保存しておく
            Minutes minutes = new Minutes();
            minutes.setTitle(" テスト用議事録" + i);
            minutes.setCreatedAt(calendar.getTime());
            minutes.setUpdatedAt(calendar.getTime());
            Datastore.put(minutes);
            minutesKeys.add(minutes.getKey());
            calendar.add(Calendar.HOUR_OF_DAY, -12); // 12 時間戻す
        }
        // 0: 現在, 1:-12h, 2:-24h, 3:-36h, 4:-48h, 5:-60h
        // 2, 3 が対象になるべき。
        List<Key> list = MinutesService.queryForUpdateMemoCount();
View Full Code Here

        Key minutesKey = MinutesService.put(" テスト用議事録");
        for (int i = 0; i < 5; i++) {
            MemoService.put(minutesKey, "memo" + i);
        }
        Memcache.put(MinutesService.MEMCACHE_KEY_LIST, "dummy");
        Minutes before = Datastore.get(Minutes.class, minutesKey);
        assertThat(" 実行前のメモ数は0", before.getMemoCount(), is(0));
        MinutesService.updateMemoCount(minutesKey);
        Minutes after = Datastore.get(Minutes.class, minutesKey);
        assertThat(" メモ数が5 になる", after.getMemoCount(), is(5));
        assertThat(
            " 議事録一覧のキャッシュがクリアされる",
            Memcache.contains(MinutesService.MEMCACHE_KEY_LIST),
            is(false));
    }
View Full Code Here

        for (int i = 0; i < 5; i++) {
            MemoService.put(minutesKey, "memo" + i);
        }
        assertThat(" 実行前のメモ数は5", MemoService.list(minutesKey).size(), is(5));
        int beforeMinutesCount = MinutesService.list().size();
        Minutes minutes = Datastore.get(Minutes.class, minutesKey);
        MinutesService.deleteMinutes(minutes);
        assertThat(" メモが全て削除される", MemoService.list(minutesKey).size(), is(0));
        assertThat(
            " 議事録が削除される",
            Datastore.getOrNull(minutesKey),
View Full Code Here

        Key minutesKey = MinutesService.put(" テスト用議事録");
        for (int i = 0; i < 5; i++) {
            MemoService.put(minutesKey, "memo" + i);
        }
        assertThat(" 実行前のメモ数は5", MemoService.list(minutesKey).size(), is(5));
        Minutes minutes = Datastore.get(Minutes.class, minutesKey);
        BlobKey blobKey = MinutesService.exportAsTSV(minutes);
        assertThat("blobKey が返される", blobKey, is(notNullValue()));
        File file =
            new File("www-test/WEB-INF/appengine-generated/"
                + blobKey.getKeyString());
View Full Code Here

            is(ProspectiveSearchController.ADMIN_EMAIL));
    }

    @Test
    public void XMPPメッセージが送信される() {
        Minutes minutes = new Minutes();
        minutes.setTitle(" 活発な議事録");
        minutes.setMemoCount(100);
        Entity document = MinutesMeta.get().modelToEntity(minutes);
        ProspectiveSearchController.sendMessage(document);
        assertThat(" メッセージが一件送信される", delegate.messages.size(), is(1));
        assertThat(
            " 宛先",
View Full Code Here

TOP

Related Classes of gaej2011.ReadOnlyDatastoreTest$ReadOnlyDelegate

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.