Package org.zanata.rest.dto.resource

Examples of org.zanata.rest.dto.resource.Resource


        String projectType = "gettext";
        restCaller.createProjectAndVersion(projectSlug, iterationSlug,
                projectType);

        String docId = "messages";
        Resource sourceResource = buildSourceResource(docId);
        TranslationsResource transResource = buildTranslationResource();
        int numOfMessages = 10;
        for (int i = 0; i < numOfMessages; i++) {
            String resId = "res" + i;
            String content = "content" + i;
            sourceResource.getTextFlows().add(buildTextFlow(resId, content));
            transResource.getTextFlowTargets().add(
                    buildTextFlowTarget(resId, content));
        }
        restCaller.asyncPushSource(projectSlug, iterationSlug, sourceResource,
                false);
        LocaleId localeId = new LocaleId("pl");
        restCaller.asyncPushTarget(projectSlug, iterationSlug, docId,
                localeId, transResource, "auto");
        restCaller.runCopyTrans(projectSlug, iterationSlug, docId);

        assertThat(true, Matchers.is(true));

        // create some obsolete text flows
        Resource updatedSource = buildSourceResource(docId);
        TranslationsResource updatedTransResource = buildTranslationResource();
        for (int i = 0; i < numOfMessages; i++) {
            String resId = "res" + i;
            String content = "content" + i + " changed";
            updatedSource.getTextFlows().add(buildTextFlow(resId, content));
            updatedTransResource.getTextFlowTargets().add(buildTextFlowTarget(resId, content));
        }

        // push updated source (same resId different content)
        restCaller.asyncPushSource(projectSlug, iterationSlug, updatedSource, false);
View Full Code Here


    public Resource parseUpdatedAdapterDocumentFile(URI documentFile,
            String docId, String fileName, Optional<String> params)
            throws ZanataServiceException {
        if (hasAdapterFor(fileName)) {
            FileFormatAdapter adapter = getAdapterFor(fileName);
            Resource doc;
            try {
                doc =
                        adapter.parseDocumentFile(documentFile, new LocaleId(
                                "en"), params);
            } catch (FileFormatAdapterException e) {
                throw new ZanataServiceException(
                        "Error parsing document file: " + fileName, e);
            }
            doc.setName(docId);
            return doc;
        } else {
            throw new ZanataServiceException("Unsupported Document file: "
                    + fileName);
        }
View Full Code Here

    private Resource parsePotFile(InputStream fileContents, String docId,
            boolean offlinePo) {
        PoReader2 poReader = new PoReader2(offlinePo);
        // assume english as source locale
        Resource res =
                poReader.extractTemplate(new InputSource(fileContents),
                        new LocaleId("en"), docId);
        return res;
    }
View Full Code Here

    }

    @Test
    public void put1Post2Put1() throws Exception {
        getZero();
        Resource doc1 = putDoc1(false);
        doc1.setRevision(1);
        TextFlow tf1 = doc1.getTextFlows().get(0);
        tf1.setRevision(1);
        TranslationsResource target1 = putTarget1();
        TextFlowTarget tft1 = target1.getTextFlowTargets().get(0);
        tft1.setTextFlowRevision(1);
        Resource doc2 = postDoc2(false);
        doc2.setRevision(1);
        TextFlow tf2 = doc2.getTextFlows().get(0);
        tf2.setRevision(1);
        TranslationsResource target2 = putTarget2();
        TextFlowTarget tft2 = target2.getTextFlowTargets().get(0);
        tft2.setTextFlowRevision(1);
        expectDocs(true, false, doc1, doc2);
        tft1.setRevision(1);
        tft2.setRevision(1);
        expectTarget1(target1);
        expectTarget2(target2);
        // this put should have the effect of deleting doc2
        putDoc1(false);
        deleteDoc2();
        // should be identical to doc1 from before, including revisions
        expectDocs(true, false, doc1);
        expectTarget1(target1);
        dontExpectTarget2();
        // expectTargets(true, FR, target2);
        // use dao to check that doc2 is marked obsolete
        verifyObsoleteDocument(doc2.getName());
    }
View Full Code Here

    }

    @Test
    public void put1Delete1Put1() throws Exception {
        getZero();
        Resource doc1 = putDoc1(false);
        doc1.setRevision(1);
        TextFlow tf1 = doc1.getTextFlows().get(0);
        tf1.setRevision(1);
        TranslationsResource target1 = putTarget1();
        TextFlowTarget tft1 = target1.getTextFlowTargets().get(0);
        tft1.setTextFlowRevision(1);
        expectDocs(true, false, doc1);
        tft1.setRevision(1);
        expectTarget1(target1);
        deleteDoc1(); // doc1 becomes obsolete
        getZero();
        dontExpectTarget1();
        putDoc1(false); // doc1 resurrected, rev 1
        doc1.setRevision(1);
        tf1.setRevision(1);
        tft1.setTextFlowRevision(1);
        expectDocs(true, false, doc1);
        expectTarget1(target1);
    }
View Full Code Here

    }

    @Test
    public void put1Put1Again() throws Exception {
        getZero();
        Resource doc1 = putDoc1(false);
        doc1.setRevision(1);
        TextFlow tf1 = doc1.getTextFlows().get(0);
        tf1.setRevision(1);
        TranslationsResource target1 = putTarget1();
        TextFlowTarget tft1 = target1.getTextFlowTargets().get(0);
        tft1.setTextFlowRevision(1);
        tft1.setRevision(1);
        expectDocs(true, false, doc1);
        expectTarget1(target1);
        putDoc1(false); // docRev still 1
        doc1.setRevision(1);
        tf1.setRevision(1);
        tft1.setTextFlowRevision(1);
        expectDocs(true, false, doc1);
        expectTarget1(target1);
    }
View Full Code Here

    }

    @Test
    public void put1Delete1Put1a() throws Exception {
        getZero();
        Resource doc1 = putDoc1(false);
        doc1.setRevision(1);
        TextFlow tf1 = doc1.getTextFlows().get(0);
        tf1.setRevision(1);
        TranslationsResource target1 = putTarget1();
        TextFlowTarget tft1 = target1.getTextFlowTargets().get(0);
        tft1.setTextFlowRevision(1);
        expectDocs(true, false, doc1);
        tft1.setRevision(1);
        expectTarget1(target1);
        deleteDoc1(); // doc1 becomes obsolete
        getZero();
        dontExpectTarget1();
        Resource doc1a = putDoc1a(false); // doc1 resurrected, rev 2
        doc1a.setRevision(2);
        TextFlow tf1a = doc1a.getTextFlows().get(0);
        tf1a.setRevision(doc1a.getRevision());
        TranslationsResource target1a = putTarget1a();
        TextFlowTarget tft1a = target1a.getTextFlowTargets().get(0);
        tft1a.setTextFlowRevision(tf1a.getRevision());
        tft1a.setRevision(1);
        expectDocs(true, false, doc1a);
View Full Code Here

    }

    @Test
    public void putPoPotGet() throws Exception {
        getZero();
        Resource po1 = putPo1();
        expectDocs(false, false, po1);
        TranslationsResource poTarget1 = putPoTarget1();
        expectTarget(false, po1.getName(), DE, poTarget1);
    }
View Full Code Here

    }

    @Test
    public void put1Put1aPut1() throws Exception {
        getZero();
        Resource doc1 = putDoc1(false);
        doc1.setRevision(1);
        TextFlow tf1 = doc1.getTextFlows().get(0);
        tf1.setRevision(1);
        TranslationsResource target1 = putTarget1();
        TextFlowTarget tft1 = target1.getTextFlowTargets().get(0);
        tft1.setTextFlowRevision(1);
        tft1.setRevision(1);
        expectDocs(true, false, doc1);
        expectTarget1(target1);
        // this should completely replace doc1's textflow FOOD with HELLO
        Resource doc1a = putDoc1a(false);
        doc1a.setRevision(2);
        TextFlow tf1a = doc1a.getTextFlows().get(0);
        tf1a.setRevision(2);
        TranslationsResource target1a = putTarget1a();
        TextFlowTarget tft1a = target1a.getTextFlowTargets().get(0);
        tft1a.setTextFlowRevision(2);
        tft1a.setRevision(1);
View Full Code Here

                ResourceTestUtil.clearRevs(expectedDoc);
            ClientResponse<Resource> response =
                    sourceDocResource.getResource(expectedDoc.getName(),
                            extGettextComment);
            assertThat(response.getStatus(), is(200));
            Resource actualDoc = response.getEntity();
            if (!checkRevs)
                ResourceTestUtil.clearRevs(actualDoc);
            createExtensionSets(expectedDoc);
            createExtensionSets(actualDoc);
            assertThat(actualDoc, Matchers.equalTo(expectedDoc));
View Full Code Here

TOP

Related Classes of org.zanata.rest.dto.resource.Resource

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.