Search in sources :

Example 21 with ConfigGroup

use of org.guvnor.structure.server.config.ConfigGroup in project kie-wb-common by kiegroup.

the class MigrationConfigurationFactoryImplTest method newConfigGroupWithoutNamespaceTest.

@Test
public void newConfigGroupWithoutNamespaceTest() {
    final ConfigGroup configGroup = configurationFactory.newConfigGroup(ConfigType.GLOBAL, "my-config", "my-description");
    assertEquals(ConfigType.GLOBAL, configGroup.getType());
    assertEquals("my-config", configGroup.getName());
    assertEquals("my-description", configGroup.getDescription());
    assertTrue(configGroup.isEnabled());
}
Also used : ConfigGroup(org.guvnor.structure.server.config.ConfigGroup) Test(org.junit.Test)

Example 22 with ConfigGroup

use of org.guvnor.structure.server.config.ConfigGroup in project kie-wb-common by kiegroup.

the class ConfigGroupsMigrationService method groupRepositoryConfigGroupsBySpace.

private void groupRepositoryConfigGroupsBySpace() {
    final org.uberfire.java.nio.file.Path systemDir = ioService.get(systemRepository.getUri());
    final org.uberfire.java.nio.file.Path repositoriesDir = systemDir.resolve(ConfigType.REPOSITORY.getDir());
    final DirectoryStream<org.uberfire.java.nio.file.Path> repoConfigs = getDirectoryStreamForFilesWithParticularExtension(repositoriesDir, ConfigType.REPOSITORY.getExt());
    final Iterator<org.uberfire.java.nio.file.Path> it = repoConfigs.iterator();
    while (it.hasNext()) {
        final org.uberfire.java.nio.file.Path oldPath = it.next();
        final String fileName = Paths.convert(oldPath).getFileName();
        final String content = ioService.readAllString(oldPath);
        final ConfigGroup repoConfig = marshaller.unmarshall(content);
        final String space = repoConfig.getConfigItemValue("space");
        final org.uberfire.java.nio.file.Path newPath = repositoriesDir.resolve(space).resolve(fileName);
        ioService.move(oldPath, newPath);
    }
}
Also used : ConfigGroup(org.guvnor.structure.server.config.ConfigGroup)

Example 23 with ConfigGroup

use of org.guvnor.structure.server.config.ConfigGroup in project kie-wb-common by kiegroup.

the class MigrationConfigurationFactoryImpl method newConfigGroup.

@Override
public ConfigGroup newConfigGroup(ConfigType type, final String name, final String description) {
    if (ConfigType.SPACE.equals(type)) {
        type = ConfigType.ORGANIZATIONAL_UNIT;
    }
    final ConfigGroup configGroup = new ConfigGroup();
    configGroup.setDescription(description);
    configGroup.setName(name);
    configGroup.setType(type);
    configGroup.setEnabled(true);
    return configGroup;
}
Also used : ConfigGroup(org.guvnor.structure.server.config.ConfigGroup)

Example 24 with ConfigGroup

use of org.guvnor.structure.server.config.ConfigGroup in project kie-wb-common by kiegroup.

the class MigrateAllProjectsTest method initConfigGroups.

public List<ConfigGroup> initConfigGroups() {
    List<ConfigGroup> spaceConfigs = new ArrayList<>();
    List<String> spaceARepos = Collections.singletonList(REPO_A);
    List<String> spaceBRepos = Arrays.asList(REPO_B, REPO_C);
    ConfigItem<List<String>> spaceAConfig = new ConfigItem<>();
    spaceAConfig.setName("repositories");
    spaceAConfig.setValue(spaceARepos);
    ConfigItem<List<String>> spaceBConfig = new ConfigItem<>();
    spaceBConfig.setName("repositories");
    spaceBConfig.setValue(spaceBRepos);
    ConfigItem<List<Contributor>> contributors = new ConfigItem<>();
    contributors.setName(SPACE_CONTRIBUTORS);
    contributors.setValue(new ArrayList<>());
    ConfigItem<List<String>> groups = new ConfigItem<>();
    groups.setName(SECURITY_GROUPS);
    groups.setValue(new ArrayList<>());
    ConfigGroup spaceA = new ConfigGroup();
    spaceA.setName(SPACE_A);
    spaceA.setConfigItem(spaceAConfig);
    spaceA.setConfigItem(contributors);
    spaceA.setConfigItem(groups);
    ConfigGroup spaceB = new ConfigGroup();
    spaceB.setName(SPACE_B);
    spaceB.setConfigItem(spaceBConfig);
    spaceB.setConfigItem(contributors);
    spaceB.setConfigItem(groups);
    spaceConfigs.add(spaceA);
    spaceConfigs.add(spaceB);
    return spaceConfigs;
}
Also used : ArrayList(java.util.ArrayList) ConfigItem(org.guvnor.structure.server.config.ConfigItem) ArrayList(java.util.ArrayList) List(java.util.List) Mockito.anyString(org.mockito.Mockito.anyString) ConfigGroup(org.guvnor.structure.server.config.ConfigGroup)

Example 25 with ConfigGroup

use of org.guvnor.structure.server.config.ConfigGroup in project kie-wb-common by kiegroup.

the class MigrationConfigurationServiceImplTest method removeConfigurationWithNamespaceTest.

@Test
public void removeConfigurationWithNamespaceTest() {
    final ConfigGroup config = configurationFactory.newConfigGroup(ConfigType.REPOSITORY, "namespace", "config", "description");
    configurationService.addConfiguration(config);
    configurationService.removeConfiguration(config);
    final List<ConfigGroup> configGroups = configurationService.getConfiguration(ConfigType.REPOSITORY, "namespace");
    assertEquals(0, configGroups.size());
}
Also used : ConfigGroup(org.guvnor.structure.server.config.ConfigGroup) Test(org.junit.Test)

Aggregations

ConfigGroup (org.guvnor.structure.server.config.ConfigGroup)40 Test (org.junit.Test)15 ConfigItem (org.guvnor.structure.server.config.ConfigItem)9 ArrayList (java.util.ArrayList)7 ConfigType (org.guvnor.structure.server.config.ConfigType)6 List (java.util.List)5 Before (org.junit.Before)4 HashMap (java.util.HashMap)3 File (java.io.File)2 Path (java.nio.file.Path)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 URL (java.net.URL)1 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)1 Repository (org.guvnor.structure.repositories.Repository)1 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)1 WorkDefinition (org.jbpm.process.core.WorkDefinition)1 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)1 Mockito.anyString (org.mockito.Mockito.anyString)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 CommentedOption (org.uberfire.java.nio.base.options.CommentedOption)1