Search in sources :

Example 21 with Preference

use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.

the class ParallelExecutorServiceTest method testGetExecutorService.

@Test
@Transactional(propagation = Propagation.REQUIRED)
public void testGetExecutorService() throws InterruptedException {
    ExecutorService service1 = parallelExecutorService.getExecutorService();
    Preference maxThreads = SystemPreferences.CLUSTER_NODEUP_MAX_THREADS.toPreference();
    maxThreads.setValue("2");
    preferenceManager.update(Collections.singletonList(maxThreads));
    // Wait for a new executor to be created
    Thread.sleep(TIMEOUT);
    ExecutorService service2 = parallelExecutorService.getExecutorService();
    Assert.assertNotEquals(service1, service2);
}
Also used : Preference(com.epam.pipeline.entity.preference.Preference) ExecutorService(java.util.concurrent.ExecutorService) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 22 with Preference

use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.

the class PreferenceManagerTest method storeAndLoadTest.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void storeAndLoadTest() {
    Preference preference = new Preference(NAME, VALUE, GROUP, "", PreferenceType.STRING, true);
    preferenceManager.update(Collections.singletonList(preference));
    String load = preferenceManager.getStringPreference(NAME);
    Assert.assertEquals(VALUE, load);
}
Also used : Preference(com.epam.pipeline.entity.preference.Preference) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 23 with Preference

use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.

the class PreferenceManagerTest method castTest.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void castTest() {
    Preference preference = new Preference(NAME, "1", GROUP, "", PreferenceType.INTEGER, true);
    preferenceManager.update(Collections.singletonList(preference));
    Integer load = preferenceManager.getIntPreference(NAME);
    Assert.assertEquals(1, load.intValue());
}
Also used : Preference(com.epam.pipeline.entity.preference.Preference) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 24 with Preference

use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.

the class PreferenceManagerTest method testGetObservablePreference.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testGetObservablePreference() {
    Observable<Integer> commitTimeoutObservable = preferenceManager.getObservablePreference(SystemPreferences.COMMIT_TIMEOUT);
    TestSubscriber<Integer> test1 = new TestSubscriber<>();
    TestSubscriber<Integer> test2 = new TestSubscriber<>();
    commitTimeoutObservable.subscribe(test1::onNext);
    commitTimeoutObservable.subscribe(test2::onNext);
    Preference commitTimeout = SystemPreferences.COMMIT_TIMEOUT.toPreference();
    commitTimeout.setValue("1111");
    preferenceManager.update(Collections.singletonList(commitTimeout));
    test1.assertValueCount(1);
    test2.assertValueCount(1);
    preferenceManager.delete(commitTimeout.getName());
    test1.assertValueCount(2);
    test2.assertValueCount(2);
}
Also used : Preference(com.epam.pipeline.entity.preference.Preference) TestSubscriber(io.reactivex.subscribers.TestSubscriber) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 25 with Preference

use of com.epam.pipeline.entity.preference.Preference in project cloud-pipeline by epam.

the class PreferenceManagerTest method updateTest.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void updateTest() {
    Preference preference = new Preference(NAME, VALUE, GROUP, "", PreferenceType.STRING, true);
    preferenceManager.update(Collections.singletonList(preference));
    String load = preferenceManager.getStringPreference(NAME);
    Assert.assertEquals(VALUE, load);
    preference.setValue(NEW_VALUE);
    preferenceManager.update(Collections.singletonList(preference));
    load = preferenceManager.getStringPreference(NAME);
    Assert.assertEquals(NEW_VALUE, load);
}
Also used : Preference(com.epam.pipeline.entity.preference.Preference) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

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