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()));
}
Aggregations