Package org.zanata.apicompat.rest.dto.resource

Examples of org.zanata.apicompat.rest.dto.resource.TranslationsResource


            @Override
            protected void onResponse(ClientResponse response) {
                assertThat(response.getStatus(), is(Status.OK.getStatusCode())); // 200
                assertJsonUnmarshal(response, TranslationsResource.class);

                TranslationsResource transRes =
                        jsonUnmarshal(response, TranslationsResource.class);
                assertThat(transRes.getTextFlowTargets().size(),
                        greaterThanOrEqualTo(3));

                // First Text Flow Target
                TextFlowTarget tft1 = transRes.getTextFlowTargets().get(0);
                assertThat(tft1.getResId(), is("tf2"));
                assertThat(tft1.getState(), is(ContentState.NeedReview));
                assertThat(tft1.getContents().get(0), is("mssgTrans1"));
                assertThat(
                        tft1.getExtensions(true)
                                .findByType(SimpleComment.class).getValue(),
                        is("Text Flow Target Comment 1"));
                assertThat(tft1.getTranslator().getName(), is("Sample User"));
                assertThat(tft1.getTranslator().getEmail(),
                        is("user1@localhost"));

                // Second Text Flow Target
                TextFlowTarget tft2 = transRes.getTextFlowTargets().get(1);
                assertThat(tft2.getResId(), is("tf3"));
                assertThat(tft2.getState(), is(ContentState.NeedReview));
                assertThat(tft2.getContents().get(0), is("mssgTrans2"));
                assertThat(
                        tft2.getExtensions(true)
                                .findByType(SimpleComment.class).getValue(),
                        is("Text Flow Target Comment 2"));
                assertThat(tft2.getTranslator().getName(), is("Sample User"));
                assertThat(tft2.getTranslator().getEmail(),
                        is("user1@localhost"));

                // First Text Flow Target
                TextFlowTarget tft3 = transRes.getTextFlowTargets().get(2);
                assertThat(tft3.getResId(), is("tf4"));
                assertThat(tft3.getState(), is(ContentState.NeedReview));
                assertThat(tft3.getContents().get(0), is("mssgTrans3"));
                assertThat(
                        tft3.getExtensions(true)
View Full Code Here


                        ITranslatedDocResource.class,
                        "/projects/p/sample-project/iterations/i/1.0/r/");
        ClientResponse<TranslationsResource> response =
                translationsClient.getTranslations("my,path,document-2.txt",
                        LocaleId.EN_US, new StringSet(SimpleComment.ID));
        final TranslationsResource transRes = response.getEntity();

        assertThat(response.getStatus(), is(Status.OK.getStatusCode())); // 200
        assertThat(transRes.getTextFlowTargets().size(),
                greaterThanOrEqualTo(3));

        // Alter the translations
        transRes.getTextFlowTargets().get(0).setContents("Translated 1");
        transRes.getTextFlowTargets().get(1).setContents("Translated 2");
        transRes.getTextFlowTargets().get(2).setContents("Translated 3");

        transRes.getTextFlowTargets().get(0).setState(ContentState.Approved);
        transRes.getTextFlowTargets().get(1).setState(ContentState.Approved);
        transRes.getTextFlowTargets().get(2).setState(ContentState.Approved);

        transRes.getTextFlowTargets().get(0).getExtensions(true)
                .add(new SimpleComment("Translated Comment 1"));
        transRes.getTextFlowTargets().get(1).getExtensions(true)
                .add(new SimpleComment("Translated Comment 2"));
        transRes.getTextFlowTargets().get(2).getExtensions(true)
                .add(new SimpleComment("Translated Comment 3"));

        // Put the translations
        new ResourceRequest(
                getRestEndpointUrl("/projects/p/sample-project/iterations/i/1.0/r/my,path,document-2.txt/translations/"
                        + LocaleId.EN_US), "PUT", getAuthorizedEnvironment()) {
            @Override
            protected void prepareRequest(ClientRequest request) {
                request.queryParameter("ext", SimpleComment.ID);
                request.body(MediaType.APPLICATION_JSON, jsonMarshal(transRes));
            }

            @Override
            protected void onResponse(ClientResponse response) {
                assertThat(response.getStatus(), is(Status.OK.getStatusCode())); // 200
            }
        }.run();

        // Retrieve the translations once more to make sure they were changed
        // accordingly
        response =
                translationsClient.getTranslations("my,path,document-2.txt",
                        LocaleId.EN_US, new StringSet(SimpleComment.ID));
        TranslationsResource updatedTransRes = response.getEntity();

        assertThat(response.getStatus(), is(Status.OK.getStatusCode())); // 200
        assertThat(updatedTransRes.getTextFlowTargets().size(),
                greaterThanOrEqualTo(3));

        // First Text Flow Target
        TextFlowTarget tft1 = updatedTransRes.getTextFlowTargets().get(0);
        assertThat(tft1.getResId(), is("tf2"));
        assertThat(tft1.getState(), is(ContentState.Approved));
        assertThat(tft1.getContents().get(0), is("Translated 1"));
        assertThat(tft1.getExtensions(true).findByType(SimpleComment.class)
                .getValue(), is("Translated Comment 1"));
        assertThat(tft1.getTranslator().getName(), is("Sample User"));
        assertThat(tft1.getTranslator().getEmail(), is("user1@localhost"));

        // Second Text Flow Target
        TextFlowTarget tft2 = updatedTransRes.getTextFlowTargets().get(1);
        assertThat(tft2.getResId(), is("tf3"));
        assertThat(tft2.getState(), is(ContentState.Approved));
        assertThat(tft2.getContents().get(0), is("Translated 2"));
        assertThat(tft2.getExtensions(true).findByType(SimpleComment.class)
                .getValue(), is("Translated Comment 2"));
        assertThat(tft2.getTranslator().getName(), is("Sample User"));
        assertThat(tft2.getTranslator().getEmail(), is("user1@localhost"));

        // First Text Flow Target
        TextFlowTarget tft3 = updatedTransRes.getTextFlowTargets().get(2);
        assertThat(tft3.getResId(), is("tf4"));
        assertThat(tft3.getState(), is(ContentState.Approved));
        assertThat(tft3.getContents().get(0), is("Translated 3"));
        assertThat(tft3.getExtensions(true).findByType(SimpleComment.class)
                .getValue(), is("Translated Comment 3"));
View Full Code Here

                        ITranslatedDocResource.class,
                        "/projects/p/sample-project/iterations/i/1.0/r/");
        ClientResponse<TranslationsResource> response =
                translationsClient.getTranslations("my,path,document-2.txt",
                        LocaleId.EN_US, new StringSet(SimpleComment.ID));
        TranslationsResource transRes = response.getEntity();

        assertThat(response.getStatus(), is(Status.OK.getStatusCode())); // 200
        assertThat(transRes.getTextFlowTargets().size(),
                greaterThanOrEqualTo(3));

        // First Text Flow Target
        TextFlowTarget tft1 = transRes.getTextFlowTargets().get(0);
        assertThat(tft1.getResId(), is("tf2"));
        assertThat(tft1.getState(), is(ContentState.NeedReview));
        assertThat(tft1.getContents().get(0), is("mssgTrans1"));
        assertThat(tft1.getExtensions(true).findByType(SimpleComment.class)
                .getValue(), is("Text Flow Target Comment 1"));
        assertThat(tft1.getTranslator().getName(), is("Sample User"));
        assertThat(tft1.getTranslator().getEmail(), is("user1@localhost"));

        // Second Text Flow Target
        TextFlowTarget tft2 = transRes.getTextFlowTargets().get(1);
        assertThat(tft2.getResId(), is("tf3"));
        assertThat(tft2.getState(), is(ContentState.NeedReview));
        assertThat(tft2.getContents().get(0), is("mssgTrans2"));
        assertThat(tft2.getExtensions(true).findByType(SimpleComment.class)
                .getValue(), is("Text Flow Target Comment 2"));
        assertThat(tft2.getTranslator().getName(), is("Sample User"));
        assertThat(tft2.getTranslator().getEmail(), is("user1@localhost"));

        // First Text Flow Target
        TextFlowTarget tft3 = transRes.getTextFlowTargets().get(2);
        assertThat(tft3.getResId(), is("tf4"));
        assertThat(tft3.getState(), is(ContentState.NeedReview));
        assertThat(tft3.getContents().get(0), is("mssgTrans3"));
        assertThat(tft3.getExtensions(true).findByType(SimpleComment.class)
                .getValue(), is("Text Flow Target Comment 3"));
View Full Code Here

                        ITranslatedDocResource.class,
                        "/projects/p/sample-project/iterations/i/1.0/r/");
        ClientResponse<TranslationsResource> response =
                translationsClient.getTranslations("my,path,document-2.txt",
                        LocaleId.EN_US, new StringSet(SimpleComment.ID));
        TranslationsResource transRes = response.getEntity();

        assertThat(response.getStatus(), is(Status.OK.getStatusCode())); // 200
        assertThat(transRes.getTextFlowTargets().size(),
                greaterThanOrEqualTo(3));

        // Alter the translations
        transRes.getTextFlowTargets().get(0).setContents("Translated 1");
        transRes.getTextFlowTargets().get(1).setContents("Translated 2");
        transRes.getTextFlowTargets().get(2).setContents("Translated 3");

        transRes.getTextFlowTargets().get(0).setState(ContentState.Approved);
        transRes.getTextFlowTargets().get(1).setState(ContentState.Approved);
        transRes.getTextFlowTargets().get(2).setState(ContentState.Approved);

        transRes.getTextFlowTargets().get(0).getExtensions(true)
                .add(new SimpleComment("Translated Comment 1"));
        transRes.getTextFlowTargets().get(1).getExtensions(true)
                .add(new SimpleComment("Translated Comment 2"));
        transRes.getTextFlowTargets().get(2).getExtensions(true)
                .add(new SimpleComment("Translated Comment 3"));

        // Put the translations
        ClientResponse<String> putResponse =
                translationsClient.putTranslations("my,path,document-2.txt",
                        LocaleId.EN_US, transRes, new StringSet(
                                SimpleComment.ID));

        assertThat(putResponse.getStatus(), is(Status.OK.getStatusCode())); // 200
        putResponse.releaseConnection();

        // Retrieve the translations once more to make sure they were changed
        // accordingly
        response =
                translationsClient.getTranslations("my,path,document-2.txt",
                        LocaleId.EN_US, new StringSet(SimpleComment.ID));
        transRes = response.getEntity();

        assertThat(response.getStatus(), is(Status.OK.getStatusCode())); // 200
        assertThat(transRes.getTextFlowTargets().size(),
                greaterThanOrEqualTo(3));

        // First Text Flow Target
        TextFlowTarget tft1 = transRes.getTextFlowTargets().get(0);
        assertThat(tft1.getResId(), is("tf2"));
        assertThat(tft1.getState(), is(ContentState.Approved));
        assertThat(tft1.getContents().get(0), is("Translated 1"));
        assertThat(tft1.getExtensions(true).findByType(SimpleComment.class)
                .getValue(), is("Translated Comment 1"));
        assertThat(tft1.getTranslator().getName(), is("Sample User"));
        assertThat(tft1.getTranslator().getEmail(), is("user1@localhost"));

        // Second Text Flow Target
        TextFlowTarget tft2 = transRes.getTextFlowTargets().get(1);
        assertThat(tft2.getResId(), is("tf3"));
        assertThat(tft2.getState(), is(ContentState.Approved));
        assertThat(tft2.getContents().get(0), is("Translated 2"));
        assertThat(tft2.getExtensions(true).findByType(SimpleComment.class)
                .getValue(), is("Translated Comment 2"));
        assertThat(tft2.getTranslator().getName(), is("Sample User"));
        assertThat(tft2.getTranslator().getEmail(), is("user1@localhost"));

        // First Text Flow Target
        TextFlowTarget tft3 = transRes.getTextFlowTargets().get(2);
        assertThat(tft3.getResId(), is("tf4"));
        assertThat(tft3.getState(), is(ContentState.Approved));
        assertThat(tft3.getContents().get(0), is("Translated 3"));
        assertThat(tft3.getExtensions(true).findByType(SimpleComment.class)
                .getValue(), is("Translated Comment 3"));
View Full Code Here

TOP

Related Classes of org.zanata.apicompat.rest.dto.resource.TranslationsResource

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.