Package org.zanata.service

Examples of org.zanata.service.TranslationService$TranslationResult


                .useImpl(ValidationServiceImpl.class).ignoreNonResolvable();
    }

    @Test
    public void translate() throws Exception {
        TranslationService transService =
                seam.autowire(TranslationServiceImpl.class);

        TransUnitId transUnitId = new TransUnitId(1L);
        List<String> newContents = new ArrayList<String>(2);
        newContents.add("translated 1");
        newContents.add("translated 2");
        TransUnitUpdateRequest translateReq =
                new TransUnitUpdateRequest(transUnitId, newContents,
                        ContentState.Approved, 1);

        List<TranslationResult> result =
                transService.translate(new LocaleId("de"),
                        Lists.newArrayList(translateReq));

        assertThat(result.get(0).isTranslationSuccessful(), is(true));
        assertThat(result.get(0).getBaseVersionNum(), is(1));
        assertThat(result.get(0).getBaseContentState(),
View Full Code Here


                is(2)); // moved up a version
    }

    @Test
    public void translateMultiple() throws Exception {
        TranslationService transService =
                seam.autowire(TranslationServiceImpl.class);

        List<TransUnitUpdateRequest> translationReqs =
                new ArrayList<TransUnitUpdateRequest>();

        // Request 1
        TransUnitId transUnitId = new TransUnitId(1L);
        List<String> newContents = new ArrayList<String>(2);
        newContents.add("translated 1");
        newContents.add("translated 2");
        translationReqs.add(new TransUnitUpdateRequest(transUnitId,
                newContents, ContentState.Approved, 1));

        // Request 2 (different documents)
        transUnitId = new TransUnitId(2L);
        newContents = new ArrayList<String>(2);
        newContents.add("translated 1");
        newContents.add("translated 2");
        translationReqs.add(new TransUnitUpdateRequest(transUnitId,
                newContents, ContentState.NeedReview, 0));

        List<TranslationResult> results =
                transService.translate(new LocaleId("de"), translationReqs);

        // First result
        TranslationResult result = results.get(0);
        assertThat(result.isTranslationSuccessful(), is(true));
        assertThat(result.getBaseVersionNum(), is(1));
View Full Code Here

                                                                                 // version
    }

    @Test
    public void incorrectBaseVersion() throws Exception {
        TranslationService transService =
                seam.autowire(TranslationServiceImpl.class);

        TransUnitId transUnitId = new TransUnitId(2L);
        List<String> newContents = new ArrayList<String>(2);
        newContents.add("translated 1");
        newContents.add("translated 2");
        TransUnitUpdateRequest translateReq =
                new TransUnitUpdateRequest(transUnitId, newContents,
                        ContentState.Approved, 1);

        // Should not pass as the base version (1) does not match
        List<TransUnitUpdateRequest> translationRequests =
                Lists.newArrayList(translateReq);
        List<TranslationResult> result =
                transService.translate(new LocaleId("de"), translationRequests);

        assertThat(result.get(0).isTranslationSuccessful(), Matchers.is(false));
    }
View Full Code Here

        assertThat(result.get(0).isTranslationSuccessful(), Matchers.is(false));
    }

    @Test
    public void willCheckPermissionForReviewState() {
        TranslationService transService =
                seam.autowire(TranslationServiceImpl.class);

        // untranslated
        TransUnitId transUnitId = new TransUnitId(3L);
        TransUnitUpdateRequest translateReq =
                new TransUnitUpdateRequest(transUnitId, Lists.newArrayList("a",
                        "b"), ContentState.Approved, 0);

        List<TranslationResult> result =
                transService.translate(new LocaleId("de"),
                        Lists.newArrayList(translateReq));

        verify(identity).checkPermission(eq("translation-review"),
                isA(HProject.class), isA(HLocale.class));
        assertThat(result.get(0).isTranslationSuccessful(), is(true));
View Full Code Here

TOP

Related Classes of org.zanata.service.TranslationService$TranslationResult

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.