Package org.zanata.ui.model.statistic

Examples of org.zanata.ui.model.statistic.WordStatistic


    @Test
    public void documentMilestoneEventApprovedNot100Test() {
        DocumentServiceImpl spyService = Mockito.spy(documentService);

        WordStatistic stats = new WordStatistic(9, 0, 0, 1, 0);
        runDocumentStatisticUpdatedTest(spyService, ContentState.Translated,
                ContentState.Approved, stats);

        DocumentMilestoneEvent milestoneEvent =
                new DocumentMilestoneEvent(projectSlug, versionSlug,
View Full Code Here


    }

    @Test
    public void documentMilestoneEventSameStateTest1() {
        DocumentServiceImpl spyService = Mockito.spy(documentService);
        WordStatistic stats = new WordStatistic(10, 0, 0, 0, 0);

        runDocumentStatisticUpdatedTest(spyService, ContentState.Approved,
                ContentState.Approved, stats);

        DocumentMilestoneEvent milestoneEvent =
View Full Code Here

    }

    @Test
    public void documentMilestoneEventSameStateTest2() {
        DocumentServiceImpl spyService = Mockito.spy(documentService);
        WordStatistic stats = new WordStatistic(0, 0, 0, 10, 0);

        runDocumentStatisticUpdatedTest(spyService, ContentState.Translated,
                ContentState.Translated, stats);

        DocumentMilestoneEvent milestoneEvent =
View Full Code Here

    private void runDocumentStatisticUpdatedTest(
            DocumentServiceImpl spyService,
            ContentState oldState, ContentState newState, WordStatistic stats) {

        int wordCount = 10;
        WordStatistic oldStats = StatisticsUtil.copyWordStatistic(stats);
        oldStats.decrement(newState, wordCount);
        oldStats.increment(oldState, wordCount);

        DocumentStatisticUpdatedEvent event =
                new DocumentStatisticUpdatedEvent(oldStats, stats, versionId,
                        docId, localeId, oldState, newState);
View Full Code Here

        LocaleId localeId = LocaleId.DE;
        int wordCount = 10;
        ContentState oldState = ContentState.New;
        ContentState newState = ContentState.Translated;

        WordStatistic stats = new WordStatistic(10, 10, 10, 10, 10);
        WordStatistic oldStats = StatisticsUtil.copyWordStatistic(stats);
        oldStats.decrement(newState, wordCount);
        oldStats.increment(oldState, wordCount);

        when(translationStateCache.getDocumentStatistics(docId, localeId)).
                thenReturn(stats);
        when(textFlowDAO.getWordCount(tfId)).thenReturn(wordCount);
View Full Code Here

        Long projectIterationId = 1L;
        LocaleId localeId = LocaleId.EN_US;
        VersionLocaleKey key = new VersionLocaleKey(projectIterationId, localeId);

        WordStatistic wordStatistic = new WordStatistic(0, 11, 100, 4, 500);

        // When:
        when(versionStatisticLoader.load(key)).thenReturn(wordStatistic);

        WordStatistic result = cache.getVersionStatistics(projectIterationId,
            localeId);

        // Then:
        verify(versionStatisticLoader).load(key); // only load the value once
        assertThat(result, equalTo(wordStatistic));
View Full Code Here

    public void textFlowStateUpdated(TextFlowTargetStateEvent event) {
        DocumentLocaleKey key =
                new DocumentLocaleKey(event.getDocumentId(),
                        event.getLocaleId());

        WordStatistic stats = documentStatisticCache.get(key);

        if (stats != null) {
            HTextFlow textFlow = getTextFlowDAO().findById(
                    event.getTextFlowId());

            stats.decrement(event.getPreviousState(),
                    textFlow.getWordCount().intValue());
            stats.increment(event.getNewState(),
                    textFlow.getWordCount().intValue());
            documentStatisticCache.put(key, stats);
        }

        // update document status information
View Full Code Here

            return ServiceLocator.instance().getInstance(DocumentDAO.class);
        }

        @Override
        public WordStatistic load(DocumentLocaleKey key) throws Exception {
            WordStatistic wordStatistic = getDocumentDAO().getWordStatistics(
                    key.getDocumentId(), key.getLocaleId());
            return wordStatistic;
        }
View Full Code Here

TOP

Related Classes of org.zanata.ui.model.statistic.WordStatistic

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.