Examples of TextFlow


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

    @Test
    public void createResourceWithContentUsingPut() {
        Resource sr = createSourceResource("my.txt");

        TextFlow stf = new TextFlow("tf1", LocaleId.EN, "tf1");
        sr.getTextFlows().add(stf);

        ClientResponse<String> response =
                sourceDocResource.putResource("my.txt", sr, null);
        assertThat(response.getResponseStatus(), is(Status.CREATED));
View Full Code Here

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

    public void createPoResourceWithPoHeader() {
        String docName = "my.txt";
        String docUri = RestUtil.convertToDocumentURIId(docName);
        Resource sr = createSourceResource(docName);

        TextFlow stf = new TextFlow("tf1", LocaleId.EN, "tf1");
        sr.getTextFlows().add(stf);

        // @formatter:off
        /*
        TODO: move this into an AbstractResourceMeta test (PoHeader is valid for source documents, not target)
View Full Code Here

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

        String docUrl = RestUtil.convertToDocumentURIId(docName);
        Resource doc = createSourceDoc(docName, false);
        List<TextFlow> textFlows = doc.getTextFlows();

        for (int i = 0; i < 2; i++) {
            TextFlow textFlow = new TextFlow("tf1");
            textFlow.setContents("hello world!");
            textFlows.add(textFlow);
        }
        ClientResponse<?> response =
                sourceDocResource.putResource(docUrl, doc, null);
        assertThat(response.getStatus(), is(Status.BAD_REQUEST.getStatusCode()));
View Full Code Here

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

        Resource doc = createSourceDoc(docName, false);

        List<TextFlow> textFlows = doc.getTextFlows();
        textFlows.clear();

        TextFlow textFlow = new TextFlow("tf1");
        textFlow.setContents("hello world!");
        textFlows.add(textFlow);

        TextFlow tf3 = new TextFlow("tf3");
        tf3.setContents("more text");
        textFlows.add(tf3);

        // Marshaller m = null;
        // JAXBContext jc = JAXBContext.newInstance(Resource.class);
        // m = jc.createMarshaller();
        // m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        // m.marshal(doc, System.out);

        Response response = sourceDocResource.putResource(docUrl, doc, null);

        assertThat(response.getStatus(), is(Status.CREATED.getStatusCode()));
        assertThat(response.getMetadata().getFirst("Location").toString(),
                endsWith(RESOURCE_PATH + docUrl));

        ClientResponse<Resource> documentResponse =
                sourceDocResource.getResource(docUrl, null);

        assertThat(documentResponse.getResponseStatus(), is(Status.OK));

        doc = documentResponse.getEntity();

        assertThat(doc.getRevision(), is(1));

        assertThat("Should have textFlows", doc.getTextFlows(), notNullValue());
        assertThat("Should have 2 textFlows", doc.getTextFlows().size(), is(2));
        assertThat("Should have tf1 textFlow", doc.getTextFlows().get(0)
                .getId(), is("tf1"));
        assertThat("Container1 should have tf3 textFlow", doc.getTextFlows()
                .get(1).getId(), is(tf3.getId()));

        textFlow = doc.getTextFlows().get(0);
        textFlow.setId("tf2");

        response = sourceDocResource.putResource(docUrl, doc, null);
View Full Code Here

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

    @Test
    public void put1Get() 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);
View Full Code Here

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

    @Test
    public void put1Post2Get() 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);
        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);
        tft2.setRevision(1);
        expectDocs(true, false, doc1, doc2);
View Full Code Here

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

    @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);
View Full Code Here

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

    @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

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

    @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

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

    @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);
        dontExpectTarget1();
        expectTarget1a(target1a);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.