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