Search in sources :

Example 1 with ContextualPreferenceVO

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));
}
Also used : ContextualPreference(com.epam.pipeline.entity.contextual.ContextualPreference) ContextualPreferenceVO(com.epam.pipeline.controller.vo.ContextualPreferenceVO) Test(org.junit.Test)

Example 2 with ContextualPreferenceVO

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)));
}
Also used : ContextualPreferenceExternalResource(com.epam.pipeline.entity.contextual.ContextualPreferenceExternalResource) ContextualPreferenceVO(com.epam.pipeline.controller.vo.ContextualPreferenceVO) Test(org.junit.Test)

Example 3 with ContextualPreferenceVO

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));
}
Also used : ContextualPreference(com.epam.pipeline.entity.contextual.ContextualPreference) ContextualPreferenceVO(com.epam.pipeline.controller.vo.ContextualPreferenceVO) Test(org.junit.Test)

Example 4 with ContextualPreferenceVO

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))));
}
Also used : ContextualPreferenceExternalResource(com.epam.pipeline.entity.contextual.ContextualPreferenceExternalResource) ContextualPreferenceVO(com.epam.pipeline.controller.vo.ContextualPreferenceVO) Test(org.junit.Test)

Example 5 with ContextualPreferenceVO

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));
}
Also used : ContextualPreferenceExternalResource(com.epam.pipeline.entity.contextual.ContextualPreferenceExternalResource) ContextualPreference(com.epam.pipeline.entity.contextual.ContextualPreference) ContextualPreferenceVO(com.epam.pipeline.controller.vo.ContextualPreferenceVO) Test(org.junit.Test)

Aggregations

ContextualPreferenceVO (com.epam.pipeline.controller.vo.ContextualPreferenceVO)6 Test (org.junit.Test)6 ContextualPreference (com.epam.pipeline.entity.contextual.ContextualPreference)4 ContextualPreferenceExternalResource (com.epam.pipeline.entity.contextual.ContextualPreferenceExternalResource)3