Search in sources :

Example 1 with ConfigGroup

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

the class ExamplesServiceImplTest method resolveGitRepositoryNotClonedBefore.

@Test
public void resolveGitRepositoryNotClonedBefore() {
    ExampleRepository playgroundRepository = new ExampleRepository("file:///home/user/folder/.kie-wb-playground");
    service.setPlaygroundRepository(playgroundRepository);
    ConfigGroup configGroup = new ConfigGroup();
    when(configurationFactory.newConfigGroup(any(ConfigType.class), anyString(), anyString(), anyString())).thenReturn(configGroup);
    doCallRealMethod().when(configurationFactory).newConfigItem(anyString(), anyBoolean());
    doCallRealMethod().when(configurationFactory).newConfigItem(anyString(), anyString());
    doCallRealMethod().when(configurationFactory).newConfigItem(anyString(), any(Object.class));
    Repository repository = mock(Repository.class);
    when(repositoryFactory.newRepository(configGroup)).thenReturn(repository);
    Repository result = service.resolveGitRepository(playgroundRepository);
    assertEquals(repository, result);
    assertEquals(false, configGroup.getConfigItem(EnvironmentParameters.MIRROR).getValue());
    verify(repositoryFactory, times(1)).newRepository(configGroup);
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) ConfigGroup(org.guvnor.structure.server.config.ConfigGroup) ConfigType(org.guvnor.structure.server.config.ConfigType) Test(org.junit.Test)

Example 2 with ConfigGroup

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

the class MigrationConfigurationServiceImplTest method removeConfigurationWithoutNamespaceTest.

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

Example 3 with ConfigGroup

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

the class ConfigGroupsMigrationService method moveDataToSpaceConfigRepo.

public void moveDataToSpaceConfigRepo() {
    Collection<ConfigGroup> groups = configurationService.getConfiguration(ConfigType.SPACE);
    if (groups != null) {
        for (ConfigGroup groupConfig : groups) {
            saveSpaceInfo(configGroupToSpaceInfoConverter.toSpaceInfo(groupConfig));
            configurationService.removeConfiguration(groupConfig);
            configGroupToSpaceInfoConverter.cleanUpRepositories(groupConfig);
        }
        configurationService.cleanUpSystemRepository();
    }
}
Also used : ConfigGroup(org.guvnor.structure.server.config.ConfigGroup)

Example 4 with ConfigGroup

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

the class MigrationConfigurationServiceImpl method getConfiguration.

@Override
public List<ConfigGroup> getConfiguration(ConfigType configType) {
    if (ConfigType.SPACE.equals(configType)) {
        configType = ConfigType.ORGANIZATIONAL_UNIT;
    }
    final ConfigType type = configType;
    final List<ConfigGroup> configGroups = new ArrayList<>();
    final DirectoryStream<Path> foundConfigs = ioService.newDirectoryStream(ioService.get(systemRepository.getUri()), entry -> {
        if (!Files.isDirectory(entry) && !entry.getFileName().toString().startsWith(".") && entry.getFileName().toString().endsWith(type.getExt())) {
            return true;
        }
        return false;
    });
    // Only load and cache if a file was found!
    final Iterator<Path> it = foundConfigs.iterator();
    if (it.hasNext()) {
        while (it.hasNext()) {
            final String content = ioService.readAllString(it.next());
            final ConfigGroup configGroup = marshaller.unmarshall(content);
            configGroups.add(configGroup);
        }
        configGroupsByTypeWithoutNamespace.put(type, configGroups);
    }
    return configGroups;
}
Also used : Path(org.uberfire.java.nio.file.Path) ArrayList(java.util.ArrayList) ConfigGroup(org.guvnor.structure.server.config.ConfigGroup) ConfigType(org.guvnor.structure.server.config.ConfigType)

Example 5 with ConfigGroup

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

the class MigrationConfigurationServiceImpl method getConfigurationByNamespace.

@Override
public Map<String, List<ConfigGroup>> getConfigurationByNamespace(ConfigType type) {
    if (ConfigType.SPACE.equals(type)) {
        type = ConfigType.ORGANIZATIONAL_UNIT;
    }
    if (!ConfigType.REPOSITORY.equals(type)) {
        return Collections.emptyMap();
    }
    final Map<String, List<ConfigGroup>> repoConfigsBySpace = new HashMap<>();
    final List<ConfigGroup> repoConfigs = getConfiguration(type);
    for (ConfigGroup repoConfig : repoConfigs) {
        final String space = repoConfig.getConfigItemValue("space");
        if (space != null) {
            if (!repoConfigsBySpace.containsKey(space)) {
                repoConfigsBySpace.put(space, new ArrayList<>());
            }
            repoConfigsBySpace.get(space).add(repoConfig);
        }
    }
    return repoConfigsBySpace;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ConfigGroup(org.guvnor.structure.server.config.ConfigGroup)

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