Package org.zanata.rest.dto.stats.contribution

Examples of org.zanata.rest.dto.stats.contribution.ContributionStatistics


            }
            stats.set(state, count);
            localeStatistics.put(localeId, stats);
        }

        ContributionStatistics result = new ContributionStatistics();
        result.put(username, localeStatistics);

        return result;
    }
View Full Code Here


        String todayDate = formatter.format(today);

        String username = "demo";
        HPerson demoPerson = personDAO.findByUsername(username);

        ContributionStatistics initialStats =
                statisticsService.getContributionStatistics(
                        "sample-project", "1.0", username, todayDate + ".."
                                + todayDate);

        BaseTranslationCount stats =
                initialStats.get(username).get(target.getLocaleId());

        // Should have no stats for user on today
        assertNull(stats);

        // needReview -> approved
        ContributionStatistics expectedStats = new ContributionStatistics();
        expectedStats.put(username, buildStats(target.getLocaleId(), 0, 0, 0,
                wordCount, 0));
        target = executeStateChangeTest(target, "test1", ContentState.Approved,
                demoPerson, expectedStats);

        // approved -> approved
        target = executeStateChangeTest(target, "test2", ContentState.Approved,
                demoPerson, expectedStats);

        // approved -> approved
        target = executeStateChangeTest(target, "test3", ContentState.Approved,
                demoPerson, expectedStats);

        // approved -> needReview
        expectedStats.put(username, buildStats(target.getLocaleId(), 0,
                wordCount, 0, wordCount, 0));
        target = executeStateChangeTest(target, "test4",
                ContentState.NeedReview, demoPerson, expectedStats);

        // needReview -> new
        expectedStats.put(username, buildStats(target.getLocaleId(), wordCount,
                wordCount, 0, wordCount, 0));
        target = executeStateChangeTest(target, "", ContentState.New,
                demoPerson, expectedStats);

    }
View Full Code Here

        int wordCount2 = target2.getTextFlow().getWordCount().intValue();

        // new -> approved
        ContentState newState = ContentState.Approved;

        ContributionStatistics expectedStats = new ContributionStatistics();
        expectedStats.put(username, buildStats(localeId, 0, 0, 0,
                wordCount1, 0));
        target1 = executeStateChangeTest(target1, "test1",
                newState, demoPerson, expectedStats);

        expectedStats.put(username, buildStats(localeId, 0, 0, 0,
                wordCount1 + wordCount2, 0));
        target2 = executeStateChangeTest(target2, "test1",
                newState, demoPerson, expectedStats);

        // approved -> needReview
        newState = ContentState.NeedReview;
        expectedStats.put(username, buildStats(localeId, 0, wordCount1, 0,
                wordCount1 + wordCount2, 0));
        target1 = executeStateChangeTest(target1, "test2",
                newState, demoPerson, expectedStats);

        expectedStats.put(username, buildStats(localeId, 0,
                wordCount1 + wordCount2, 0, wordCount1 + wordCount2, 0));
        target2 = executeStateChangeTest(target2, "test2",
                newState, demoPerson, expectedStats);
    }
View Full Code Here

        int wordCount2 = target2.getTextFlow().getWordCount().intValue();

        // needReview -> approved
        ContentState newState = ContentState.Approved;

        ContributionStatistics expectedStats = new ContributionStatistics();
        expectedStats.put(username, buildStats(target1.getLocaleId(), 0, 0, 0,
                wordCount1, 0));
        target1 = executeStateChangeTest(target1, "test1",
                newState, demoPerson, expectedStats);

        expectedStats.get(username).putAll(buildStats(target2.getLocaleId(), 0,
                0, 0, wordCount2, 0));
        target2 = executeStateChangeTest(target2, "test1",
                newState, demoPerson, expectedStats);

        // approved -> needReview
        newState = ContentState.NeedReview;
        BaseTranslationCount localeStat = expectedStats.get(username)
                .get(target1.getLocaleId());
        localeStat.set(newState, localeStat.get(newState) + wordCount1);
        target1 = executeStateChangeTest(target1, "test2",
                newState, demoPerson, expectedStats);

        localeStat = expectedStats.get(username).get(target2.getLocaleId());
        localeStat.set(newState, localeStat.get(newState) + wordCount2);
        target2 = executeStateChangeTest(target2, "test2",
                newState, demoPerson, expectedStats);

    }
View Full Code Here

            ContributionStatistics expectedStats) {
        target = changeState(target, newContent, newState, translator);

        String todayDate = formatter.format(today);

        ContributionStatistics newStats =
                statisticsService.getContributionStatistics(
                        "sample-project", "1.0", translator.getAccount()
                                .getUsername(), todayDate + ".." + todayDate);

        assertNotNull(newStats);
View Full Code Here

TOP

Related Classes of org.zanata.rest.dto.stats.contribution.ContributionStatistics

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.