Package gaej2011.controller

Examples of gaej2011.controller.MinutesControllerTest


    @Test
    public void タスクを実行する() throws NullPointerException,
            IllegalArgumentException, IOException, ServletException {
        Key minutesKey = MinutesService.put(" テスト用議事録1");
        Minutes before = Datastore.get(Minutes.class, minutesKey);
        tester.request.addParameter(
            "minutesKey",
            Datastore.keyToString(minutesKey));
        tester.start(PATH);
        assertThat(
            "IncrementMemoCountController のインスタンスが使用される",
            tester.getController(),
            instanceOf(IncrementMemoCountController.class));
        assertThat(
            " レスポンスコードが200",
            tester.response.getStatus(),
            is(HttpServletResponse.SC_OK));
        Minutes after = Datastore.get(Minutes.class, minutesKey);
        assertThat(
            " メモ件数が1 増える",
            after.getMemoCount(),
            is(before.getMemoCount() + 1));
    }
View Full Code Here


                counter = counterEntitiesMap.get(counterKey);
            } else {
                counter = new AccessCounter();
                counterEntitiesMap.put(counterKey, counter);
                counter.setKey(counterKey);
                Minutes minutes =
                    Datastore.get(
                        Minutes.class,
                        Datastore.createKey(Minutes.class, counterKey.getId()));
                counter.setMinutesTitle(minutes.getTitle());
            }
            counter.setCount(counter.getCount() + next.getValue());
        }
        return counterEntitiesMap.values();
    }
View Full Code Here

    @Test
    public void 議事録の一覧を新しい順に表示できる() throws NullPointerException,
            IllegalArgumentException, IOException, ServletException {
        for (int i = 0; i < 5; i++) {
            Minutes minutes = new Minutes();
            minutes.setTitle(" テスト用議事録" + i);
            minutes.setCreatedAt(new Date());
            Datastore.put(minutes);
        }
        tester.request.setMethod("GET");
        tester.start(PATH);
        assertThat(
View Full Code Here

        environment.setEmail("test@example.com");
        Key minutesKey = MinutesService.put(" テスト用議事録");
        for (int i = 0; i < 5; i++) {
            MemoService.put(minutesKey, "memo" + i);
        }
        Minutes minutes = Datastore.get(Minutes.class, minutesKey);
        BlobKey blobKey = MinutesService.exportAsTSV(minutes);
        tester.param("download", blobKey.getKeyString());
        tester.start(PATH);
        assertThat(
            "MinutesController のインスタンスが使用される",
View Full Code Here

        environment.setEmail("test@example.com");
        Key minutesKey = MinutesService.put(" テスト用議事録");
        for (int i = 0; i < 5; i++) {
            MemoService.put(minutesKey, "memo" + i);
        }
        Minutes minutes = Datastore.get(Minutes.class, minutesKey);
        // メール送信API をフックするApiProxy.Delegate を適用しておく。
        @SuppressWarnings("rawtypes")
        Delegate parentDelegate = ApiProxy.getDelegate();
        MailDelegate mailDelegate = new MailDelegate();
        ApiProxy.setDelegate(mailDelegate);
        tester.param("delete", Datastore.keyToString(minutesKey));
        tester.start(PATH);
        assertThat(
            "MinutesController のインスタンスが使用される",
            tester.getController(),
            instanceOf(MinutesController.class));
        assertThat(
            " レスポンスコードが204",
            tester.response.getStatus(),
            is(HttpServletResponse.SC_NO_CONTENT));
        assertThat(" メールが送信される", mailDelegate.messages.size(), is(1));
        MailMessage mail = mailDelegate.messages.get(0);
        assertThat(
            "From",
            mail.getSender(),
            is("minutes@yourappid.appspotmail.com"));
        assertThat("To", mail.getTo(0), is("test@example.com"));
        assertThat(
            "Subject",
            mail.getSubject(),
            is(" 議事録[" + minutes.getTitle() + "] がTSV に変換されました"));
        assertThat(
            "Body",
            mail.getTextBody(Charset.forName("utf-8")),
            containsString("http://localhost/minutes?download="));
        // ApiProxy.Delegate をもとに戻す。
View Full Code Here

            }
        } catch (IllegalArgumentException e) {
            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
            return null;
        }
        Minutes minutes = Datastore.getOrNull(Minutes.class, minutesKey);
        if (minutes == null) {
            response.setStatus(HttpServletResponse.SC_NOT_FOUND);
            return null;
        }
        if (minutes.getAuthor().equals(currentUser) == false) {
            response.setStatus(HttpServletResponse.SC_FORBIDDEN);
            return null;
        }
        // TSV 作成と削除をする
        BlobKey blobKey = MinutesService.exportAsTSV(minutes);
        MinutesService.deleteMinutes(minutes);
        // ダウンロードURL をメールで送信する
        Message message = new Message();
        message.setSender("minutes@yourappid.appspotmail.com");
        message.setSubject(" 議事録[" + minutes.getTitle() + "] がTSV に変換されました");
        message.setTo(currentUser.getEmail());
        StringBuilder b = new StringBuilder();
        b
            .append(request.getScheme())
            .append("://")
View Full Code Here

        }
        String clientId = UUID.randomUUID().toString();
        ChannelService channelService =
            ChannelServiceFactory.getChannelService();
        String token = channelService.createChannel(clientId);
        MinutesChannel minutesChannel = new MinutesChannel();
        minutesChannel.setKey(Datastore.createKey(
            MinutesChannel.class,
            clientId));
        minutesChannel.setCreatedAt(new Date());
        minutesChannel.setMinutesKey(minutesKey);
        minutesChannel.setToken(token);
        Datastore.putAsync(minutesChannel);
        response.setCharacterEncoding("utf-8");
        response.setContentType("application/json");
        response.getWriter().println(
            MinutesChannelMeta.get().modelToJson(minutesChannel));
View Full Code Here

            instanceOf(ChannelController.class));
        assertThat(
            " レスポンスコードが200",
            tester.response.getStatus(),
            is(HttpServletResponse.SC_OK));
        MinutesChannel minutesChannel =
            MinutesChannelMeta.get().jsonToModel(
                tester.response.getOutputAsString());
        assertThat(
            "channel のtoken が返される",
            minutesChannel.getToken(),
            is(notNullValue()));
    }
View Full Code Here

    @Test
    public void 接続済みのチャンネルにプッシュできる() {
        // テスト用の議事録
        Key testMinutesKey = MinutesService.put(" テスト用議事録1");
        // テスト用の接続済みチャンネル1
        MinutesChannel minutesChannel1 = new MinutesChannel();
        minutesChannel1.setMinutesKey(testMinutesKey);
        minutesChannel1.setToken("test-token1");
        minutesChannel1.setKey(Datastore.createKey(
            MinutesChannel.class,
            "test-client-id1"));
        Datastore.put(minutesChannel1);
        // テスト用の接続済みチャンネル2
        MinutesChannel minutesChannel2 = new MinutesChannel();
        minutesChannel2.setMinutesKey(testMinutesKey);
        minutesChannel2.setToken("test-token2");
        minutesChannel2.setKey(Datastore.createKey(
            MinutesChannel.class,
            "test-client-id2"));
        Datastore.put(minutesChannel2);
        // 新たに投稿されてプッシュされるべき投稿
        Key memoKey = MemoService.put(testMinutesKey, "test 投稿");
View Full Code Here

    @Test
    public void 接続済みのチャンネルにプッシュできる_関係ないチャンネルにはプッシュされない() {
        // テスト用の議事録
        Key testMinutesKey = MinutesService.put(" テスト用議事録1");
        // テスト用の接続済みチャンネル1
        MinutesChannel minutesChannel1 = new MinutesChannel();
        minutesChannel1.setMinutesKey(testMinutesKey);
        minutesChannel1.setToken("test-token1");
        minutesChannel1.setKey(Datastore.createKey(
            MinutesChannel.class,
            "test-client-id1"));
        Datastore.put(minutesChannel1);
        // 新たに投稿されてプッシュされるべき投稿
        Key memoKey = MemoService.put(testMinutesKey, "test 投稿");
        // テスト用の議事録2(プッシュとは関係ない議事録)
        Key testMinutesKey2 = MinutesService.put(" テスト用議事録2");
        // テスト用の接続済みチャンネル2(プッシュとは関係ないチャンネル)
        MinutesChannel minutesChannel2 = new MinutesChannel();
        minutesChannel2.setMinutesKey(testMinutesKey2);
        minutesChannel2.setToken("test-token2");
        minutesChannel2.setKey(Datastore.createKey(
            MinutesChannel.class,
            "test-client-id2"));
        Datastore.put(minutesChannel2);
        ChannelDelegate channelDelegate = new ChannelDelegate();
        ApiProxy.setDelegate(channelDelegate);
View Full Code Here

TOP

Related Classes of gaej2011.controller.MinutesControllerTest

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.