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

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


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

                ResourceMeta resMeta =
                        jsonUnmarshal(response, ResourceMeta.class);
                assertThat(resMeta.getName(), is("my/path/document-2.txt"));
                assertThat(resMeta.getType(), is(ResourceType.FILE));
                assertThat(resMeta.getLang(), is(LocaleId.EN_US));
                assertThat(resMeta.getContentType(), is(ContentType.TextPlain));
            }
        }.run();
    }
View Full Code Here


    public void putJsonResourceMeta() throws Exception {
        ISourceDocResource translationsClient =
                super.createProxy(createClientProxyFactory(ADMIN, ADMIN_KEY),
                        ISourceDocResource.class,
                        "/projects/p/sample-project/iterations/i/1.0/r/");
        final ResourceMeta resMeta = new ResourceMeta();
        resMeta.setName("my/path/document-2.txt");
        resMeta.setType(ResourceType.FILE);
        resMeta.setContentType(ContentType.TextPlain);
        resMeta.setLang(LocaleId.EN_US);
        resMeta.setRevision(1);

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

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

        // Fetch again
        ClientResponse<ResourceMeta> getResponse =
                translationsClient.getResourceMeta("my,path,document-2.txt",
                        null);
        ResourceMeta newResMeta = getResponse.getEntity();

        assertThat(getResponse.getStatus(), is(Status.OK.getStatusCode())); // 200
        assertThat(newResMeta.getName(), is(resMeta.getName()));
        assertThat(newResMeta.getContentType(), is(resMeta.getContentType()));
        assertThat(newResMeta.getLang(), is(resMeta.getLang()));
        assertThat(newResMeta.getType(), is(resMeta.getType()));
        assertThat(newResMeta.getRevision(), greaterThan(1)); // Updated so
                                                              // higher revision
    }
View Full Code Here

                        ISourceDocResource.class,
                        "/projects/p/sample-project/iterations/i/1.0/r/");
        ClientResponse<ResourceMeta> response =
                sourceDocClient.getResourceMeta("my,path,document-2.txt",
                        new StringSet(SimpleComment.ID));
        ResourceMeta resMeta = response.getEntity();

        assertThat(response.getStatus(), is(Status.OK.getStatusCode())); // 200
        assertThat(resMeta.getName(), is("my/path/document-2.txt"));
        assertThat(resMeta.getType(), is(ResourceType.FILE));
        assertThat(resMeta.getLang(), is(LocaleId.EN_US));
        assertThat(resMeta.getContentType(), is(ContentType.TextPlain));
    }
View Full Code Here

    public void putResourceMeta() throws Exception {
        ISourceDocResource sourceDocClient =
                super.createProxy(createClientProxyFactory(ADMIN, ADMIN_KEY),
                        ISourceDocResource.class,
                        "/projects/p/sample-project/iterations/i/1.0/r/");
        ResourceMeta resMeta = new ResourceMeta();
        resMeta.setName("my/path/document-2.txt");
        resMeta.setType(ResourceType.FILE);
        resMeta.setContentType(ContentType.TextPlain);
        resMeta.setLang(LocaleId.EN_US);
        resMeta.setRevision(1);

        ClientResponse<String> putResponse =
                sourceDocClient.putResourceMeta("my,path,document-2.txt",
                        resMeta, null);
        assertThat(putResponse.getStatus(), is(Status.OK.getStatusCode())); // 200
        putResponse.releaseConnection();

        // Fetch again
        ClientResponse<ResourceMeta> getResponse =
                sourceDocClient.getResourceMeta("my,path,document-2.txt", null);
        ResourceMeta newResMeta = getResponse.getEntity();

        assertThat(getResponse.getStatus(), is(Status.OK.getStatusCode())); // 200
        assertThat(newResMeta.getName(), is(resMeta.getName()));
        assertThat(newResMeta.getContentType(), is(resMeta.getContentType()));
        assertThat(newResMeta.getLang(), is(resMeta.getLang()));
        assertThat(newResMeta.getType(), is(resMeta.getType()));
        assertThat(newResMeta.getRevision(), is(1)); // Created, so revision 1
    }
View Full Code Here

TOP

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

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.