use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.
the class PreferenceManager method mergeWithDefaults.
private Preference mergeWithDefaults(Preference preference) {
Optional<AbstractSystemPreference<?>> systemPref = SystemPreferences.getSystemPreference(preference.getName());
if (!systemPref.isPresent()) {
Assert.notNull(preference.getType(), messageHelper.getMessage(MessageConstants.ERROR_PREFERENCE_TYPE_NOT_SPECIFIED));
return preference;
}
Preference origin = systemPref.get().toPreference();
// Just set the new value
origin.setValue(preference.getValue());
origin.setVisible(preference.isVisible());
return origin;
}
use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.
the class PreferenceManager method getSystemPreference.
public Preference getSystemPreference(AbstractSystemPreference systemPreference) {
Preference loaded = load(systemPreference.getKey()).orElseThrow(() -> new IllegalArgumentException(messageHelper.getMessage(MessageConstants.ERROR_PREFERENCE_WITH_NAME_NOT_FOUND, systemPreference.getKey())));
Assert.isTrue(loaded.getType() == systemPreference.getType(), messageHelper.getMessage(MessageConstants.ERROR_PREFERENCE_WITH_NAME_HAS_DIFFERENT_TYPE, loaded.getName(), loaded.getType().name()));
return loaded;
}
use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.
the class PreferenceDaoTest method setup.
@Before
public void setup() {
preference = new Preference(TEST_NAME, TEST_VALUE, TEST_GROUP, TEST_DESCRIPTION, TEST_TYPE, TEST_VISIBLE);
preference2 = new Preference(TEST_NAME_2, TEST_VALUE_2, TEST_GROUP, TEST_DESCRIPTION, TEST_TYPE, TEST_VISIBLE);
}
use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.
the class InstanceOfferManagerTest method testUpdateAllowedToolInstanceTypes.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testUpdateAllowedToolInstanceTypes() {
final Preference allowedToolTypesPreference = SystemPreferences.CLUSTER_ALLOWED_INSTANCE_TYPES_DOCKER.toPreference();
allowedToolTypesPreference.setValue(M5_PATTERN);
preferenceManager.update(Collections.singletonList(allowedToolTypesPreference));
Assert.assertTrue(instanceOfferManager.isToolInstanceAllowed(M5_INSTANCE_TYPE, null));
Assert.assertFalse(instanceOfferManager.isToolInstanceAllowed(X5_INSTANCE_TYPE, null));
allowedToolTypesPreference.setValue(M5_X5_PATTERN);
preferenceManager.update(Collections.singletonList(allowedToolTypesPreference));
Assert.assertTrue(instanceOfferManager.isToolInstanceAllowed(M5_INSTANCE_TYPE, null));
Assert.assertTrue(instanceOfferManager.isToolInstanceAllowed(X5_INSTANCE_TYPE, null));
}
use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.
the class DataStorageManagerTest method setUp.
@Before
public void setUp() {
doReturn(new MockS3Helper()).when(storageProviderManager).getS3Helper(any());
Preference systemIndependentBlackList = SystemPreferences.DATA_STORAGE_NFS_MOUNT_BLACK_LIST.toPreference();
systemIndependentBlackList.setValue(Arrays.asList(SystemPreferences.DATA_STORAGE_NFS_MOUNT_BLACK_LIST.getDefaultValue().split(",")).stream().map(p -> Paths.get(p).toString()).collect(Collectors.joining(",")));
preferenceManager.update(Collections.singletonList(systemIndependentBlackList));
}
Aggregations