Search in sources :

Example 1 with DirectoryFileObjectResolver

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);
}
Also used : BuiltinMetadataMappingsRegistry(com.evolveum.midpoint.model.common.mapping.metadata.builtin.BuiltinMetadataMappingsRegistry) ExpressionFactory(com.evolveum.midpoint.repo.common.expression.ExpressionFactory) MetadataMappingEvaluator(com.evolveum.midpoint.model.common.mapping.metadata.MetadataMappingEvaluator) ModelCommonBeans(com.evolveum.midpoint.model.common.ModelCommonBeans) DirectoryFileObjectResolver(com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver) ObjectResolver(com.evolveum.midpoint.repo.common.ObjectResolver) DirectoryFileObjectResolver(com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver) ProvenanceBuiltinMapping(com.evolveum.midpoint.model.common.mapping.metadata.builtin.ProvenanceBuiltinMapping) Clock(com.evolveum.midpoint.common.Clock)

Example 2 with DirectoryFileObjectResolver

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;
}
Also used : DirectoryFileObjectResolver(com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver) ObjectResolver(com.evolveum.midpoint.repo.common.ObjectResolver) DirectoryFileObjectResolver(com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDeltaObject(com.evolveum.midpoint.prism.util.ObjectDeltaObject) PrismObject(com.evolveum.midpoint.prism.PrismObject) UniformItemPath(com.evolveum.midpoint.prism.path.UniformItemPath) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl)

Example 3 with DirectoryFileObjectResolver

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);
}
Also used : DirectoryFileObjectResolver(com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver) ObjectResolver(com.evolveum.midpoint.repo.common.ObjectResolver) DirectoryFileObjectResolver(com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver) ArrayList(java.util.ArrayList) FunctionLibrary(com.evolveum.midpoint.model.common.expression.functions.FunctionLibrary) SkipException(org.testng.SkipException) Clock(com.evolveum.midpoint.common.Clock) Protector(com.evolveum.midpoint.prism.crypto.Protector) BeforeClass(org.testng.annotations.BeforeClass)

Example 4 with DirectoryFileObjectResolver

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);
}
Also used : ConstantsManager(com.evolveum.midpoint.model.common.ConstantsManager) DirectoryFileObjectResolver(com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver) ObjectResolver(com.evolveum.midpoint.repo.common.ObjectResolver) DirectoryFileObjectResolver(com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver) Clock(com.evolveum.midpoint.common.Clock) Protector(com.evolveum.midpoint.prism.crypto.Protector) BeforeClass(org.testng.annotations.BeforeClass)

Example 5 with DirectoryFileObjectResolver

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);
}
Also used : Jsr223ScriptEvaluator(com.evolveum.midpoint.model.common.expression.script.jsr223.Jsr223ScriptEvaluator) PrismContext(com.evolveum.midpoint.prism.PrismContext) PrismTestUtil.getPrismContext(com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext) DirectoryFileObjectResolver(com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver) ObjectResolver(com.evolveum.midpoint.repo.common.ObjectResolver) DirectoryFileObjectResolver(com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver) ArrayList(java.util.ArrayList) FunctionLibrary(com.evolveum.midpoint.model.common.expression.functions.FunctionLibrary) Clock(com.evolveum.midpoint.common.Clock) Protector(com.evolveum.midpoint.prism.crypto.Protector) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

DirectoryFileObjectResolver (com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver)5 ObjectResolver (com.evolveum.midpoint.repo.common.ObjectResolver)5 Clock (com.evolveum.midpoint.common.Clock)4 Protector (com.evolveum.midpoint.prism.crypto.Protector)3 BeforeClass (org.testng.annotations.BeforeClass)3 FunctionLibrary (com.evolveum.midpoint.model.common.expression.functions.FunctionLibrary)2 ArrayList (java.util.ArrayList)2 ConstantsManager (com.evolveum.midpoint.model.common.ConstantsManager)1 ModelCommonBeans (com.evolveum.midpoint.model.common.ModelCommonBeans)1 Jsr223ScriptEvaluator (com.evolveum.midpoint.model.common.expression.script.jsr223.Jsr223ScriptEvaluator)1 MetadataMappingEvaluator (com.evolveum.midpoint.model.common.mapping.metadata.MetadataMappingEvaluator)1 BuiltinMetadataMappingsRegistry (com.evolveum.midpoint.model.common.mapping.metadata.builtin.BuiltinMetadataMappingsRegistry)1 ProvenanceBuiltinMapping (com.evolveum.midpoint.model.common.mapping.metadata.builtin.ProvenanceBuiltinMapping)1 PrismContext (com.evolveum.midpoint.prism.PrismContext)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 UniformItemPath (com.evolveum.midpoint.prism.path.UniformItemPath)1 ObjectDeltaObject (com.evolveum.midpoint.prism.util.ObjectDeltaObject)1 PrismTestUtil.getPrismContext (com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext)1 ExpressionFactory (com.evolveum.midpoint.repo.common.expression.ExpressionFactory)1