Package org.zanata.rest.dto.stats

Examples of org.zanata.rest.dto.stats.ContainerTranslationStatistics


            protected void onResponse(ClientResponse response) {
                assertThat(response.getStatus(), is(200)); // Ok
                assertJsonUnmarshal(response,
                        ContainerTranslationStatistics.class);

                ContainerTranslationStatistics stats =
                        jsonUnmarshal(response,
                                ContainerTranslationStatistics.class);
                assertThat(stats.getId(), is("1.0"));
                assertThat(stats.getRefs().size(), greaterThan(0));
                assertThat(stats.getDetailedStats(), nullValue()); // No
                                                                   // detailed
                                                                   // stats
                assertThat(stats.getStats().size(), greaterThan(0));

                // No word level stats
                for (TranslationStatistics transStat : stats.getStats()) {
                    assertThat(transStat.getUnit(),
                            is(TranslationStatistics.StatUnit.MESSAGE));
                    // make sure counts are sane
                    assertThat(
                            transStat.getUntranslated() + transStat.getDraft()
View Full Code Here


            protected void onResponse(ClientResponse response) {
                assertThat(response.getStatus(), is(200)); // Ok
                assertJsonUnmarshal(response,
                        ContainerTranslationStatistics.class);

                ContainerTranslationStatistics stats =
                        jsonUnmarshal(response,
                                ContainerTranslationStatistics.class);
                assertThat(stats.getId(), is("1.0"));
                assertThat(stats.getRefs().size(), greaterThan(0));
                assertThat(stats.getDetailedStats().size(), greaterThan(0));
                assertThat(stats.getStats().size(), greaterThan(0));

                for (TranslationStatistics transStat : stats.getStats()) {
                    // make sure counts are sane
                    assertThat(transStat.getDraft() + transStat.getApproved()
                            + transStat.getUntranslated(),
                            equalTo(transStat.getTotal()));
                }

                // Results returned only for specified locales
                String[] expectedLocales = new String[] { "en-US", "as", "es" };
                for (TranslationStatistics transStat : stats.getStats()) {
                    assertThat(Arrays.asList(expectedLocales),
                            hasItem(transStat.getLocale()));
                    // make sure counts are sane
                    assertThat(
                            transStat.getDraft() + transStat.getApproved()
View Full Code Here

            protected void onResponse(ClientResponse response) {
                assertThat(response.getStatus(), is(200)); // Ok
                assertJsonUnmarshal(response,
                        ContainerTranslationStatistics.class);

                ContainerTranslationStatistics stats =
                        jsonUnmarshal(response,
                                ContainerTranslationStatistics.class);
                assertThat(stats.getId(), is("my/path/document.txt"));
                assertThat(stats.getRefs().size(), greaterThan(0));
                assertThat(stats.getDetailedStats(), nullValue()); // No
                                                                   // detailed
                                                                   // stats
                assertThat(stats.getStats().size(), greaterThan(0));

                // No word level stats
                for (TranslationStatistics transStat : stats.getStats()) {
                    assertThat(transStat.getUnit(),
                            is(TranslationStatistics.StatUnit.MESSAGE));
                    // make sure counts are sane
                    assertThat(
                            transStat.getDraft() + transStat.getApproved()
View Full Code Here

            protected void onResponse(ClientResponse response) {
                assertThat(response.getStatus(), is(200)); // Ok
                assertJsonUnmarshal(response,
                        ContainerTranslationStatistics.class);

                ContainerTranslationStatistics stats =
                        jsonUnmarshal(response,
                                ContainerTranslationStatistics.class);
                assertThat(stats.getId(), is("my/path/document.txt"));
                assertThat(stats.getRefs().size(), greaterThan(0));
                // assertThat(stats.getDetailedStats().size(), greaterThan(0));
                // // No detailed stats (maybe later)
                assertThat(stats.getStats().size(), greaterThan(0));

                for (TranslationStatistics transStat : stats.getStats()) {
                    // make sure counts are sane
                    assertThat(
                            transStat.getDraft() + transStat.getApproved()
                                    + transStat.getUntranslated()
                                    + transStat.getTranslatedOnly(),
                            equalTo(transStat.getTotal()));
                }

                // Results returned only for specified locales
                String[] expectedLocales = new String[] { "en-US", "as", "es" };
                for (TranslationStatistics transStat : stats.getStats()) {
                    assertThat(Arrays.asList(expectedLocales),
                            hasItem(transStat.getLocale()));
                    // make sure counts are sane
                    assertThat(
                            transStat.getDraft() + transStat.getApproved()
View Full Code Here

    @Captor
    private ArgumentCaptor<KeyShortcut> keyShortcutCaptor;

    @BeforeMethod
    public void beforeMethod() {
        selectedDocumentStats = new ContainerTranslationStatistics();
        selectedDocumentStats.addStats(new TranslationStatistics(
                new TransUnitCount(1, 2, 3), LocaleId.EN_US.getId()));
        selectedDocumentStats.addStats(new TranslationStatistics(
                new TransUnitWords(4, 5, 6), LocaleId.EN_US.getId()));

        projectStats = new ContainerTranslationStatistics();
        projectStats.addStats(new TranslationStatistics(new TransUnitCount(7,
                8, 9), LocaleId.EN_US.getId()));
        projectStats.addStats(new TranslationStatistics(new TransUnitWords(10,
                11, 12), LocaleId.EN_US.getId()));
View Full Code Here

        presenter.setStatesForTest(projectStats, selectedDocumentStats, null,
                null);
        DocumentId docId = new DocumentId(1L, "");
        // newly selected document has new stats

        ContainerTranslationStatistics newSelectedStats =
                new ContainerTranslationStatistics();
        newSelectedStats.addStats(new TranslationStatistics(new TransUnitCount(
                1, 2, 3), LocaleId.EN_US.toString()));
        newSelectedStats.addStats(new TranslationStatistics(new TransUnitWords(
                4, 5, 6), LocaleId.EN_US.toString()));
        DocumentInfo documentInfo =
                new DocumentInfo(docId, "a.po", "pot/", new LocaleId("en-US"),
                        newSelectedStats, new AuditInfo(new Date(),
                                "Translator"), new HashMap<String, String>(),
                        new AuditInfo(new Date(), "last translator"));
        when(documentListPresenter.getDocumentInfo(docId)).thenReturn(
                documentInfo);
        // current view is editor
        presenter.showView(MainView.Editor);
        verify(display).setStats(statsCaptor.capture(), eq(true));
        assertThat(statsCaptor.getValue(),
                Matchers.sameInstance(selectedDocumentStats));

        // When:
        presenter.selectDocument(docId);

        // Then:
        display.setDocumentLabel("pot/", "a.po");
        verify(display, atLeastOnce()).setStats(selectedDocumentStats, true);
        assertThat(selectedDocumentStats.getStats(),
                Matchers.equalTo(newSelectedStats.getStats()));
        assertThat(presenter.getSelectedDocIdOrNull(), Matchers.is(docId));
    }
View Full Code Here

        presenter.setStatesForTest(projectStats, selectedDocumentStats,
                MainView.Documents, null);
        DocumentId docId = new DocumentId(1L, "");
        // newly selected document has new stats

        ContainerTranslationStatistics newSelectedStats =
                new ContainerTranslationStatistics();
        newSelectedStats.addStats(new TranslationStatistics(new TransUnitCount(
                1, 2, 3), LocaleId.EN_US.toString()));
        newSelectedStats.addStats(new TranslationStatistics(new TransUnitWords(
                4, 5, 6), LocaleId.EN_US.toString()));

        DocumentInfo documentInfo =
                new DocumentInfo(docId, "a.po", "pot/", new LocaleId("en-US"),
                        newSelectedStats, new AuditInfo(new Date(),
View Full Code Here

    public void onDocumentStatsUpdateWillDoNothingIfNoSelectedDocument() {
        assertThat(presenter.getSelectedDocumentInfoOrNull(),
                Matchers.is(Matchers.nullValue()));

        presenter.onDocumentStatsUpdated(new DocumentStatsUpdatedEvent(
                new DocumentId(1L, ""), new ContainerTranslationStatistics()));

        verifyZeroInteractions(display);
    }
View Full Code Here

                null);
        presenter.selectDocument(new DocumentId(2L, ""));

        // When:
        presenter.onDocumentStatsUpdated(new DocumentStatsUpdatedEvent(
                new DocumentId(1L, ""), new ContainerTranslationStatistics()));

        // Then:
        verifyZeroInteractions(display);
    }
View Full Code Here

                documentInfo);
        presenter.selectDocument(docId);
        verify(display, atLeastOnce()).setStats(selectedDocumentStats, true);

        // When:
        ContainerTranslationStatistics newStats =
                new ContainerTranslationStatistics();
        newStats.addStats(new TranslationStatistics(
                new TransUnitCount(9, 9, 9), LocaleId.EN_US.toString()));
        newStats.addStats(new TranslationStatistics(
                new TransUnitWords(8, 8, 8), LocaleId.EN_US.toString()));

        presenter.onDocumentStatsUpdated(new DocumentStatsUpdatedEvent(docId,
                newStats));

        // Then:
        assertThat(selectedDocumentStats.getStats(),
                Matchers.equalTo(newStats.getStats()));
        verify(display, atLeastOnce()).setStats(selectedDocumentStats, true);
    }
View Full Code Here

TOP

Related Classes of org.zanata.rest.dto.stats.ContainerTranslationStatistics

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.