use of org.guvnor.structure.server.config.ConfigGroup in project kie-wb-common by kiegroup.
the class InternalMigrationServiceTest method testCreateSpaceDirs.
@Test
public void testCreateSpaceDirs() {
final String firstOuName = "firstOrgUnit", secondOuName = "secondOrgUnit";
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 firstOuConfig = new ConfigGroup();
firstOuConfig.setName(firstOuName);
firstOuConfig.addConfigItem(contributors);
firstOuConfig.addConfigItem(groups);
ConfigGroup secondOuConfig = new ConfigGroup();
secondOuConfig.setName(secondOuName);
secondOuConfig.addConfigItem(contributors);
secondOuConfig.addConfigItem(groups);
List<ConfigGroup> orgUnitConfigs = new ArrayList<>();
orgUnitConfigs.add(firstOuConfig);
orgUnitConfigs.add(secondOuConfig);
Path mockPath = mock(Path.class);
File mockFile = mock(File.class);
when(mockPath.toFile()).thenReturn(mockFile);
when(mockPath.resolve(anyString())).thenReturn(mockPath);
internalMigrationService.createSpaceDirs(mockPath, orgUnitConfigs);
verify(mockPath).resolve(firstOuName);
verify(mockPath).resolve(secondOuName);
verify(mockFile, times(2)).mkdir();
verify(spaceConfigStorageRegistry, times(4)).get(anyString());
verify(spaceConfigStorage, times(2)).saveSpaceInfo(any());
}
use of org.guvnor.structure.server.config.ConfigGroup in project kie-wb-common by kiegroup.
the class MigrationConfigurationFactoryImplTest method newConfigGroupWithNamespaceTest.
@Test
public void newConfigGroupWithNamespaceTest() {
final ConfigGroup configGroup = configurationFactory.newConfigGroup(ConfigType.REPOSITORY, "my-namespace", "my-config", "my-description");
assertEquals(ConfigType.REPOSITORY, configGroup.getType());
assertEquals("my-config", configGroup.getName());
assertEquals("my-description", configGroup.getDescription());
assertTrue(configGroup.isEnabled());
}
use of org.guvnor.structure.server.config.ConfigGroup in project kie-wb-common by kiegroup.
the class ConfigGroupsMigrationService method groupConfigGroupsByType.
private void groupConfigGroupsByType() {
final org.uberfire.java.nio.file.Path systemDir = ioService.get(systemRepository.getUri());
for (ConfigType oldType : ConfigType.values()) {
final String oldExt = oldType.getExt();
final DirectoryStream<org.uberfire.java.nio.file.Path> foundConfigs = getDirectoryStreamForFilesWithParticularExtension(systemDir, oldExt);
final ConfigType newType = getNewType(oldType);
final org.uberfire.java.nio.file.Path newTypeDir = systemDir.resolve(newType.getDir());
if (!ioService.exists(newTypeDir)) {
ioService.createDirectory(newTypeDir);
}
final Iterator<org.uberfire.java.nio.file.Path> it = foundConfigs.iterator();
while (it.hasNext()) {
final org.uberfire.java.nio.file.Path oldPath = it.next();
final String newExt = newType.getExt();
final String oldFileName = Paths.convert(oldPath).getFileName();
final String newFileName = FileNameUtil.removeExtension(oldFileName, oldExt.substring(1)) + newExt;
final org.uberfire.java.nio.file.Path newPath = newTypeDir.resolve(newFileName);
ioService.move(oldPath, newPath);
if (!newType.equals(oldType)) {
final String content = ioService.readAllString(newPath);
final ConfigGroup configGroup = marshaller.unmarshall(content);
configGroup.setType(newType);
ioService.write(newPath, marshaller.marshall(configGroup), new CommentedOption(getIdentityName(), "Updated configuration type."));
}
}
}
}
use of org.guvnor.structure.server.config.ConfigGroup in project kie-wb-common by kiegroup.
the class MigrateAllProjectsTest method testMigrateAllProjects.
@Test
public void testMigrateAllProjects() throws Exception {
List<ConfigGroup> spaceConfigs = initConfigGroups();
List<WorkspaceProject> workspaceProjects = initWorkspaceProjects();
PowerMockito.mockStatic(Files.class);
Path niogitDir = mock(Path.class);
File niogitDirFile = mock(File.class);
when(Files.move(any(Path.class), any(Path.class))).thenReturn(niogitDir);
when(projectService.getAllWorkspaceProjects()).thenReturn(workspaceProjects);
when(system.out()).thenReturn(System.out);
when(configService.getConfiguration(ConfigType.ORGANIZATIONAL_UNIT)).thenReturn(spaceConfigs);
when(configService.getConfiguration(ConfigType.REPOSITORY)).thenReturn(spaceConfigs);
when(niogitDir.toFile()).thenReturn(niogitDirFile);
when(niogitDir.resolve(anyString())).thenReturn(niogitDir);
service.migrateAllProjects(niogitDir);
verify(projectMigrationService, times(workspaceProjects.size())).migrate(any(WorkspaceProject.class));
verify(repoService, times(NUMBER_OF_REPOS)).deleteRepository(any());
}
use of org.guvnor.structure.server.config.ConfigGroup in project kie-wb-common by kiegroup.
the class ResourceChangeIncrementalBuilderWithoutFullBuildTest method setUp.
@Before
public void setUp() throws Exception {
// Define mandatory properties
List<ConfigGroup> globalConfigGroups = configurationService.getConfiguration(ConfigType.GLOBAL);
boolean globalSettingsDefined = false;
for (ConfigGroup globalConfigGroup : globalConfigGroups) {
if (GLOBAL_SETTINGS.equals(globalConfigGroup.getName())) {
globalSettingsDefined = true;
break;
}
}
if (!globalSettingsDefined) {
configurationService.addConfiguration(getGlobalConfiguration());
}
}
Aggregations