Package org.zanata.model

Examples of org.zanata.model.HTextFlowTarget


        assertThat(matchingTarget.isPresent()).as("match present").isEqualTo(
                execution.expectMatch());

        if (matchingTarget.isPresent()) {
            HTextFlowTarget target = matchingTarget.get();
            HTextFlow tf = target.getTextFlow();
            assertThat(target.getLocaleId()).isEqualTo(LocaleId.DE);
            assertThat(tf.getContents()).containsExactly(execution.getContent());

            if (execution.isCheckContext()) {
                assertThat(tf.getResId()).isEqualTo(execution.getContext());
            }
View Full Code Here


        testHashChange(new Function<HDocument, Void>() {
            @Override
            @Nullable
            public Void apply(@Nullable HDocument doc) {
                HTextFlow tf = doc.getTextFlows().get(0);
                HTextFlowTarget tft = tf.getTargets().get(as.getId());
                tft.setContent0("new Translation for as");
                return null;
            }
        }, true);
    }
View Full Code Here

        testHashChange(new Function<HDocument, Void>() {
            @Override
            @Nullable
            public Void apply(@Nullable HDocument doc) {
                HTextFlow tf = doc.getTextFlows().get(0);
                HTextFlowTarget tft = tf.getTargets().get(de.getId());
                tft.setContent0("new Translation for de");
                return null;
            }
        }, false);
    }
View Full Code Here

        testHashChange(new Function<HDocument, Void>() {
            @Override
            @Nullable
            public Void apply(@Nullable HDocument doc) {
                HTextFlow tf = doc.getTextFlows().get(0);
                HTextFlowTarget tft = tf.getTargets().get(as.getId());
                tft.setComment(new HSimpleComment("This is a new comment"));
                return null;
            }
        }, true);
    }
View Full Code Here

    @Test
    public void testTargetUserComment() {
        PersonDAO personDAO = new PersonDAO(getSession());
        HPerson person = personDAO.findById(1L, false);
        HTextFlowTarget target = textFlowTargetDAO.findById(1L, false);

        List<HTextFlowTargetReviewComment> userComments =
                target.getReviewComments();

        assertThat(userComments, Matchers.empty());

        target.addReviewComment("bad translation", person);
        getEm().persist(target);

        List<HTextFlowTargetReviewComment> result =
                reviewCommentsDAO.getReviewComments(new TransUnitId(target
                        .getTextFlow().getId()), target.getLocaleId());

        assertThat(result, Matchers.hasSize(1));
        assertThat(result.get(0).getCommenterName(),
                Matchers.equalTo(person.getName()));
        assertThat(result.get(0).getCreationDate(),
View Full Code Here

    @Test
    public void testTargetUserCommentMadeOnPreviousTranslation() {
        PersonDAO personDAO = new PersonDAO(getSession());
        HPerson person = personDAO.findById(1L, false);
        HTextFlowTarget target = textFlowTargetDAO.findById(2L, false);

        List<String> oldTranslation = target.getContents();
        int oldVersion = target.getVersionNum();

        target.addReviewComment("comment blah", person);
        getEm().persist(target);

        // change target after making comment
        target.setContent0("new translation");
        getEm().persist(target);

        List<HTextFlowTargetReviewComment> result =
                reviewCommentsDAO.getReviewComments(new TransUnitId(target
                        .getTextFlow().getId()), target.getLocaleId());

        assertThat(result.get(0).getTargetVersion(),
                Matchers.equalTo(oldVersion));
    }
View Full Code Here

    @Test
    public void getContribStatsSingleTarget() {
        PersonDAO personDAO = seam.autowire(PersonDAO.class);

        // Initial state = needReview
        HTextFlowTarget target = textFlowTargetDAO.findById(2L);

        int wordCount = target.getTextFlow().getWordCount().intValue();

        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

        PersonDAO personDAO = seam.autowire(PersonDAO.class);
        String username = "demo";
        HPerson demoPerson = personDAO.findByUsername(username);

        // Initial state = new (en-us)
        HTextFlowTarget target1 = textFlowTargetDAO.findById(5L);

        // Initial state = new (en-us)
        HTextFlowTarget target2 = textFlowTargetDAO.findById(6L);

        LocaleId localeId = target1.getLocaleId(); // same as target2

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

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

        ContributionStatistics expectedStats = new ContributionStatistics();
View Full Code Here

        PersonDAO personDAO = seam.autowire(PersonDAO.class);
        String username = "demo";
        HPerson demoPerson = personDAO.findByUsername(username);

        // Initial state = needReview (AS)
        HTextFlowTarget target1 = textFlowTargetDAO.findById(1L);

        // Initial state = needReview (DE)
        HTextFlowTarget target2 = textFlowTargetDAO.findById(2L);

        int wordCount1 = target1.getTextFlow().getWordCount().intValue();
        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

        fuzzyLoc = new HLocale(LocaleId.FR);
        apprLoc = new HLocale(LocaleId.ES);
        // Target Locale ids
        Long newLocId = 1L, fuzzyLocId = 2L, apprLocId = 3L;

        HTextFlowTarget newTarg, fuzzyTarg, apprTarg;
        newTarg = new HTextFlowTarget(originalTF, newLoc);
        fuzzyTarg = new HTextFlowTarget(originalTF, fuzzyLoc);
        apprTarg = new HTextFlowTarget(originalTF, apprLoc);

        int newTargVersionBefore = 1;
        int fuzzyTargVersionBefore = 1;
        int apprTargVersionBefore = 1;

        newTarg.setVersionNum(newTargVersionBefore);
        fuzzyTarg.setVersionNum(fuzzyTargVersionBefore);
        apprTarg.setVersionNum(apprTargVersionBefore);

        newTarg.setState(ContentState.New);
        fuzzyTarg.setState(ContentState.NeedReview);
        apprTarg.setState(ContentState.Approved);

        originalTF.getTargets().put(newLocId, newTarg);
        originalTF.getTargets().put(fuzzyLocId, fuzzyTarg);
        originalTF.getTargets().put(apprLocId, apprTarg);

        to.getAllTextFlows().put("id", originalTF);

        // set up a textflow with the same id and different content
        TextFlow changedTF =
                new TextFlow(originalTF.getResId(), LocaleId.EN, "changed text");
        List<TextFlow> from = new ArrayList<TextFlow>();
        from.add(changedTF);

        int newTFRevision = 2;

        boolean changed =
                resourceUtils.transferFromTextFlows(from, to,
                        new HashSet<String>(), newTFRevision);

        Map<Long, HTextFlowTarget> targets =
                to.getAllTextFlows().get("id").getTargets();
        newTarg = targets.get(newLocId);
        assertThat(newTarg.getState(), is(ContentState.New));
        assertThat(newTarg.getVersionNum(), is(newTargVersionBefore));
        assertThat(newTarg.getTextFlowRevision(), is(originalTFRevision));

        fuzzyTarg = targets.get(fuzzyLocId);
        assertThat(fuzzyTarg.getState(), is(ContentState.NeedReview));
        assertThat(fuzzyTarg.getVersionNum(), is(fuzzyTargVersionBefore));
        assertThat(fuzzyTarg.getTextFlowRevision(), is(originalTFRevision));
View Full Code Here

TOP

Related Classes of org.zanata.model.HTextFlowTarget

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.