Search in sources :

Example 1 with LibraryPreferences

use of org.kie.workbench.common.screens.library.api.preferences.LibraryPreferences in project kie-wb-common by kiegroup.

the class LibraryServiceImpl method createDefaultOrganizationalUnit.

private OrganizationalUnit createDefaultOrganizationalUnit() {
    if (!authorizationManager.authorize(OrganizationalUnit.RESOURCE_TYPE, OrganizationalUnitAction.CREATE, sessionInfo.getIdentity())) {
        throw new UnauthorizedException("User :user has no permissions to :type -> :action".replace(":user", sessionInfo.getIdentity().getIdentifier()).replace(":type", OrganizationalUnit.RESOURCE_TYPE.getName()).replace(":action", OrganizationalUnitAction.CREATE.getName()));
    }
    final LibraryPreferences preferences = getPreferences();
    final List<Contributor> contributors = new ArrayList<>();
    contributors.add(new Contributor(preferences.getOrganizationalUnitPreferences().getOwner(), ContributorType.OWNER));
    return ouService.createOrganizationalUnit(preferences.getOrganizationalUnitPreferences().getName(), preferences.getOrganizationalUnitPreferences().getGroupId(), Collections.emptyList(), contributors);
}
Also used : UnauthorizedException(org.jboss.errai.security.shared.exception.UnauthorizedException) LibraryPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryPreferences) ArrayList(java.util.ArrayList) Contributor(org.uberfire.security.Contributor)

Example 2 with LibraryPreferences

use of org.kie.workbench.common.screens.library.api.preferences.LibraryPreferences in project kie-wb-common by kiegroup.

the class PopulatedAssetsScreenTest method testInitializeDefaultPreference.

@Test
public void testInitializeDefaultPreference() {
    LibraryPreferences mockLibraryPreferences = mock(LibraryPreferences.class);
    LibraryProjectPreferences mockLibraryProjectPreferences = mock(LibraryProjectPreferences.class);
    when(mockLibraryPreferences.getProjectPreferences()).thenReturn(mockLibraryProjectPreferences);
    when(mockLibraryProjectPreferences.getAssetsPerPage()).thenReturn(15);
    doReturn(promises.resolve(false)).when(this.projectController).canUpdateProject(any());
    this.populatedAssetsScreen.init();
    verify(libraryPreferences).load(any(ParameterizedCommand.class), any(ParameterizedCommand.class));
}
Also used : LibraryPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryPreferences) LibraryProjectPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryProjectPreferences) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Test(org.junit.Test)

Example 3 with LibraryPreferences

use of org.kie.workbench.common.screens.library.api.preferences.LibraryPreferences in project kie-wb-common by kiegroup.

the class AddProjectPopUpPresenterTest method testRestoreAdvancedOptionsWithoutActiveOrganizationalUnit.

@Test
public void testRestoreAdvancedOptionsWithoutActiveOrganizationalUnit() {
    LibraryPreferences loadedLibraryPreferences = mock(LibraryPreferences.class);
    LibraryProjectPreferences libraryProjectPreferences = mock(LibraryProjectPreferences.class);
    LibraryOrganizationalUnitPreferences libraryOrganizationalUnitPreferences = mock(LibraryOrganizationalUnitPreferences.class);
    doReturn(libraryProjectPreferences).when(loadedLibraryPreferences).getProjectPreferences();
    doReturn("version").when(libraryProjectPreferences).getVersion();
    doReturn(libraryOrganizationalUnitPreferences).when(loadedLibraryPreferences).getOrganizationalUnitPreferences();
    when(libraryOrganizationalUnitPreferences.getGroupId()).thenReturn("group");
    when(projectContext.getActiveOrganizationalUnit()).thenReturn(Optional.empty());
    when(view.getName()).thenReturn("Project Test");
    executeParametrizedCommandWith(0, loadedLibraryPreferences).when(libraryPreferences).load(any(ParameterizedCommand.class), any(ParameterizedCommand.class));
    presenter.restoreAdvancedOptions();
    verify(view).setVersion("version");
    verify(view).setGroupId("group");
    verify(view, never()).setDescription(any());
    verify(view).setArtifactId("ProjectTest");
}
Also used : LibraryOrganizationalUnitPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryOrganizationalUnitPreferences) LibraryPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryPreferences) LibraryProjectPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryProjectPreferences) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Test(org.junit.Test)

Example 4 with LibraryPreferences

use of org.kie.workbench.common.screens.library.api.preferences.LibraryPreferences in project kie-wb-common by kiegroup.

the class LibraryServiceImpl method createGAV.

@Override
public GAV createGAV(final String projectName, final OrganizationalUnit selectedOrganizationalUnit) {
    final LibraryPreferences preferences = getPreferences();
    final String artifactId = NewWorkspaceProjectUtils.sanitizeProjectName(projectName);
    return new GAV(selectedOrganizationalUnit.getDefaultGroupId(), artifactId, preferences.getProjectPreferences().getVersion());
}
Also used : LibraryPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryPreferences) GAV(org.guvnor.common.services.project.model.GAV)

Example 5 with LibraryPreferences

use of org.kie.workbench.common.screens.library.api.preferences.LibraryPreferences in project kie-wb-common by kiegroup.

the class AddProjectPopUpPresenterTest method testRestoreAdvancedOptionsWithActiveOrganizationalUnit.

@Test
public void testRestoreAdvancedOptionsWithActiveOrganizationalUnit() {
    LibraryPreferences loadedLibraryPreferences = mock(LibraryPreferences.class);
    LibraryProjectPreferences libraryProjectPreferences = mock(LibraryProjectPreferences.class);
    doReturn(libraryProjectPreferences).when(loadedLibraryPreferences).getProjectPreferences();
    doReturn("version").when(libraryProjectPreferences).getVersion();
    when(projectContext.getActiveOrganizationalUnit().get().getDefaultGroupId()).thenReturn("group");
    when(view.getName()).thenReturn("Project Test");
    executeParametrizedCommandWith(0, loadedLibraryPreferences).when(libraryPreferences).load(any(ParameterizedCommand.class), any(ParameterizedCommand.class));
    presenter.restoreAdvancedOptions();
    verify(libraryPreferences).load(any(ParameterizedCommand.class), any(ParameterizedCommand.class));
    verify(view).setVersion("version");
    verify(view).setGroupId("group");
    verify(view, never()).setDescription(any());
    verify(view).setArtifactId("ProjectTest");
}
Also used : LibraryPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryPreferences) LibraryProjectPreferences(org.kie.workbench.common.screens.library.api.preferences.LibraryProjectPreferences) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Test(org.junit.Test)

Aggregations

LibraryPreferences (org.kie.workbench.common.screens.library.api.preferences.LibraryPreferences)5 Test (org.junit.Test)3 LibraryProjectPreferences (org.kie.workbench.common.screens.library.api.preferences.LibraryProjectPreferences)3 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)3 ArrayList (java.util.ArrayList)1 GAV (org.guvnor.common.services.project.model.GAV)1 UnauthorizedException (org.jboss.errai.security.shared.exception.UnauthorizedException)1 LibraryOrganizationalUnitPreferences (org.kie.workbench.common.screens.library.api.preferences.LibraryOrganizationalUnitPreferences)1 Contributor (org.uberfire.security.Contributor)1