Package org.zanata.rest.dto.resource

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


        sr.getExtensions(true).add(poHeaderExt);
        return sr;
    }

    public Resource getPotEntryHeaderTest() {
        Resource sr = getTextFlowTest();
        TextFlow stf = sr.getTextFlows().get(0);

        PotEntryHeader potEntryHeader = new PotEntryHeader();
        potEntryHeader.setContext("potentrycontext");
        // for the convenience of test only
        potEntryHeader.getFlags().add("");
View Full Code Here


        stf.getExtensions(true).add(potEntryHeader);
        return sr;
    }

    public Resource getTextFlowCommentTest() {
        Resource sr = getTextFlowTest();
        TextFlow stf = sr.getTextFlows().get(0);

        SimpleComment simpleComment = new SimpleComment("textflow comment");

        stf.getExtensions(true).add(simpleComment);
        return sr;
View Full Code Here

        stf.getExtensions(true).add(simpleComment);
        return sr;
    }

    public Resource getPotEntryHeaderComment() {
        Resource sr = getTextFlowTest();
        TextFlow stf = sr.getTextFlows().get(0);
        SimpleComment simpleComment = new SimpleComment("textflow comment");

        PotEntryHeader potEntryHeader = new PotEntryHeader();
        potEntryHeader.setContext("potentrycontext");
View Full Code Here

    static void clearRevs(AbstractResourceMeta doc) {
        doc.setRevision(null);

        if (doc instanceof Resource) {
            Resource res = (Resource) doc;
            final List<TextFlow> textFlows = res.getTextFlows();
            if (textFlows != null)
                for (TextFlow tf : textFlows) {
                    tf.setRevision(null);
                }
        }
View Full Code Here

                        .addFieldOrPropertyMaker(
                                HProject.class, "sourceViewURL",
                                FixedValueMaker.EMPTY_STRING_MAKER).build()
                        .makeAndPersist(getEm(),
                                HProjectIteration.class);
        Resource from = new Resource("message");
        from.setContentType(ContentType.PO);
        LocaleId localeId = locale.getLocaleId();
        // adjust this number to suit testing purpose
        int numOfTextFlows = 50;
        for (int i = 0; i < numOfTextFlows; i++) {
            addSampleTextFlow(from, localeId, i);
        }

        // this is the same from org/zanata/service/impl/DocumentServiceImpl.java:140
        HDocument to = new HDocument(from.getName(), from.getContentType(), locale);
        to.setProjectIteration(iteration);
        getEm().persist(to);
        getEm().flush();

View Full Code Here

        resources.add(translatedDocResourceService);
    }

    @Test
    public void testDeleteTranslation() {
        Resource res = resourceTestFactory.getTextFlowTest();
        sourceDocResource.putResource(res.getName(), res, new StringSet(
                "gettext;comment"));
        TranslationsResource sr = transTestFactory.getTestObject();
        translationResource.putTranslations(res.getName(), DE, sr,
                new StringSet("gettext;comment"));
        ClientResponse<String> resourceGetResponse =
                translationResource.deleteTranslations(res.getName(), DE);
        assertThat(resourceGetResponse.getResponseStatus(), is(Status.OK));

        ClientResponse<String> resourceGetResponse2 =
                translationResource.deleteTranslations("test2", FR);
        assertThat(resourceGetResponse2.getResponseStatus(),
View Full Code Here

    }

    @Test(dataProvider = "TranslationTestData")
    public void testPutGetTranslation(String desc, TranslationsResource sr) {
        sr = cloneDTO(sr);
        Resource res = resourceTestFactory.getTextFlowTest();
        sourceDocResource.putResource(res.getName(), res, new StringSet(
                "gettext;comment"));
        log.debug("successful put resource:" + res.getName());
        translationResource.putTranslations(res.getName(), DE, sr,
                new StringSet("gettext;comment"));
        TranslationsResource get =
                translationResource.getTranslations(res.getName(), DE,
                        new StringSet("gettext;comment")).getEntity();
        log.debug("expect:" + sr.toString());
        log.debug("actual:" + get.toString());
        ResourceTestUtil.clearRevs(sr);
        ResourceTestUtil.clearRevs(get);
View Full Code Here

    @Test(dataProvider = "TranslationTestData")
    public void testPutGetTranslationNoExtension(String desc,
            TranslationsResource sr) {
        sr = cloneDTO(sr);
        Resource res = resourceTestFactory.getTextFlowTest();
        sourceDocResource.putResource(res.getName(), res, new StringSet(
                "gettext;comment"));
        log.debug("successful put resource:" + res.getName());
        translationResource.putTranslations(res.getName(), DE, sr, null);
        TranslationsResource get =
                translationResource.getTranslations(res.getName(), DE, null)
                        .getEntity();
        TranslationsResource base = transTestFactory.getTestObject();
        ResourceTestUtil.clearRevs(base);
        ResourceTestUtil.clearRevs(get);
        log.debug("expect:" + base.toString());
View Full Code Here

    @Test(dataProvider = "TranslationTestData",
            dependsOnMethods = { "testPutGetTranslation" })
    public void testPutNoExtensionGetTranslation(String desc,
            TranslationsResource sr) {
        sr = cloneDTO(sr);
        Resource res = resourceTestFactory.getTextFlowTest();
        sourceDocResource.putResource(res.getName(), res, new StringSet(
                "gettext;comment"));
        log.debug("successful put resource:" + res.getName());
        translationResource.putTranslations(res.getName(), DE, sr, null);
        TranslationsResource get =
                translationResource.getTranslations(res.getName(), DE,
                        new StringSet("gettext;comment")).getEntity();
        TranslationsResource base = transTestFactory.getTestObject();
        ResourceTestUtil.clearRevs(base);
        ResourceTestUtil.clearRevs(get);
        log.debug("expect:" + base.toString());
View Full Code Here

    @Test(dataProvider = "TranslationTestData")
    public void testPutGetNoExtensionTranslation(String desc,
            TranslationsResource sr) {
        sr = cloneDTO(sr);
        Resource res = resourceTestFactory.getTextFlowTest();
        sourceDocResource.putResource(res.getName(), res, new StringSet(
                "gettext;comment"));
        log.debug("successful put resource:" + res.getName());
        translationResource.putTranslations(res.getName(), DE, sr,
                new StringSet("gettext;comment"));
        TranslationsResource get =
                translationResource.getTranslations(res.getName(), DE, null)
                        .getEntity();
        TranslationsResource base = transTestFactory.getTestObject();
        ResourceTestUtil.clearRevs(base);
        ResourceTestUtil.clearRevs(get);
        log.debug("expect:" + base.toString());
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.