Package org.zanata.rest.client

Examples of org.zanata.rest.client.ICopyTransResource


        return target;
    }

    public void runCopyTrans(String projectSlug, String iterationSlug,
            String docId) {
        ICopyTransResource resource =
                zanataProxyFactory.getCopyTransResource();
        CopyTransStatus copyTransStatus =
                resource.startCopyTrans(projectSlug,
                        iterationSlug, docId);
        log.info("copyTrans started: {}-{}-{}", projectSlug, iterationSlug, docId);
        while (copyTransStatus.isInProgress()) {
            try {
                Thread.sleep(1000);
                log.debug("copyTrans completion: {}", copyTransStatus.getPercentageComplete());
                copyTransStatus = resource.getCopyTransStatus(projectSlug, iterationSlug, docId);
            }
            catch (InterruptedException e) {
                throw Throwables.propagate(e);
            }
        }
View Full Code Here


        processStatus = waitUntilFinished(resource, processStatus);
        log.info("finished async source push ({}-{}): {}", projectSlug,
                iterationSlug, processStatus.getStatusCode());
        if (copyTrans) {
            log.info("start copyTrans for {} - {}", projectSlug, iterationSlug);
            ICopyTransResource copyTransResource =
                    zanataProxyFactory.getCopyTransResource();
            CopyTransStatus copyTransStatus =
                    copyTransResource
                            .startCopyTrans(projectSlug, iterationSlug,
                                    sourceResource.getName());
            while (copyTransStatus.isInProgress()) {
                try {
                    Thread.sleep(1000);
                }
                catch (InterruptedException e) {
                    throw Throwables.propagate(e);
                }
                copyTransStatus = copyTransResource.getCopyTransStatus(projectSlug, iterationSlug, sourceResource.getName());
            }
            log.info("finish copyTrans for {} - {}", projectSlug, iterationSlug);
        }
    }
View Full Code Here

                DatabaseOperation.DELETE_ALL));
    }

    @Test
    public void startCopyTrans() {
        ICopyTransResource copyTransResource =
                getClientRequestFactory().createProxy(ICopyTransResource.class);

        copyTransResource.startCopyTrans("sample-project", "1.0",
                "my/path/document.txt");
        verify(mockIdentity, atLeastOnce()).checkPermission(eq("copy-trans"),
                anyVararg());
    }
View Full Code Here

                anyVararg());
    }

    @Test
    public void startCopyTransAndCheckStatus() {
        ICopyTransResource copyTransResource =
                getClientRequestFactory().createProxy(ICopyTransResource.class);

        copyTransResource.startCopyTrans("sample-project", "1.0",
                "my/path/document.txt");

        CopyTransStatus status =
                copyTransResource.getCopyTransStatus("sample-project", "1.0",
                        "my/path/document.txt");
        assertThat(status, notNullValue());
        verify(mockIdentity, atLeastOnce()).checkPermission(eq("copy-trans"),
                anyVararg());
    }
View Full Code Here

                anyVararg());
    }

    @Test
    public void copyTransForUnknownDocument() {
        ICopyTransResource copyTransResource =
                getClientRequestFactory().createProxy(ICopyTransResource.class);

        try {
            copyTransResource.startCopyTrans("sample-project", "1.0",
                    "/an/inexisting/document.txt");
            assertThat(
                    "startCopyTrans should have returned 404 in the form of an exception.",
                    false);
        } catch (ClientResponseFailure failure) {
View Full Code Here

        }
    }

    @Test
    public void unauthorizedStartCopyTrans() {
        ICopyTransResource copyTransResource =
                getClientRequestFactory().createProxy(ICopyTransResource.class);
        doThrow(new AuthorizationException("Expected Exception")).when(
                mockIdentity).checkPermission(eq("copy-trans"), anyVararg());

        try {
            copyTransResource.startCopyTrans("sample-project", "1.0",
                    "my/path/document.txt");
            assertThat(
                    "startCopyTrans should have returned 401 in the form of an exception.",
                    false);
        } catch (ClientResponseFailure failure) {
View Full Code Here

        }
    }

    @Test
    public void unauthorizedCopyTransStatus() {
        ICopyTransResource copyTransResource =
                getClientRequestFactory().createProxy(ICopyTransResource.class);
        doThrow(new AuthorizationException("Expected Exception")).when(
                mockIdentity).checkPermission(eq("copy-trans"), anyVararg());

        try {
            copyTransResource.getCopyTransStatus("sample-project", "1.0",
                    "/my/path/document.txt");
            assertThat(
                    "getCopyTransStatus should have returned 401 in the form of an exception.",
                    false);
        } catch (ClientResponseFailure failure) {
View Full Code Here

TOP

Related Classes of org.zanata.rest.client.ICopyTransResource

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.