Package org.zanata.rest.dto.stats

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


        return result.toString();
    }

    public ContainerTranslationStatistics getDocStatistics(Long documentId,
            LocaleId localeId) {
        ContainerTranslationStatistics result =
                documentDAO.getStatistics(documentId, localeId);

        TranslationStatistics wordStatistics =
                result.getStats(localeId.getId(), StatUnit.WORD);
        wordStatistics.setRemainingHours(StatisticsUtil
                .getRemainingHours(wordStatistics));

        TranslationStatistics msgStatistics =
                result.getStats(localeId.getId(), StatUnit.MESSAGE);
        msgStatistics.setRemainingHours(StatisticsUtil
                .getRemainingHours(wordStatistics));

        return result;
    }
View Full Code Here


        }
    }

    @Test
    public void getWordIterationStatisticsForAllLocales() {
        ContainerTranslationStatistics stats =
                statisticsService.getStatistics("sample-project", "1.0", false,
                        true, new String[] {});

        // Make sure the id matches
        assertThat(stats.getId()).isEqualTo("1.0");
        // Make sure there are links
        assertThat(stats.getRefs().size()).isGreaterThan(0);

        // No detailed stats
        assertThat(stats.getDetailedStats()).isNull();

        // Word level AND message level stats
        int wordLevel = 0;
        int mssgLevel = 0;
        for (TranslationStatistics transStat : stats.getStats()) {
            if (transStat.getUnit() == TranslationStatistics.StatUnit.MESSAGE) {
                mssgLevel++;
            } else if (transStat.getUnit() == TranslationStatistics.StatUnit.WORD) {
                wordLevel++;
            }
View Full Code Here

    @Test
    public void getDetailedIterationStatisticsForSpecificLocales() {
        String[] locales = new String[] { "en-US", "es", "as" };

        ContainerTranslationStatistics stats =
                statisticsService.getStatistics("sample-project", "1.0", true,
                        true, locales);

        // Make sure the id matches
        assertThat(stats.getId()).isEqualTo("1.0");
        // Make sure there are links
        assertThat(stats.getRefs().size()).isGreaterThan(0);

        // Detailed Stats
        assertThat(stats.getDetailedStats().size()).isGreaterThan(0);

        // Results returned only for specified locales
        for (TranslationStatistics transStat : stats.getStats()) {
            assertThat(Arrays.asList(locales)).contains(transStat.getLocale());
            // make sure counts are sane
            assertThat(
                    transStat.getDraft() + transStat.getApproved()
                            + transStat.getTranslatedOnly()
View Full Code Here

        }
    }

    @Test
    public void getSimpleDocumentStatisticsForAllLocales() {
        ContainerTranslationStatistics stats =
                statisticsService.getStatistics("sample-project", "1.0",
                        "my/path/document.txt", false, new String[] {});

        // Make sure the id matches
        assertThat(stats.getId()).isEqualTo("my/path/document.txt");
        // Make sure there are links
        assertThat(stats.getRefs().size()).isGreaterThan(0);

        // No detailed stats
        assertThat(stats.getDetailedStats()).isNull();

        assertThat(stats.getStats().get(0).getUnit()).isEqualTo(
                TranslationStatistics.StatUnit.MESSAGE);

        for (TranslationStatistics transStat : stats.getStats()) {
            // Check that there are no word level stats
            assertThat(transStat.getUnit()).isNotEqualTo(
                    TranslationStatistics.StatUnit.WORD);

            // make sure counts are sane
View Full Code Here

    @Test
    public void getDetailedDocumentStatisticsForSpecificLocales() {
        String[] locales = new String[] { "en-US", "es", "as" };

        ContainerTranslationStatistics stats =
                statisticsService.getStatistics("sample-project", "1.0",
                        "my/path/document.txt", true, locales);

        // Make sure the id matches
        assertThat(stats.getId()).isEqualTo("my/path/document.txt");
        // Make sure there are links
        assertThat(stats.getRefs().size()).isGreaterThan(0);

        // No Detailed Stats
        assertThat(stats.getDetailedStats()).isNull();

        // Results returned only for specified locales
        for (TranslationStatistics transStat : stats.getStats()) {
            assertThat(Arrays.asList(locales)).contains(transStat.getLocale());
            // make sure counts are sane
            assertThat(
                    transStat.getDraft() + transStat.getApproved()
                            + transStat.getTranslatedOnly()
View Full Code Here

        TranslationStatistics msgStats =
                new TranslationStatistics(count, LocaleId.EN_US.toString());
        TranslationStatistics wordStats =
                new TranslationStatistics(words, LocaleId.EN_US.toString());

        ContainerTranslationStatistics result =
                new ContainerTranslationStatistics();
        result.addStats(msgStats);
        result.addStats(wordStats);
        return result;
    }
View Full Code Here

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

                ContainerTranslationStatistics stats =
                        jaxbUnmarshal(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
                assertJaxbUnmarshal(response,
                        ContainerTranslationStatistics.class);

                ContainerTranslationStatistics stats =
                        jaxbUnmarshal(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.getUntranslated() + transStat.getDraft()
View Full Code Here

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

                ContainerTranslationStatistics stats =
                        jaxbUnmarshal(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.getUntranslated() + transStat.getDraft()
View Full Code Here

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

                ContainerTranslationStatistics stats =
                        jaxbUnmarshal(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.getUntranslated() + transStat.getDraft()
                                    + transStat.getTranslatedAndApproved(),
                            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()
                            + transStat.getUntranslated(),
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.