Search in sources :

Example 1 with PreferenceType

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

the class PreferenceDaoTest method testCRUDPreference.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testCRUDPreference() {
    Preference savedPreference = preferenceDao.upsertPreference(preference);
    assertNotNull(savedPreference);
    assertEquals(preference, savedPreference);
    preferenceDao.upsertPreference(preference2);
    String newValue = "new value";
    String newDescription = "new description";
    String newGroup = "new group";
    PreferenceType newType = PreferenceType.FLOAT;
    preference.setValue(newValue);
    preference.setDescription(newDescription);
    preference.setPreferenceGroup(newGroup);
    preference.setType(newType);
    Preference updatedPreference = preferenceDao.upsertPreference(preference);
    assertEquals(preference, updatedPreference);
    Preference loadedByName = preferenceDao.loadPreferenceByName(TEST_NAME);
    assertEquals(preference, loadedByName);
    assertEquals(updatedPreference, loadedByName);
    Preference loadedPref2 = preferenceDao.loadPreferenceByName(preference2.getName());
    assertNotNull(loadedPref2);
    assertEquals(TEST_VALUE_2, loadedPref2.getValue());
    List<Preference> preferenceList = preferenceDao.loadAllPreferences();
    assertEquals(2, preferenceList.size());
    preferenceDao.deletePreference(savedPreference.getName());
    assertNull(preferenceDao.loadPreferenceByName(savedPreference.getName()));
}
Also used : Preference(com.epam.pipeline.entity.preference.Preference) PreferenceType(com.epam.pipeline.entity.preference.PreferenceType) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)1 Preference (com.epam.pipeline.entity.preference.Preference)1 PreferenceType (com.epam.pipeline.entity.preference.PreferenceType)1 Test (org.junit.Test)1 Transactional (org.springframework.transaction.annotation.Transactional)1