Search in sources :

Example 1 with ScriptResource

use of org.forgerock.openam.scripting.rest.ScriptResource in project OpenAM by OpenRock.

the class ScriptResourceTest method setUp.

@BeforeMethod
public void setUp() throws ResourceException {
    Logger logger = mock(Logger.class);
    ScriptingService scriptingService = new MockScriptingService();
    ScriptingServiceFactory serviceFactory = mock(ScriptingServiceFactory.class);
    when(serviceFactory.create(any(Subject.class), anyString())).thenReturn(scriptingService);
    ExceptionMappingHandler<ScriptException, ResourceException> errorHandler = new ScriptExceptionMappingHandler();
    scriptResource = new ScriptResource(logger, serviceFactory, errorHandler, new StandardScriptValidator(new StandardScriptEngineManager()));
    context = mock(Context.class);
    given(context.asContext(HttpContext.class)).willReturn(new HttpContext(json(object(field("headers", Collections.emptyMap()), field("parameters", Collections.emptyMap()))), null));
}
Also used : StandardScriptEngineManager(org.forgerock.openam.scripting.StandardScriptEngineManager) HttpContext(org.forgerock.json.resource.http.HttpContext) ScriptContext(org.forgerock.openam.scripting.ScriptConstants.ScriptContext) Context(org.forgerock.services.context.Context) ScriptingService(org.forgerock.openam.scripting.service.ScriptingService) HttpContext(org.forgerock.json.resource.http.HttpContext) StandardScriptValidator(org.forgerock.openam.scripting.StandardScriptValidator) Logger(org.slf4j.Logger) ScriptingServiceFactory(org.forgerock.openam.scripting.service.ScriptingServiceFactory) Subject(javax.security.auth.Subject) ScriptException(org.forgerock.openam.scripting.ScriptException) ResourceException(org.forgerock.json.resource.ResourceException) ScriptExceptionMappingHandler(org.forgerock.openam.scripting.rest.ScriptExceptionMappingHandler) ScriptResource(org.forgerock.openam.scripting.rest.ScriptResource) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

Subject (javax.security.auth.Subject)1 ResourceException (org.forgerock.json.resource.ResourceException)1 HttpContext (org.forgerock.json.resource.http.HttpContext)1 ScriptContext (org.forgerock.openam.scripting.ScriptConstants.ScriptContext)1 ScriptException (org.forgerock.openam.scripting.ScriptException)1 StandardScriptEngineManager (org.forgerock.openam.scripting.StandardScriptEngineManager)1 StandardScriptValidator (org.forgerock.openam.scripting.StandardScriptValidator)1 ScriptExceptionMappingHandler (org.forgerock.openam.scripting.rest.ScriptExceptionMappingHandler)1 ScriptResource (org.forgerock.openam.scripting.rest.ScriptResource)1 ScriptingService (org.forgerock.openam.scripting.service.ScriptingService)1 ScriptingServiceFactory (org.forgerock.openam.scripting.service.ScriptingServiceFactory)1 Context (org.forgerock.services.context.Context)1 Logger (org.slf4j.Logger)1 BeforeMethod (org.testng.annotations.BeforeMethod)1