use of com.epam.pipeline.controller.vo.ContextualPreferenceVO in project cloud-pipeline by epam.
the class ContextualPreferenceManagerTest method upsertShouldFailIfPreferenceExternalResourceDoesNotExist.
@Test
public void upsertShouldFailIfPreferenceExternalResourceDoesNotExist() {
final ContextualPreferenceVO preferenceVO = new ContextualPreferenceVO(NAME, VALUE, TYPE, toolResource);
final ContextualPreference preference = new ContextualPreference(NAME, VALUE, TYPE, toolResource);
when(contextualPreferenceHandler.isValid(eq(preference))).thenReturn(false);
assertThrows(IllegalArgumentException.class, () -> manager.upsert(preferenceVO));
}
use of com.epam.pipeline.controller.vo.ContextualPreferenceVO in project cloud-pipeline by epam.
the class ContextualPreferenceManagerTest method upsertShouldFailIfPreferenceLevelIsSystem.
@Test
public void upsertShouldFailIfPreferenceLevelIsSystem() {
final ContextualPreferenceExternalResource resource = new ContextualPreferenceExternalResource(ContextualPreferenceLevel.SYSTEM, TOOL_ID);
assertThrows(IllegalArgumentException.class, () -> manager.upsert(new ContextualPreferenceVO(NAME, VALUE, TYPE, resource)));
}
use of com.epam.pipeline.controller.vo.ContextualPreferenceVO in project cloud-pipeline by epam.
the class ContextualPreferenceManagerTest method upsertShouldFailIfPreferenceValueDoesNotSuitItsType.
@Test
public void upsertShouldFailIfPreferenceValueDoesNotSuitItsType() {
final ContextualPreferenceVO preferenceVO = new ContextualPreferenceVO(NAME, VALUE, ANOTHER_TYPE, toolResource);
final ContextualPreference preference = new ContextualPreference(NAME, VALUE, ANOTHER_TYPE, toolResource);
when(contextualPreferenceHandler.isValid(eq(preference))).thenReturn(true);
when(contextualPreferenceDao.load(eq(preference.getName()))).thenReturn(Collections.emptyList());
assertThrows(IllegalArgumentException.class, () -> manager.upsert(preferenceVO));
}
use of com.epam.pipeline.controller.vo.ContextualPreferenceVO in project cloud-pipeline by epam.
the class ContextualPreferenceManagerTest method upsertShouldFailIfPreferenceHasEmptyFields.
@Test
public void upsertShouldFailIfPreferenceHasEmptyFields() {
when(contextualPreferenceHandler.isValid(any())).thenReturn(true);
assertThrows(IllegalArgumentException.class, () -> manager.upsert(new ContextualPreferenceVO(null, VALUE, TYPE, toolResource)));
assertThrows(IllegalArgumentException.class, () -> manager.upsert(new ContextualPreferenceVO(NAME, null, TYPE, toolResource)));
assertThrows(IllegalArgumentException.class, () -> manager.upsert(new ContextualPreferenceVO(NAME, VALUE, null, toolResource)));
assertThrows(IllegalArgumentException.class, () -> manager.upsert(new ContextualPreferenceVO(NAME, VALUE, TYPE, new ContextualPreferenceExternalResource(null, TOOL_ID))));
assertThrows(IllegalArgumentException.class, () -> manager.upsert(new ContextualPreferenceVO(NAME, VALUE, TYPE, new ContextualPreferenceExternalResource(LEVEL, null))));
}
use of com.epam.pipeline.controller.vo.ContextualPreferenceVO in project cloud-pipeline by epam.
the class ContextualPreferenceManagerTest method upsertShouldFailIfPreferenceTypeDiffersWithExistingPreferencesWithTheSameName.
@Test
public void upsertShouldFailIfPreferenceTypeDiffersWithExistingPreferencesWithTheSameName() {
final ContextualPreferenceExternalResource anotherResource = new ContextualPreferenceExternalResource(LEVEL, ANOTHER_TOOL_ID);
final ContextualPreferenceVO preferenceVO = new ContextualPreferenceVO(NAME, VALUE, TYPE, toolResource);
final ContextualPreference preference = new ContextualPreference(NAME, VALUE, TYPE, toolResource);
when(contextualPreferenceHandler.isValid(eq(preference))).thenReturn(true);
when(contextualPreferenceDao.load(eq(preference.getName()))).thenReturn(Collections.singletonList(new ContextualPreference(NAME, VALUE, ANOTHER_TYPE, anotherResource)));
assertThrows(IllegalArgumentException.class, () -> manager.upsert(preferenceVO));
}
Aggregations