Package org.zanata.model.tm

Examples of org.zanata.model.tm.TransMemory


    @Test
    @org.junit.Test
    public void mergeSameTM() throws Exception {
        // Initial load
        TransMemory tm = createTMFromFile("/tmx/default-valid-tm.tmx");

        // Make sure everything is stored properly
        tm = getEm().find(TransMemory.class, tm.getId());
        assertThat(tm.getTranslationUnits().size(), is(4));

        // Second load (should yield the same result)
        populateTMFromFile(tm, "/tmx/default-valid-tm.tmx");

        tm = getEm().find(TransMemory.class, tm.getId());
        assertThat(tm.getTranslationUnits().size(), is(4));
    }
View Full Code Here


                "org/zanata/test/model/ClearAllTables.dbunit.xml",
                DatabaseOperation.DELETE_ALL));
    }

    private TransMemory createDefaultTransMemoryInstance() {
        TransMemory tm = new TransMemory();
        tm.setSlug("new-trans-memory");
        return tm;
    }
View Full Code Here

                .add(Restrictions.naturalId().set("slug", slug)).uniqueResult();
    }

    @Test
    public void save() throws Exception {
        TransMemory tm = createDefaultTransMemoryInstance();
        super.getEm().persist(tm);

        TransMemory stored = loadTM("new-trans-memory");

        assertThat(stored.getSlug(), is(tm.getSlug()));
    }
View Full Code Here

        assertThat(stored.getSlug(), is(tm.getSlug()));
    }

    @Test
    public void saveWithMetadata() throws Exception {
        TransMemory tm = createDefaultTransMemoryInstance();
        String defaultMetadataVal = "This is a test";
        tm.getMetadata().put(TMMetadataType.TMX14, defaultMetadataVal);
        super.getEm().persist(tm);

        TransMemory stored = loadTM("new-trans-memory");
        assertThat(stored.getSlug(), is(tm.getSlug()));
        assertThat(stored.getMetadata().size(), is(tm.getMetadata().size()));
        assertThat(stored.getMetadata().get(TMMetadataType.TMX14),
                equalTo(defaultMetadataVal));
    }
View Full Code Here

                equalTo(defaultMetadataVal));
    }

    @Test
    public void saveWithTransUnits() throws Exception {
        TransMemory tm = createDefaultTransMemoryInstance();

        // add some units
        for (int i = 0; i < NUM_TRANS_UNITS; i++) {
            TransMemoryUnit unit = new TransMemoryUnit("uid:" + i);
            unit.setTranslationMemory(tm);
            unit.setSourceLanguage("en-US");
            unit.setTransUnitId("unit-id-" + i);
            tm.getTranslationUnits().add(unit);
        }

        super.getEm().persist(tm);

        // Fetch it, should have the same elements
        TransMemory stored = loadTM("new-trans-memory");

        assertThat(stored.getTranslationUnits().size(), is(NUM_TRANS_UNITS));
    }
View Full Code Here

        assertThat(stored.getTranslationUnits().size(), is(NUM_TRANS_UNITS));
    }

    @Test
    public void saveTransUnitsWithMetadata() throws Exception {
        TransMemory tm = createDefaultTransMemoryInstance();

        // add some units
        for (int i = 0; i < NUM_TRANS_UNITS; i++) {
            TransMemoryUnit unit = new TransMemoryUnit("uid:" + i);
            unit.setTranslationMemory(tm);
            unit.setSourceLanguage("en-US");
            unit.setTransUnitId("unit-id-" + i);
            unit.setMetadata(TMMetadataType.TMX14, "Metadata " + i);
            tm.getTranslationUnits().add(unit);
        }

        super.getEm().persist(tm);

        // Fetch it, should have the same elements
        TransMemory stored = loadTM("new-trans-memory");

        assertThat(stored.getTranslationUnits().size(), is(NUM_TRANS_UNITS));
        for (TransMemoryUnit tu : tm.getTranslationUnits()) {
            assertThat(tu.getMetadata(TMMetadataType.TMX14),
                    startsWith("Metadata "));
        }
    }
View Full Code Here

        // Save them from the bottom up, as that is probably how it will need to
        // be done due to the large amount of them
        saveWithTransUnits();

        // Fetch the translation memory
        TransMemory stored = loadTM("new-trans-memory");

        // For each trans unit, generate some variants
        for (TransMemoryUnit tu : stored.getTranslationUnits()) {
            TransMemoryUnitVariant tuvES =
                    new TransMemoryUnitVariant("es",
                            "<seg>Mensaje de Prueba</seg>");
            TransMemoryUnitVariant tuvEN =
                    new TransMemoryUnitVariant("en-US",
View Full Code Here

        // Save them from the bottom up, as that is probably how it will need to
        // be done due to the large amount of them
        saveWithTransUnits();

        // Fetch the translation memory
        TransMemory stored = loadTM("new-trans-memory");

        // Store a Trans unit variant with formatting
        TransMemoryUnit tu = stored.getTranslationUnits().iterator().next();
        TransMemoryUnitVariant tuvES =
                new TransMemoryUnitVariant("es",
                        "<seg>Mensaje <bpt>&lt;b></bpt>de<ept i=\"1\">&lt;b></ept> Prueba</seg>");

        tu.getTransUnitVariants().put(tuvES.getLanguage(), tuvES);
View Full Code Here

    public static DocumentInfo documentInfo(long id) {
        return documentInfo(id, "");
    }

    public static TransMemoryUnit makeTransMemoryUnit(Long l, HLocale hLocale) {
        TransMemory tm = new TransMemory();
        tm.setSlug("test-tm");

        return TransMemoryUnit.tu(tm, "uid" + l, "uid" + l, hLocale
                .getLocaleId().getId(), "<seg>source</seg>",
                TransMemoryUnitVariant.tuv("lang", "<seg>target</seg>"));
    }
View Full Code Here

TOP

Related Classes of org.zanata.model.tm.TransMemory

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.