Package org.zanata.webtrans.shared.rpc

Examples of org.zanata.webtrans.shared.rpc.LoadOptionsResult


        WorkspaceRestrictions workspaceRestrictions =
                new WorkspaceRestrictions(isProjectActive, hasWriteAccess,
                        hasGlossaryUpdateAccess, hasReviewAccess, requireReview);
        log.debug("workspace restrictions: {}", workspaceRestrictions);

        LoadOptionsResult loadOptsRes =
                loadOptionsHandler
                        .execute(new LoadOptionsAction(null), context);

        GetValidationRulesResult validationRulesResult =
                getValidationRulesHandler.execute(new GetValidationRulesAction(
                        workspaceId), context);

        Identity identity = new Identity(editorClientId, person);
        workspace.getWorkspaceContext().getWorkspaceId()
                .getProjectIterationId()
                .setProjectType(projectIteration.getProjectType());
        UserWorkspaceContext userWorkspaceContext =
                new UserWorkspaceContext(workspace.getWorkspaceContext(),
                        workspaceRestrictions);
        return new ActivateWorkspaceResult(userWorkspaceContext, identity,
                loadOptsRes.getConfiguration(),
                validationRulesResult.getValidationRules());
    }
View Full Code Here


            configHolder.setShowSaveApprovedWarning(filteredOptions.get(
                    UserOptions.ShowSaveApprovedWarning.getPersistentName())
                    .getValueAsBoolean());
        }

        return new LoadOptionsResult(configHolder.getState());
    }
View Full Code Here

        configHolder.setShowError(true); // we change one default value
        SaveOptionsAction action =
                new SaveOptionsAction(generateConfigMap(configHolder));
        saveHandler.execute(action, null); // save some options first

        LoadOptionsResult result =
                handler.execute(new LoadOptionsAction(null), null);

        assertThat(result.getConfiguration().isShowError(),
                Matchers.equalTo(true));
        assertThat(result.getConfiguration().getNavOption(),
                Matchers.equalTo(NavOption.FUZZY_UNTRANSLATED));
        assertThat(result.getConfiguration().isDisplayButtons(),
                Matchers.equalTo(true));
    }
View Full Code Here

        // given: no options in database
        List<HAccountOption> options =
                getEm().createQuery("from HAccountOption").getResultList();
        assertThat(options, Matchers.<HAccountOption> empty());

        LoadOptionsResult result =
                handler.execute(new LoadOptionsAction(null), null);

        // then: we get back default values
        assertThat(result.getConfiguration().isShowError(),
                Matchers.equalTo(false));
        assertThat(result.getConfiguration().getNavOption(),
                Matchers.equalTo(NavOption.FUZZY_UNTRANSLATED));
        assertThat(result.getConfiguration().getEditorPageSize(),
                Matchers.equalTo(25));
    }
View Full Code Here

        configHolder.setEnterSavesApproved(true);
        configHolder.setFilterByTranslated(true);
        configHolder.setNavOption(NavOption.FUZZY);
        configHolder.setEditorPageSize(10);

        LoadOptionsResult result =
                new LoadOptionsResult(configHolder.getState());

        presenter.loadOptions();

        ArgumentCaptor<LoadOptionsAction> actionCaptor =
                ArgumentCaptor.forClass(LoadOptionsAction.class);
View Full Code Here

    public void onLoadSavedOption() {
        UserConfigHolder configHolder = new UserConfigHolder();
        configHolder.setDocumentListPageSize(100);
        configHolder.setShowError(true);

        LoadOptionsResult result =
                new LoadOptionsResult(configHolder.getState());

        presenter.loadOptions();

        ArgumentCaptor<LoadOptionsAction> actionCaptor =
                ArgumentCaptor.forClass(LoadOptionsAction.class);
View Full Code Here

                        projectIterationId.getIterationSlug())).thenReturn(
                hProjectIteration);
        when(identity.hasPermission("modify-translation", hProject, hLocale))
                .thenReturn(true);
        when(identity.hasPermission("glossary-update", "")).thenReturn(true);
        LoadOptionsResult optionsResult =
                new LoadOptionsResult(new UserConfigHolder().getState());
        when(
                loadOptionsHandler.execute(isA(LoadOptionsAction.class),
                        any(ExecutionContext.class))).thenReturn(optionsResult);

        when(translationWorkspace.getWorkspaceContext()).thenReturn(
                workspaceContext);
        when(workspaceContext.getWorkspaceId()).thenReturn(workspaceId);

        Collection<ValidationAction> validationList =
                validationFactory.getAllValidationActions().values();
        Map<ValidationId, State> validationStates =
                new HashMap<ValidationId, State>();
        for (ValidationAction valAction : validationList) {
            validationStates.put(valAction.getId(), valAction.getState());
        }

        GetValidationRulesResult validationResult =
                new GetValidationRulesResult(validationStates);
        when(
                getValidationRulesHandler.execute(
                        isA(GetValidationRulesAction.class),
                        any(ExecutionContext.class))).thenReturn(
                validationResult);

        ActivateWorkspaceResult result = handler.execute(action, null);

        verify(identity).checkLoggedIn();
        verify(translationWorkspace).addEditorClient(eq(HTTP_SESSION_ID),
                editorClientIdCaptor.capture(), eq(person.getId()));
        EditorClientId editorClientId = editorClientIdCaptor.getValue();
        assertThat(editorClientId.getHttpSessionId(),
                Matchers.equalTo(HTTP_SESSION_ID));

        verify(translationWorkspace).publish(
                enterWorkspaceEventCaptor.capture());
        EnterWorkspace enterWorkspace = enterWorkspaceEventCaptor.getValue();
        assertThat(enterWorkspace.getPerson(), Matchers.equalTo(person));
        assertThat(enterWorkspace.getEditorClientId(),
                Matchers.equalTo(editorClientId));

        Identity userIdentity = result.getIdentity();
        assertThat(userIdentity.getPerson(), Matchers.equalTo(person));
        assertThat(userIdentity.getEditorClientId(),
                Matchers.equalTo(editorClientId));

        UserWorkspaceContext userWorkspaceContext =
                result.getUserWorkspaceContext();
        assertThat(userWorkspaceContext.getWorkspaceRestrictions()
                .isHasGlossaryUpdateAccess(), Matchers.equalTo(true));
        assertThat(userWorkspaceContext.getWorkspaceRestrictions()
                .isProjectActive(), Matchers.equalTo(true));
        assertThat(userWorkspaceContext.getWorkspaceRestrictions()
                .isHasEditTranslationAccess(), Matchers.equalTo(true));

        assertThat(result.getStoredUserConfiguration(),
                Matchers.sameInstance(optionsResult.getConfiguration()));
    }
View Full Code Here

TOP

Related Classes of org.zanata.webtrans.shared.rpc.LoadOptionsResult

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.