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);
}
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));
}
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");
}
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());
}
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");
}
Aggregations