use of com.epam.pipeline.entity.contextual.ContextualPreferenceExternalResource in project cloud-pipeline by epam.
the class PipelineRunManager method validateToolInstanceAndPriceTypes.
private void validateToolInstanceAndPriceTypes(final PipelineConfiguration configuration, final String instanceType, final PriceType priceType) {
final Tool tool = toolManager.loadByNameOrId(configuration.getDockerImage());
final ContextualPreferenceExternalResource toolResource = new ContextualPreferenceExternalResource(ContextualPreferenceLevel.TOOL, tool.getId().toString());
Assert.isTrue(!StringUtils.hasText(instanceType) || instanceOfferManager.isToolInstanceAllowed(instanceType, toolResource), messageHelper.getMessage(MessageConstants.ERROR_INSTANCE_TYPE_IS_NOT_ALLOWED, instanceType));
Assert.isTrue(instanceOfferManager.isPriceTypeAllowed(priceType.getLiteral(), toolResource), messageHelper.getMessage(MessageConstants.ERROR_PRICE_TYPE_IS_NOT_ALLOWED, priceType));
}
use of com.epam.pipeline.entity.contextual.ContextualPreferenceExternalResource in project cloud-pipeline by epam.
the class RunConfigurationProvider method validateEntryConfiguration.
private void validateEntryConfiguration(final PipelineConfiguration configuration) {
if (configuration.getInstanceType() != null) {
final ContextualPreferenceExternalResource resource = retrieveResource(configuration);
Assert.isTrue(instanceOfferManager.isToolInstanceAllowed(configuration.getInstanceType(), resource), messageHelper.getMessage(MessageConstants.ERROR_INSTANCE_TYPE_IS_NOT_ALLOWED, configuration.getInstanceType()));
}
}
use of com.epam.pipeline.entity.contextual.ContextualPreferenceExternalResource in project cloud-pipeline by epam.
the class ContextualPreferenceDaoTest method upsertShouldUpdateCreatedDateWhileUpdatingPreference.
@Test
public void upsertShouldUpdateCreatedDateWhileUpdatingPreference() {
final ContextualPreferenceExternalResource resource = new ContextualPreferenceExternalResource(LEVEL, RESOURCE_ID);
final ContextualPreference preference = new ContextualPreference(NAME, VALUE, resource);
final ContextualPreference oldPreference = contextualPreferenceDao.upsert(preference);
contextualPreferenceDao.upsert(oldPreference.withValue(ANOTHER_VALUE));
final Optional<ContextualPreference> loadedPreference = contextualPreferenceDao.load(NAME, resource);
assertTrue(loadedPreference.isPresent());
assertThat(loadedPreference.get().getCreatedDate(), is(not(oldPreference.getCreatedDate())));
}
use of com.epam.pipeline.entity.contextual.ContextualPreferenceExternalResource in project cloud-pipeline by epam.
the class ContextualPreferenceDaoTest method upsertShouldCreatePreference.
@Test
public void upsertShouldCreatePreference() {
final ContextualPreferenceExternalResource resource = new ContextualPreferenceExternalResource(LEVEL, RESOURCE_ID);
final ContextualPreference preference = contextualPreferenceDao.upsert(new ContextualPreference(NAME, VALUE, resource));
final Optional<ContextualPreference> loadedPreference = contextualPreferenceDao.load(NAME, resource);
assertTrue(loadedPreference.isPresent());
assertThat(loadedPreference.get(), is(preference));
}
use of com.epam.pipeline.entity.contextual.ContextualPreferenceExternalResource in project cloud-pipeline by epam.
the class ContextualPreferenceDaoTest method loadShouldReturnPreference.
@Test
public void loadShouldReturnPreference() {
final ContextualPreferenceExternalResource resource = new ContextualPreferenceExternalResource(LEVEL, RESOURCE_ID);
final ContextualPreference preference = new ContextualPreference(NAME, VALUE, TYPE, resource);
final ContextualPreference storedPreference = contextualPreferenceDao.upsert(preference);
final Optional<ContextualPreference> loadedPreference = contextualPreferenceDao.load(NAME, resource);
assertTrue(loadedPreference.isPresent());
loadedPreference.ifPresent(pref -> {
assertThat(pref.getName(), is(storedPreference.getName()));
assertThat(pref.getValue(), is(storedPreference.getValue()));
assertThat(pref.getType(), is(storedPreference.getType()));
assertThat(pref.getCreatedDate(), is(storedPreference.getCreatedDate()));
assertThat(pref.getResource(), is(storedPreference.getResource()));
});
}
Aggregations