Search in sources :

Example 1 with Preference

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;
}
Also used : Preference(com.epam.pipeline.entity.preference.Preference) ObjectPreference(com.epam.pipeline.manager.preference.AbstractSystemPreference.ObjectPreference)

Example 2 with Preference

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;
}
Also used : Preference(com.epam.pipeline.entity.preference.Preference) ObjectPreference(com.epam.pipeline.manager.preference.AbstractSystemPreference.ObjectPreference)

Example 3 with Preference

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);
}
Also used : Preference(com.epam.pipeline.entity.preference.Preference) Before(org.junit.Before)

Example 4 with Preference

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));
}
Also used : Preference(com.epam.pipeline.entity.preference.Preference) Test(org.junit.Test) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Preference

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));
}
Also used : Preference(com.epam.pipeline.entity.preference.Preference) MockS3Helper(com.epam.pipeline.manager.MockS3Helper) Before(org.junit.Before)

Aggregations

Preference (com.epam.pipeline.entity.preference.Preference)27 Test (org.junit.Test)20 Transactional (org.springframework.transaction.annotation.Transactional)17 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)11 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)5 Before (org.junit.Before)5 DataStorageVO (com.epam.pipeline.controller.vo.DataStorageVO)3 AwsRegionVO (com.epam.pipeline.controller.vo.AwsRegionVO)2 Attachment (com.epam.pipeline.entity.issue.Attachment)2 AwsRegion (com.epam.pipeline.entity.region.AwsRegion)2 ObjectPreference (com.epam.pipeline.manager.preference.AbstractSystemPreference.ObjectPreference)2 PreferenceManager (com.epam.pipeline.manager.preference.PreferenceManager)2 SystemPreferences (com.epam.pipeline.manager.preference.SystemPreferences)2 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)2 MessageHelper (com.epam.pipeline.common.MessageHelper)1 EntityVO (com.epam.pipeline.controller.vo.EntityVO)1 PreferenceDao (com.epam.pipeline.dao.preference.PreferenceDao)1 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)1 DataStorageFile (com.epam.pipeline.entity.datastorage.DataStorageFile)1 DataStorageStreamingContent (com.epam.pipeline.entity.datastorage.DataStorageStreamingContent)1