Package org.zanata.rest.dto.resource

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


        assertThat(actualDoc.toString(),
                Matchers.equalTo(expectedDoc.toString()));
    }

    private Resource createSourceDoc(String name, boolean withTextFlow) {
        Resource resource = new Resource();
        resource.setContentType(ContentType.TextPlain);
        resource.setLang(LocaleId.EN_US);
        resource.setName(name);
        resource.setType(ResourceType.DOCUMENT);

        if (withTextFlow)
            resource.getTextFlows().add(
                    new TextFlow("tf1", LocaleId.EN_US, "hello world"));
        return resource;
    }
View Full Code Here


        trans.getTextFlowTargets().add(target);
        return trans;
    }

    private Resource createSourceResource(String name) {
        Resource sr = new Resource(name);
        sr.setContentType(ContentType.TextPlain);
        sr.setLang(LocaleId.EN);
        sr.setType(ResourceType.FILE);
        return sr;
    }
View Full Code Here

        assertThat(resources.getEntity().size(), is(n));
    }

    private Resource newDoc(String id, TextFlow... textFlows) {
        Resource doc = new Resource(id);
        doc.setLang(LocaleId.EN);
        doc.setContentType(ContentType.TextPlain);
        doc.setType(ResourceType.FILE);
        doc.setRevision(null);
        for (TextFlow textFlow : textFlows) {
            doc.getTextFlows().add(textFlow);
        }
        return doc;
    }
View Full Code Here

        flags.add("flag2");
        List<String> refs = poData.getReferences();
        refs.add("ref1.xml:7");
        refs.add("ref1.xml:21");

        Resource doc = newDoc(id, textflow);
        PoHeader poHeader = new PoHeader();
        poHeader.setComment("poheader comment");
        List<HeaderEntry> poEntries = poHeader.getEntries();
        poEntries.add(new HeaderEntry("Project-Id-Version", "en"));
        poEntries.add(new HeaderEntry("Content-Type",
                "application/x-publican; charset=UTF-8\n"));
        doc.getExtensions(true).add(poHeader);

        log.debug("{}", doc);
        Response response =
                sourceDocResource.putResource(id, doc, extGettextComment);
        assertThat(response.getStatus(), isOneOf(200, 201));
View Full Code Here

        return tr;
    }

    private Resource putDoc1(boolean putTarget) {
        String id = DOC1_NAME;
        Resource doc =
                newDoc(id,
                        newTextFlow("FOOD", "Slime Mould",
                                "slime mould comment"));
        Response response = sourceDocResource.putResource(id, doc, extComment);
        assertThat(response.getStatus(), isOneOf(200, 201));
View Full Code Here

        expectTarget(true, id, DE, target1);
    }

    private Resource putDoc1a(boolean putTarget) {
        String id = DOC1_NAME;
        Resource doc = newDoc(id, newTextFlow("HELLO", "Hello World", null));
        Response response = sourceDocResource.putResource(id, doc, extComment);
        assertThat(response.getStatus(), isOneOf(200, 201));

        if (putTarget)
            putTarget1a();
View Full Code Here

        assertThat(response.getStatus(), is(200));
    }

    private Resource postDoc2(boolean putTarget) {
        String id = DOC2_NAME;
        Resource doc =
                newDoc(id, newTextFlow("HELLO", "Hello World", "hello comment"));
        Response response = sourceDocResource.post(doc, extComment, true);
        assertThat(response.getStatus(), is(201));

        if (putTarget)
View Full Code Here

public class ResourceTestObjectFactory {
    private final Logger log = LoggerFactory
            .getLogger(ResourceTestObjectFactory.class);

    public Resource getTextFlowTest() {
        Resource sr = new Resource("test1");
        sr.setContentType(ContentType.TextPlain);
        sr.setLang(LocaleId.EN_US);
        sr.setType(ResourceType.FILE);
        // for the convenience of test only
        sr.getExtensions(true);

        TextFlow stf = new TextFlow("rest1", LocaleId.EN_US, "tf1");
        stf.getExtensions(true);
        sr.getTextFlows().add(stf);
        log.debug(sr.toString());
        return sr;
    }
View Full Code Here

        log.debug(sr.toString());
        return sr;
    }

    public Resource getTextFlowTest2() {
        Resource sr = new Resource("test2");
        sr.setContentType(ContentType.TextPlain);
        sr.setLang(LocaleId.EN_US);
        sr.setType(ResourceType.FILE);
        sr.getExtensions(true);

        TextFlow stf = new TextFlow("tf1", LocaleId.EN_US, "tf1");
        stf.getExtensions(true);
        TextFlow stf2 = new TextFlow("tf2", LocaleId.EN_US, "testtf2");
        // stf2.getExtensions(true);
        sr.getTextFlows().add(stf);
        sr.getTextFlows().add(stf2);
        return sr;
    }
View Full Code Here

        sr.getTextFlows().add(stf2);
        return sr;
    }

    public Resource getPoHeaderTest() {
        Resource sr = getTextFlowTest();

        PoHeader poHeaderExt =
                new PoHeader("comment", new HeaderEntry("h1", "v1"),
                        new HeaderEntry("h2", "v2"), new HeaderEntry(
                                "Content-Type", "charset=UTF-8"));
        sr.getExtensions(true).add(poHeaderExt);
        return sr;
    }
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.