use of com.epam.pipeline.entity.contextual.ContextualPreference in project cloud-pipeline by epam.
the class UserContextualPreferenceHandlerTest method isValidShouldReturnFalseIfUserDoesNotExist.
@Test
public void isValidShouldReturnFalseIfUserDoesNotExist() {
final ContextualPreference preference = new ContextualPreference(NAME, VALUE, resource);
when(userDao.loadUserById(eq(Long.valueOf(RESOURCE_ID)))).thenReturn(null);
assertFalse(handler().isValid(preference));
}
use of com.epam.pipeline.entity.contextual.ContextualPreference in project cloud-pipeline by epam.
the class InstanceOfferManagerUnitTest method isToolInstanceAllowedShouldReturnFalseIfInstanceTypeDoesNotMatchAnyOfTheAllowedPatterns.
@Test
public void isToolInstanceAllowedShouldReturnFalseIfInstanceTypeDoesNotMatchAnyOfTheAllowedPatterns() {
when(contextualPreferenceManager.search(eq(DOCKER_INSTANCE_TYPES_PREFERENCES), eq(TOOL_RESOURCE))).thenReturn(new ContextualPreference(ALLOWED_DOCKER_INSTANCE_TYPES_PREFERENCE, M4_M5_PATTERNS));
assertFalse(instanceOfferManager.isToolInstanceAllowed(T2_LARGE, TOOL_RESOURCE));
verify(contextualPreferenceManager).search(eq(DOCKER_INSTANCE_TYPES_PREFERENCES), eq(TOOL_RESOURCE));
}
use of com.epam.pipeline.entity.contextual.ContextualPreference in project cloud-pipeline by epam.
the class InstanceOfferManagerUnitTest method getAllowedInstanceAndPriceTypesShouldSearchPreferencesUsingToolAsExternalResourceIfToolIdIsSpecified.
@Test
public void getAllowedInstanceAndPriceTypesShouldSearchPreferencesUsingToolAsExternalResourceIfToolIdIsSpecified() {
final List<String> allowedPriceTypes = Arrays.asList(SPOT, ON_DEMAND);
final List<InstanceType> allInstanceTypes = Arrays.asList(m4InstanceType, m5InstanceType, t2InstanceType);
final List<InstanceType> allowedInstanceTypes = Arrays.asList(m4InstanceType, m5InstanceType);
final List<InstanceType> allowedInstanceDockerTypes = Collections.singletonList(m4InstanceType);
when(contextualPreferenceManager.search(eq(INSTANCE_TYPES_PREFERENCES), eq(TOOL_RESOURCE))).thenReturn(new ContextualPreference(ALLOWED_INSTANCE_TYPES_PREFERENCE, M4_M5_PATTERNS));
when(contextualPreferenceManager.search(eq(Arrays.asList(ALLOWED_DOCKER_INSTANCE_TYPES_PREFERENCE, ALLOWED_INSTANCE_TYPES_PREFERENCE)), eq(TOOL_RESOURCE))).thenReturn(new ContextualPreference(ALLOWED_DOCKER_INSTANCE_TYPES_PREFERENCE, M4_PATTERN));
when(contextualPreferenceManager.search(eq(Collections.singletonList(ALLOWED_PRICE_TYPES_PREFERENCE)), eq(TOOL_RESOURCE))).thenReturn(new ContextualPreference(ALLOWED_PRICE_TYPES_PREFERENCE, SPOT_AND_ON_DEMAND_TYPES));
when(instanceOfferDao.loadInstanceTypes(any())).thenReturn(allInstanceTypes);
final AllowedInstanceAndPriceTypes allowedInstanceAndPriceTypes = instanceOfferManager.getAllowedInstanceAndPriceTypes(TOOL_ID);
assertThat(allowedInstanceAndPriceTypes.getAllowedInstanceTypes(), is(allowedInstanceTypes));
assertThat(allowedInstanceAndPriceTypes.getAllowedInstanceDockerTypes(), is(allowedInstanceDockerTypes));
assertThat(allowedInstanceAndPriceTypes.getAllowedPriceTypes(), is(allowedPriceTypes));
}
use of com.epam.pipeline.entity.contextual.ContextualPreference in project cloud-pipeline by epam.
the class InstanceOfferManagerUnitTest method isToolInstanceAllowedShouldReturnFalseIfInstanceTypeIsNotOffered.
@Test
public void isToolInstanceAllowedShouldReturnFalseIfInstanceTypeIsNotOffered() {
when(contextualPreferenceManager.search(eq(DOCKER_INSTANCE_TYPES_PREFERENCES), eq(TOOL_RESOURCE))).thenReturn(new ContextualPreference(ALLOWED_DOCKER_INSTANCE_TYPES_PREFERENCE, S2_PATTERN));
assertFalse(instanceOfferManager.isToolInstanceAllowed(S2_LARGE, TOOL_RESOURCE));
verify(contextualPreferenceManager).search(eq(DOCKER_INSTANCE_TYPES_PREFERENCES), eq(TOOL_RESOURCE));
}
use of com.epam.pipeline.entity.contextual.ContextualPreference in project cloud-pipeline by epam.
the class InstanceOfferManagerUnitTest method isInstanceAllowedShouldReturnFalseIfInstanceTypeIsNotOffered.
@Test
public void isInstanceAllowedShouldReturnFalseIfInstanceTypeIsNotOffered() {
when(contextualPreferenceManager.search(eq(INSTANCE_TYPES_PREFERENCES), eq(null))).thenReturn(new ContextualPreference(ALLOWED_INSTANCE_TYPES_PREFERENCE, S2_PATTERN));
assertFalse(instanceOfferManager.isInstanceAllowed(S2_LARGE));
verify(contextualPreferenceManager).search(eq(INSTANCE_TYPES_PREFERENCES), eq(null));
}
Aggregations