Search in sources :

Example 6 with ObjectResolver

use of com.evolveum.midpoint.repo.common.ObjectResolver 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 7 with ObjectResolver

use of com.evolveum.midpoint.repo.common.ObjectResolver 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 8 with ObjectResolver

use of com.evolveum.midpoint.repo.common.ObjectResolver 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

ObjectResolver (com.evolveum.midpoint.repo.common.ObjectResolver)8 DirectoryFileObjectResolver (com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver)5 Clock (com.evolveum.midpoint.common.Clock)4 ArrayList (java.util.ArrayList)4 Protector (com.evolveum.midpoint.prism.crypto.Protector)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 BeforeClass (org.testng.annotations.BeforeClass)3 ModelProjectionContext (com.evolveum.midpoint.model.api.context.ModelProjectionContext)2 FunctionLibrary (com.evolveum.midpoint.model.common.expression.functions.FunctionLibrary)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2 Task (com.evolveum.midpoint.task.api.Task)2 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 ApprovalProcessExecutionInformationDto (com.evolveum.midpoint.web.page.admin.workflow.dto.ApprovalProcessExecutionInformationDto)2 EvaluatedTriggerGroupDto (com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerGroupDto)2 ApprovalSchemaExecutionInformationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalSchemaExecutionInformationType)2 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)2 PolicyRuleEnforcerPreviewOutputType (com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyRuleEnforcerPreviewOutputType)2 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)2