Package org.zanata.rest.dto.resource

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


    @Test
    public void putDocWithDuplicateTextFlowIds() throws Exception {
        String docName = "testDoc";
        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);
View Full Code Here


    @Test
    public void putNewDocumentWithResources() throws Exception {
        String docName = "my/fancy/document.txt";
        String docUrl = RestUtil.convertToDocumentURIId(docName);
        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);

        // this WAS testing for status 205
        assertThat(response.getStatus(), is(200));

        documentResponse = sourceDocResource.getResource(docUrl, null);
        assertThat(documentResponse.getResponseStatus(), is(Status.OK));
        doc = documentResponse.getEntity();

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

        assertThat("Should have textFlows", doc.getTextFlows(), notNullValue());
        assertThat("Should have two textFlows", doc.getTextFlows().size(),
                is(2));
        assertThat("should have same id", doc.getTextFlows().get(0).getId(),
                is("tf2"));
    }
View Full Code Here

    }

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

    }

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

                new HRawDocument());
        when(
                documentDAO.getByProjectIterationAndDocId(conf.projectSlug,
                        conf.versionSlug, conf.docId)).thenReturn(
                conf.existingDocument);
        Resource document = new Resource();
        when(
                translationFileService.parseUpdatedAdapterDocumentFile(
                        Matchers.<URI> any(), eq(conf.docId),
                        eq(conf.fileType), paramCaptor.capture())).thenReturn(
                document);
View Full Code Here

                    textFlowTargetDAO.findTranslations(document, hLocale);
            resourceUtils.transferToTranslationsResource(translationResource,
                    document, hLocale, extensions, hTargets,
                    Optional.<String> absent());

            Resource res = resourceUtils.buildResource(document);

            String filename = localeDirectory + document.getDocId() + ".po";
            zipOutput.putNextEntry(new ZipEntry(filename));
            poWriter.writePo(zipOutput, "UTF-8", res, translationResource);
            zipOutput.closeEntry();
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.