Examples of ISourceDocResource


Examples of org.zanata.apicompat.rest.client.ISourceDocResource

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

Examples of org.zanata.apicompat.rest.client.ISourceDocResource

        res.setContentType(ContentType.TextPlain);
        res.setLang(LocaleId.EN_US);
        res.setRevision(1);

        // Post once
        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();

        // Post Twice (should conflict)
        response =
                sourceDocClient.post(res, new StringSet(PoHeader.ID + ";"
                        + SimpleComment.ID), true);

        assertThat(response.getStatus(), is(Status.CONFLICT.getStatusCode())); // 409
        response.releaseConnection();
    }
View Full Code Here

Examples of org.zanata.apicompat.rest.client.ISourceDocResource

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

Examples of org.zanata.apicompat.rest.client.ISourceDocResource

    }

    @Test
    @RunAsClient
    public void getXmlResource() throws Exception {
        ISourceDocResource sourceDocClient =
                super.createProxy(
                        createClientProxyFactory(TRANSLATOR, TRANSLATOR_KEY),
                        ISourceDocResource.class,
                        "/projects/p/sample-project/iterations/i/1.0/r/");
        ClientResponse<Resource> response =
                sourceDocClient.getResource("my,path,document-2.txt",
                        new StringSet(SimpleComment.ID));
        Resource resource = response.getEntity();

        assertThat(resource.getName(), is("my/path/document-2.txt"));
        assertThat(resource.getType(), is(ResourceType.FILE));
View Full Code Here

Examples of org.zanata.apicompat.rest.client.ISourceDocResource

        res.setType(ResourceType.FILE);
        res.setContentType(ContentType.TextPlain);
        res.setLang(LocaleId.EN_US);
        res.setRevision(1);

        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();

        // Delete the resource
        ClientResponse<String> deleteResponse =
                sourceDocClient.deleteResource(res.getName());

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

        // try to fetch it again
        ClientResponse<Resource> getResponse =
                sourceDocClient.getResource(res.getName(), null);
        assertThat(getResponse.getStatus(),
                is(Status.NOT_FOUND.getStatusCode())); // 404
        getResponse.releaseConnection();
    }
View Full Code Here

Examples of org.zanata.apicompat.rest.client.ISourceDocResource

    }

    @Test
    @RunAsClient
    public void getResourceMeta() throws Exception {
        ISourceDocResource sourceDocClient =
                super.createProxy(
                        createClientProxyFactory(TRANSLATOR, TRANSLATOR_KEY),
                        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"));
View Full Code Here

Examples of org.zanata.apicompat.rest.client.ISourceDocResource

    }

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

Examples of org.zanata.apicompat.rest.client.ISourceDocResource

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

Examples of org.zanata.apicompat.rest.client.ISourceDocResource

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

Examples of org.zanata.apicompat.rest.client.ISourceDocResource

    }

    @Test
    @RunAsClient
    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()));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.