Package org.zanata.model

Examples of org.zanata.model.HLocale


        EntityMaker entityMaker = EntityMakerBuilder.builder()
                .addFieldOrPropertyMaker(HProject.class, "sourceViewURL",
                        FixedValueMaker.EMPTY_STRING_MAKER).build();
        HProjectIteration iteration = entityMaker
                .makeAndPersist(getEm(), HProjectIteration.class);
        HLocale srcLocale = createAndPersistLocale(LocaleId.EN_US, getEm());
        HLocale transLocale = createAndPersistLocale(LocaleId.DE, getEm());

        String versionSlug = iteration.getSlug();
        String projectSlug = iteration.getProject().getSlug();

        HDocument document = new HDocument("message", ContentType.PO, srcLocale);
        document.setProjectIteration(iteration);
        getEm().persist(document);
        getEm().flush();

        // adjust this number to suit testing purpose
        int numOfTextFlows = 50;
        int numOfTextFlowsHavingTarget =
                createSourceAndSomeTargets(document, transLocale,
                        numOfTextFlows);
        getEm().getTransaction().commit();
        getEm().getTransaction().begin();

        Long targetsCountBefore = getEm().createQuery(
                "select count(*) from HTextFlowTarget where locale = :locale",
                Long.class).setParameter("locale", transLocale).getSingleResult();
        Assertions.assertThat(targetsCountBefore).isEqualTo(numOfTextFlowsHavingTarget);

        // ============ add targets =========
        TranslationsResource translations = new TranslationsResource();
        translations.setRevision(1);
        for (int i = 0; i < numOfTextFlows; i++) {
            addSampleTranslation(translations, "res" + i);
        }
        Monitor mon = MonitorFactory.start("");
        log.info("==== start translateAllInDoc");
        service.translateAllInDoc(projectSlug, versionSlug, document.getDocId(),
                transLocale.getLocaleId(), translations,
                extensions, MergeType.AUTO);
        log.info("==== stop translateAllInDoc: {}", mon.stop());
        getEm().getTransaction().commit();
        getEm().getTransaction().begin();

View Full Code Here


    // FIXME looks like this test does not take more recently added states into
    // account
    // should ensure all states are in test data and check test logic
    @Test
    public void canGetAllUntranslatedTextFlowForADocument() {
        HLocale deLocale = getEm().find(HLocale.class, 3L);
        log.info("locale: {}", deLocale);

        FilterConstraints untranslated =
                FilterConstraints.builder().keepAll().excludeFuzzy()
                        .excludeTranslated().build();
        List<HTextFlow> result =
                dao.getTextFlowByDocumentIdWithConstraints(new DocumentId(1L,
                        ""), deLocale, untranslated, 0, 10);
        assertThat(result.size(), is(0));

        HLocale frLocale = getEm().find(HLocale.class, 6L);
        result =
                dao.getTextFlowByDocumentIdWithConstraints(new DocumentId(1L,
                        ""), frLocale, untranslated, 0, 10);
        assertThat(result.size(), is(1));
    }
View Full Code Here

        assertThat(result.size(), is(1));
    }

    @Test
    public void canGetTextFlowWithNullTarget() {
        HLocale deLocale = getEm().find(HLocale.class, 3L);

        FilterConstraints untranslated =
                FilterConstraints.builder().keepAll().excludeFuzzy()
                        .excludeTranslated().build();
        List<HTextFlow> result =
View Full Code Here

        assertThat(result, Matchers.hasSize(1));
    }

    @Test
    public void canGetTextFlowsByStatusNotNew() {
        HLocale enUSLocale = getEm().find(HLocale.class, 4L);
        // all 3 text flows are fuzzy for en-US in this document
        DocumentId documentId2 = new DocumentId(2L, "");
        List<HTextFlow> result =
                dao.getTextFlowByDocumentIdWithConstraints(documentId2,
                        enUSLocale, FilterConstraints.builder().keepAll()
View Full Code Here

    @Test
    public void canGetTextFlowsByStatusNotFuzzy() {
        // frLocale new in this document
        DocumentId documentId = new DocumentId(1L, "");
        HLocale frLocale = getEm().find(HLocale.class, 6L);
        FilterConstraints notFuzzy =
                FilterConstraints.builder().keepAll().excludeFuzzy().build();

        List<HTextFlow> result =
                dao.getTextFlowByDocumentIdWithConstraints(documentId,
View Full Code Here

    @Test
    public void canGetTextFlowsByStatusNotTranslatedNotNew() {
        // esLocale fuzzy in this document
        DocumentId documentId = new DocumentId(1L, "");
        HLocale esLocale = getEm().find(HLocale.class, 5L);
        FilterConstraints notNewOrTranslated =
                FilterConstraints.builder().keepAll().excludeTranslated()
                        .excludeNew().build();

        List<HTextFlow> result =
View Full Code Here

    @Test
    public void canGetTextFlowsByStatusNotFuzzyNotNew() {
        // deLocale approved in this document
        DocumentId documentId = new DocumentId(1L, "");
        HLocale deLocale = getEm().find(HLocale.class, 3L);
        FilterConstraints notNewOrFuzzy =
                FilterConstraints.builder().keepAll().excludeFuzzy()
                        .excludeNew().build();

        List<HTextFlow> result =
View Full Code Here

        assertThat(result, Matchers.hasSize(1));
    }

    @Test
    public void canGetTextFlowsByStatusNotFuzzyNotTranslated() {
        HLocale enUSLocale = getEm().find(HLocale.class, 4L);
        // all 3 text flows are fuzzy for en-US in this document
        DocumentId documentId2 = new DocumentId(2L, "");
        FilterConstraints notFuzzyOrTranslated =
                FilterConstraints.builder().keepAll().excludeTranslated()
                        .excludeFuzzy().build();
View Full Code Here

    @Test(enabled = false)
    public void thisBreaksForSomeReason() {
        // fails regardless of using different documentId, locale or constraints
        DocumentId id = new DocumentId(1L, "");
        HLocale locale = getEm().find(HLocale.class, 3L);
        FilterConstraints constraints = FilterConstraints.builder().build();

        dao.getTextFlowByDocumentIdWithConstraints(id, locale, constraints, 0,
                10);
        dao.getTextFlowByDocumentIdWithConstraints(id, locale, constraints, 0,
View Full Code Here

                10);
    }

    @Test
    public void testGetTextFlowByDocumentIdWithConstraint() {
        HLocale deLocale = getEm().find(HLocale.class, 3L);

        List<HTextFlow> result =
                dao.getTextFlowByDocumentIdWithConstraints(new DocumentId(
                        new Long(4), ""), deLocale, FilterConstraints.builder()
                        .filterBy("mssg").excludeTranslated().excludeFuzzy()
View Full Code Here

TOP

Related Classes of org.zanata.model.HLocale

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.