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

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


                // Make sure all Text Flows are present
                assertThat(resource.getTextFlows().size(),
                        greaterThanOrEqualTo(3));

                // Evaluate individual text flows
                TextFlow txtFlow = resource.getTextFlows().get(0);
                assertThat(txtFlow.getId(), is("tf2"));
                assertThat(txtFlow.getRevision(), is(1));
                assertThat(txtFlow.getContent(), is("mssgId1"));

                txtFlow = resource.getTextFlows().get(1);
                assertThat(txtFlow.getId(), is("tf3"));
                assertThat(txtFlow.getRevision(), is(1));
                assertThat(txtFlow.getContent(), is("mssgId2"));

                txtFlow = resource.getTextFlows().get(2);
                assertThat(txtFlow.getId(), is("tf4"));
                assertThat(txtFlow.getRevision(), is(1));
                assertThat(txtFlow.getContent(), is("mssgId3"));
            }
        }.run();
    }
View Full Code Here


        res.setContentType(ContentType.TextPlain);
        res.setLang(LocaleId.EN_US);
        res.setRevision(1);
        res.getExtensions(true).add(new PoHeader("This is a PO Header"));

        TextFlow tf1 = new TextFlow("tf1", LocaleId.EN_US, "First Text Flow");
        tf1.getExtensions(true).add(new SimpleComment("This is one comment"));
        res.getTextFlows().add(tf1);

        new ResourceRequest(
                getRestEndpointUrl("/projects/p/sample-project/iterations/i/1.0/r"),
                "POST", getAuthorizedEnvironment()) {
            @Override
            protected void prepareRequest(ClientRequest request) {
                request.queryParameter("ext", PoHeader.ID).queryParameter(
                        "ext", SimpleComment.ID);
                request.body(MediaType.APPLICATION_JSON, jsonMarshal(res));
            }

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

        // Verify that it was created successfully
        ISourceDocResource sourceDocClient =
                super.createProxy(
                        createClientProxyFactory(TRANSLATOR, TRANSLATOR_KEY),
                        ISourceDocResource.class,
                        "/projects/p/sample-project/iterations/i/1.0/r");
        ClientResponse<Resource> resourceResponse =
                sourceDocClient.getResource(res.getName(), new StringSet(
                        PoHeader.ID + ";" + SimpleComment.ID));

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

        Resource createdResource = resourceResponse.getEntity();

        assertThat(createdResource.getName(), is(res.getName()));
        assertThat(createdResource.getType(), is(res.getType()));
        assertThat(createdResource.getContentType(), is(res.getContentType()));
        assertThat(createdResource.getLang(), is(res.getLang()));
        assertThat(createdResource.getRevision(), is(1)); // Created, so
                                                          // revision 1

        // Extensions
        assertThat(createdResource.getExtensions(true).size(),
                greaterThanOrEqualTo(1));
        assertThat(
                createdResource.getExtensions(true).findByType(PoHeader.class)
                        .getComment(), is("This is a PO Header"));

        // Text Flow
        assertThat(createdResource.getTextFlows().size(), is(1));

        TextFlow createdTf = createdResource.getTextFlows().get(0);
        assertThat(createdTf.getContents(), is(tf1.getContents()));
        assertThat(createdTf.getId(), is(tf1.getId()));
        assertThat(createdTf.getLang(), is(tf1.getLang()));
        assertThat(createdTf.getRevision(), is(1)); // Create, so revision 1

        // Text Flow extensions
        assertThat(createdTf.getExtensions(true).size(), is(1));
        assertThat(
                createdTf.getExtensions(true)
                        .findOrAddByType(SimpleComment.class).getValue(),
                is("This is one comment"));
    }
View Full Code Here

        res.setContentType(ContentType.TextPlain);
        res.setLang(LocaleId.EN_US);
        res.setRevision(1);
        res.getExtensions(true).add(new PoHeader("This is a PO Header"));

        TextFlow tf1 = new TextFlow("tf1", LocaleId.EN_US, "First Text Flow");
        tf1.getExtensions(true).add(new SimpleComment("This is one comment"));
        res.getTextFlows().add(tf1);

        new ResourceRequest(
                getRestEndpointUrl("/projects/p/sample-project/iterations/i/1.0/r/"
                        + res.getName()), "PUT", getAuthorizedEnvironment()) {
            @Override
            protected void prepareRequest(ClientRequest request) {
                request.queryParameter("ext", SimpleComment.ID).queryParameter(
                        "ext", PoHeader.ID);
                request.body(MediaType.APPLICATION_JSON, jsonMarshal(res));
            }

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

        ISourceDocResource translationsClient =
                super.createProxy(
                        createClientProxyFactory(TRANSLATOR, TRANSLATOR_KEY),
                        ISourceDocResource.class,
                        "/projects/p/sample-project/iterations/i/1.0/r/");
        // Verify that it was created successfully
        ClientResponse<Resource> resourceResponse =
                translationsClient.getResource(res.getName(), new StringSet(
                        PoHeader.ID + ";" + SimpleComment.ID));
        Resource createdResource = resourceResponse.getEntity();

        assertThat(createdResource.getName(), is(res.getName()));
        assertThat(createdResource.getType(), is(res.getType()));
        assertThat(createdResource.getContentType(), is(res.getContentType()));
        assertThat(createdResource.getLang(), is(res.getLang()));
        assertThat(createdResource.getRevision(), is(1)); // Created, so
                                                          // revision 1

        // Extensions
        assertThat(createdResource.getExtensions(true).size(),
                greaterThanOrEqualTo(1));
        assertThat(
                createdResource.getExtensions(true).findByType(PoHeader.class)
                        .getComment(), is("This is a PO Header"));

        // Text Flow
        assertThat(createdResource.getTextFlows().size(), is(1));

        TextFlow createdTf = createdResource.getTextFlows().get(0);
        assertThat(createdTf.getContents(), is(tf1.getContents()));
        assertThat(createdTf.getId(), is(tf1.getId()));
        assertThat(createdTf.getLang(), is(tf1.getLang()));
        assertThat(createdTf.getRevision(), is(1)); // Create, so revision 1

        // Text Flow extensions
        assertThat(createdTf.getExtensions(true).size(), is(1));
        assertThat(
                createdTf.getExtensions(true)
                        .findOrAddByType(SimpleComment.class).getValue(),
                is("This is one comment"));
    }
View Full Code Here

        res.setContentType(ContentType.TextPlain);
        res.setLang(LocaleId.EN_US);
        res.setRevision(1);
        res.getExtensions(true).add(new PoHeader("This is a PO Header"));

        TextFlow tf1 = new TextFlow("tf1", LocaleId.EN_US, "First Text Flow");
        tf1.getExtensions(true).add(new SimpleComment("This is one comment"));
        res.getTextFlows().add(tf1);

        ISourceDocResource sourceDocClient =
                super.createProxy(createClientProxyFactory(ADMIN, ADMIN_KEY),
                        ISourceDocResource.class,
                        "/projects/p/sample-project/iterations/i/1.0/r/");
        ClientResponse<String> response =
                sourceDocClient.post(res, new StringSet(PoHeader.ID + ";"
                        + SimpleComment.ID), true);

        assertThat(response.getStatus(), is(Status.CREATED.getStatusCode())); // 201
        response.releaseConnection();

        // Verify that it was created successfully
        ClientResponse<Resource> resourceResponse =
                sourceDocClient.getResource(res.getName(), new StringSet(
                        PoHeader.ID + ";" + SimpleComment.ID));
        Resource createdResource = resourceResponse.getEntity();

        assertThat(createdResource.getName(), is(res.getName()));
        assertThat(createdResource.getType(), is(res.getType()));
        assertThat(createdResource.getContentType(), is(res.getContentType()));
        assertThat(createdResource.getLang(), is(res.getLang()));
        assertThat(createdResource.getRevision(), is(1)); // Created, so
                                                          // revision 1

        // Extensions
        assertThat(createdResource.getExtensions(true).size(),
                greaterThanOrEqualTo(1));
        assertThat(
                createdResource.getExtensions(true).findByType(PoHeader.class)
                        .getComment(), is("This is a PO Header"));

        // Text Flow
        assertThat(createdResource.getTextFlows().size(), is(1));

        TextFlow createdTf = createdResource.getTextFlows().get(0);
        assertThat(createdTf.getContents().get(0), is(tf1.getContents().get(0)));
        assertThat(createdTf.getId(), is(tf1.getId()));
        assertThat(createdTf.getLang(), is(tf1.getLang()));
        assertThat(createdTf.getRevision(), is(1)); // Create, so revision 1

        // Text Flow extensions
        assertThat(createdTf.getExtensions(true).size(), is(1));
        assertThat(
                createdTf.getExtensions(true)
                        .findOrAddByType(SimpleComment.class).getValue(),
                is("This is one comment"));
    }
View Full Code Here

        res.setContentType(ContentType.TextPlain);
        res.setLang(LocaleId.EN_US);
        res.setRevision(1);
        res.getExtensions(true).add(new PoHeader("This is a PO Header"));

        TextFlow tf1 = new TextFlow("tf1", LocaleId.EN_US, "First Text Flow");
        tf1.getExtensions(true).add(new SimpleComment("This is one comment"));
        res.getTextFlows().add(tf1);

        ISourceDocResource sourceDocClient =
                super.createProxy(createClientProxyFactory(ADMIN, ADMIN_KEY),
                        ISourceDocResource.class,
                        "/projects/p/sample-project/iterations/i/1.0/r/");
        ClientResponse<String> response =
                sourceDocClient.putResource(res.getName(), res, new StringSet(
                        PoHeader.ID + ";" + SimpleComment.ID));

        assertThat(response.getStatus(), is(Status.CREATED.getStatusCode())); // 201
        response.releaseConnection();

        // Verify that it was created successfully
        ClientResponse<Resource> resourceResponse =
                sourceDocClient.getResource(res.getName(), new StringSet(
                        PoHeader.ID + ";" + SimpleComment.ID));
        Resource createdResource = resourceResponse.getEntity();

        assertThat(createdResource.getName(), is(res.getName()));
        assertThat(createdResource.getType(), is(res.getType()));
        assertThat(createdResource.getContentType(), is(res.getContentType()));
        assertThat(createdResource.getLang(), is(res.getLang()));
        assertThat(createdResource.getRevision(), is(1)); // Created, so
                                                          // revision 1

        // Extensions
        assertThat(createdResource.getExtensions(true).size(),
                greaterThanOrEqualTo(1));
        assertThat(
                createdResource.getExtensions(true).findByType(PoHeader.class)
                        .getComment(), is("This is a PO Header"));

        // Text Flow
        assertThat(createdResource.getTextFlows().size(), is(1));

        TextFlow createdTf = createdResource.getTextFlows().get(0);
        assertThat(createdTf.getContents().get(0), is(tf1.getContents().get(0)));
        assertThat(createdTf.getId(), is(tf1.getId()));
        assertThat(createdTf.getLang(), is(tf1.getLang()));
        assertThat(createdTf.getRevision(), is(1)); // Create, so revision 1

        // Text Flow extensions
        assertThat(createdTf.getExtensions(true).size(), is(1));
        assertThat(
                createdTf.getExtensions(true)
                        .findOrAddByType(SimpleComment.class).getValue(),
                is("This is one comment"));
    }
View Full Code Here

        // Make sure all Text Flows are present
        assertThat(resource.getTextFlows().size(), greaterThanOrEqualTo(3));

        // Evaluate individual text flows
        TextFlow txtFlow = resource.getTextFlows().get(0);
        assertThat(txtFlow.getId(), is("tf2"));
        assertThat(txtFlow.getRevision(), is(1));
        assertThat(txtFlow.getContents().get(0), is("mssgId1"));

        txtFlow = resource.getTextFlows().get(1);
        assertThat(txtFlow.getId(), is("tf3"));
        assertThat(txtFlow.getRevision(), is(1));
        assertThat(txtFlow.getContents().get(0), is("mssgId2"));

        txtFlow = resource.getTextFlows().get(2);
        assertThat(txtFlow.getId(), is("tf4"));
        assertThat(txtFlow.getRevision(), is(1));
        assertThat(txtFlow.getContents().get(0), is("mssgId3"));
    }
View Full Code Here

TOP

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

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.