### Question:
BaseAppSetup { protected void setupConfigurationGroup(ConfigType configType, String configGroupName, ConfigGroup configGroup, ConfigItem... configItemsToSetManually) { List<ConfigGroup> existentConfigGroups = configurationService.getConfiguration(configType); boolean settingsDefined = false; for (ConfigGroup existentConfigGroup : existentConfigGroups) { if (configGroupName.equals(existentConfigGroup.getName())) { settingsDefined = true; if (configItemsToSetManually != null) { for (ConfigItem configItem : configItemsToSetManually) { ConfigItem existentConfigItem = existentConfigGroup.getConfigItem(configItem.getName()); if (existentConfigItem == null) { existentConfigGroup.addConfigItem(configItem); configurationService.updateConfiguration(existentConfigGroup); } else if (!existentConfigItem.getValue().equals(configItem.getValue())) { existentConfigItem.setValue(configItem.getValue()); configurationService.updateConfiguration(existentConfigGroup); } } } break; } } if (!settingsDefined) { configurationService.addConfiguration(configGroup); } } protected  BaseAppSetup();  BaseAppSetup(final IOService ioService,
                        final RepositoryService repositoryService,
                        final OrganizationalUnitService organizationalUnitService,
                        final KieModuleService moduleService,
                        final ConfigurationService configurationService,
                        final ConfigurationFactory configurationFactory);   }### Answer:
@Test public void setupDefinedConfigurationGroupTest() { final ConfigType configType = ConfigType.GLOBAL; final String configGroupName = BaseAppSetup.GLOBAL_SETTINGS; final ConfigGroup existentConfigGroup = setupPredefinedGlobalConfiguration(); List<ConfigGroup> definedConfigGroups = new ArrayList<>(1); definedConfigGroups.add(existentConfigGroup); doReturn(definedConfigGroups).when(configurationService).getConfiguration(eq(ConfigType.GLOBAL)); final ConfigItem<String> existentDroolsDefaultLanguageConfigItem = configItemsByName.get("drools.defaultlanguage"); final ConfigItem<String> existentSupportRuntimeDeployConfigItem = configItemsByName.get("support.runtime.deploy"); final ConfigItem<String> droolsDefaultLanguageConfigItem = new ConfigItem<>(); droolsDefaultLanguageConfigItem.setName("drools.defaultlanguage"); droolsDefaultLanguageConfigItem.setValue("en"); final ConfigItem<String> droolsDefaultCountryConfigItem = new ConfigItem<>(); droolsDefaultCountryConfigItem.setName("drools.defaultcountry"); droolsDefaultCountryConfigItem.setValue("US"); final ConfigItem<String> supportRuntimeDeployConfigItem = new ConfigItem<>(); supportRuntimeDeployConfigItem.setName("support.runtime.deploy"); supportRuntimeDeployConfigItem.setValue("true"); baseAppSetup.setupConfigurationGroup(configType, configGroupName, null, droolsDefaultLanguageConfigItem, droolsDefaultCountryConfigItem, supportRuntimeDeployConfigItem); verify(configurationService, never()).addConfiguration(any(ConfigGroup.class)); verify(configurationService, times(2)).updateConfiguration(existentConfigGroup); verify(existentConfigGroup, never()).addConfigItem(droolsDefaultLanguageConfigItem); verify(existentConfigGroup).addConfigItem(droolsDefaultCountryConfigItem); verify(existentConfigGroup, never()).addConfigItem(supportRuntimeDeployConfigItem); verify(existentDroolsDefaultLanguageConfigItem).setValue(droolsDefaultLanguageConfigItem.getValue()); verify(existentSupportRuntimeDeployConfigItem, never()).setValue(anyString()); }
@Test public void setupUndefinedConfigurationGroupTest() { doReturn(new ArrayList<>()).when(configurationService).getConfiguration(eq(ConfigType.GLOBAL)); final ConfigType configType = ConfigType.GLOBAL; final String configGroupName = BaseAppSetup.GLOBAL_SETTINGS; final ConfigGroup configGroup = setupPredefinedGlobalConfiguration(); baseAppSetup.setupConfigurationGroup(configType, configGroupName, configGroup); verify(configurationService).addConfiguration(any(ConfigGroup.class)); verify(configurationService, never()).updateConfiguration(any(ConfigGroup.class)); }