use of com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver in project midpoint by Evolveum.
the class MappingTestEvaluator method init.
private void init(boolean withMetadata) throws SchemaException, SAXException, IOException {
this.withMetadata = withMetadata;
PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX);
PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY);
prismContext = PrismTestUtil.createInitializedPrismContext();
ObjectResolver resolver = new DirectoryFileObjectResolver(MidPointTestConstants.OBJECTS_DIR);
protector = ExpressionTestUtil.createInitializedProtector(prismContext);
Clock clock = new Clock();
ExpressionFactory expressionFactory = ExpressionTestUtil.createInitializedExpressionFactory(resolver, protector, prismContext, clock, null, null);
// We need only selected beans for the mapping factory
ModelCommonBeans beans = new ModelCommonBeans();
beans.expressionFactory = expressionFactory;
beans.objectResolver = resolver;
beans.prismContext = prismContext;
beans.protector = protector;
if (withMetadata) {
BuiltinMetadataMappingsRegistry builtinMetadataMappingsRegistry = new BuiltinMetadataMappingsRegistry();
ProvenanceBuiltinMapping provenanceBuiltinMapping = new ProvenanceBuiltinMapping(prismContext, builtinMetadataMappingsRegistry);
provenanceBuiltinMapping.register();
beans.metadataMappingEvaluator = new MetadataMappingEvaluator(mappingFactory, prismContext, builtinMetadataMappingsRegistry);
}
mappingFactory = new MappingFactory();
mappingFactory.setBeans(beans);
mappingFactory.setProfiling(true);
}
use of com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver in project midpoint by Evolveum.
the class TestExpressionUtil method resolvePath.
private <T> T resolvePath(String path, VariablesMap variables, String exprShortDesc) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
OperationResult result = createOperationResult();
ItemPath itemPath = toItemPath(path);
// WHEN
ObjectResolver objectResolver = new DirectoryFileObjectResolver(MidPointTestConstants.OBJECTS_DIR);
Object resolved = ExpressionUtil.resolvePathGetValue(itemPath, variables, false, null, objectResolver, PrismTestUtil.getPrismContext(), exprShortDesc, new NullTaskImpl(), result);
// THEN
IntegrationTestTools.display("Resolved", resolved);
// noinspection unchecked
return (T) resolved;
}
use of com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver in project midpoint by Evolveum.
the class AbstractScriptTest method setupFactory.
@BeforeClass
public void setupFactory() {
prismContext = PrismTestUtil.getPrismContext();
ObjectResolver resolver = new DirectoryFileObjectResolver(OBJECTS_DIR);
Protector protector = KeyStoreBasedProtectorBuilder.create(prismContext).buildOnly();
Clock clock = new Clock();
Collection<FunctionLibrary> functions = new ArrayList<>();
functions.add(FunctionLibraryUtil.createBasicFunctionLibrary(prismContext, protector, clock));
scriptExpressionfactory = new ScriptExpressionFactory(prismContext, null);
scriptExpressionfactory.setObjectResolver(resolver);
scriptExpressionfactory.setFunctions(functions);
localizationService = LocalizationTestUtil.getLocalizationService();
evaluator = createEvaluator(prismContext, protector);
if (!evaluator.isInitialized()) {
display("Script engine for " + evaluator.getLanguageName() + " missing, skipping the tests.");
throw new SkipException("Script engine not available");
}
String languageUrl = evaluator.getLanguageUrl();
display("Expression test for " + evaluator.getLanguageName() + ": registering " + evaluator + " with URL " + languageUrl);
scriptExpressionfactory.registerEvaluator(languageUrl, evaluator);
}
use of com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver in project midpoint by Evolveum.
the class TestExpression method setup.
@BeforeClass
public void setup() throws SchemaException, SAXException, IOException {
PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX);
PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY);
prismContext = PrismTestUtil.createInitializedPrismContext();
ObjectResolver resolver = new DirectoryFileObjectResolver(MidPointTestConstants.OBJECTS_DIR);
Protector protector = ExpressionTestUtil.createInitializedProtector(prismContext);
Clock clock = new Clock();
constantsManager = new ConstantsManager();
expressionFactory = ExpressionTestUtil.createInitializedExpressionFactory(resolver, protector, prismContext, clock, null, null);
expressionProfile = compileExpressionProfile(getExpressionProfileName());
System.out.println("Using expression profile: " + expressionProfile);
logger.info("EXPRESSION PROFILE: {}", expressionProfile);
}
use of com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver in project midpoint by Evolveum.
the class TestScriptCaching method setupFactory.
@BeforeClass
public void setupFactory() {
display("Setting up expression factory and evaluator");
PrismContext prismContext = getPrismContext();
ObjectResolver resolver = new DirectoryFileObjectResolver(OBJECTS_DIR);
Protector protector = KeyStoreBasedProtectorBuilder.create(prismContext).buildOnly();
Clock clock = new Clock();
Collection<FunctionLibrary> functions = new ArrayList<>();
functions.add(FunctionLibraryUtil.createBasicFunctionLibrary(prismContext, protector, clock));
scriptExpressionfactory = new ScriptExpressionFactory(prismContext, null);
scriptExpressionfactory.setObjectResolver(resolver);
scriptExpressionfactory.setFunctions(functions);
evaluator = new Jsr223ScriptEvaluator("groovy", prismContext, protector, LocalizationTestUtil.getLocalizationService());
String languageUrl = evaluator.getLanguageUrl();
scriptExpressionfactory.registerEvaluator(languageUrl, evaluator);
}
Aggregations