Package org.zanata.webtrans.server.rpc

Examples of org.zanata.webtrans.server.rpc.UpdateTransUnitHandler


                                                                     // and have
                                                                     // a wrong
                                                                     // HAccount
                                                                     // injected

        UpdateTransUnitHandler transUnitHandler =
                seamAutowire.autowire(UpdateTransUnitHandler.class);

        // Translation unit id to update
        HTextFlow hTextFlow =
                (HTextFlow) getSession()
                        .createQuery(
                                "select tf from HTextFlow tf where tf.contentHash = ? and "
                                        + "tf.document.docId = ? and "
                                        + "tf.document.projectIteration.slug = ? and "
                                        + "tf.document.projectIteration.project.slug = ?")
                        .setString(0, HashUtil.generateHash(textFlowContent))
                        .setString(1, docId).setString(2, iterationSlug)
                        .setString(3, projectSlug).uniqueResult();
        Long textFlowId = hTextFlow.getId();
        int versionNum = 0; // no previous translation

        // Translate using webtrans
        UpdateType updateType = UpdateType.WebEditorSave;
        UpdateTransUnit action =
                new UpdateTransUnit(new TransUnitUpdateRequest(new TransUnitId(
                        textFlowId), Lists.newArrayList(translation),
                        translationState, versionNum), updateType);
        action.setWorkspaceId(workspaceId);

        UpdateTransUnitResult result = transUnitHandler.execute(action, null);

        assertThat(result.isSingleSuccess(), is(true));
        verify(mockIdentity).checkLoggedIn();
        verify(mockIdentity, atLeastOnce()).checkPermission(anyString(),
                any(HLocale.class), any(HProject.class));
View Full Code Here

TOP

Related Classes of org.zanata.webtrans.server.rpc.UpdateTransUnitHandler

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.