Search in sources :

Example 1 with ScriptContext

use of org.forgerock.openam.scripting.ScriptConstants.ScriptContext in project OpenAM by OpenRock.

the class ScriptEngineConfiguratorTest method shouldNotUpdateEngineWhenEngineConfigDidNotChange.

@Test
public void shouldNotUpdateEngineWhenEngineConfigDidNotChange() {
    // given
    ScriptContext context = POLICY_CONDITION;
    String serviceComponent = "/" + context.name() + "/SomeOtherConfig";
    doCallRealMethod().when(mockEngineConfigurator).globalConfigChanged(anyString(), anyString(), anyString(), anyString(), anyInt());
    // when
    mockEngineConfigurator.globalConfigChanged(ScriptConstants.SERVICE_NAME, "", "", serviceComponent, 0);
    // then
    verify(mockEngineConfigurator, times(0)).updateConfig(any(ScriptContext.class));
}
Also used : ScriptContext(org.forgerock.openam.scripting.ScriptConstants.ScriptContext) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Example 2 with ScriptContext

use of org.forgerock.openam.scripting.ScriptConstants.ScriptContext in project OpenAM by OpenRock.

the class ScriptEngineConfiguratorTest method shouldUpdateEngineWithAuthorisationEntitlementConditionConfig.

@Test
public void shouldUpdateEngineWithAuthorisationEntitlementConditionConfig() {
    // given
    ScriptContext context = POLICY_CONDITION;
    String serviceComponent = "/" + context.name() + "/" + ENGINE_CONFIGURATION;
    doCallRealMethod().when(mockEngineConfigurator).globalConfigChanged(anyString(), anyString(), anyString(), anyString(), anyInt());
    // when
    mockEngineConfigurator.globalConfigChanged(ScriptConstants.SERVICE_NAME, "", "", serviceComponent, 0);
    // then
    ArgumentCaptor<ScriptContext> contextCaptor = ArgumentCaptor.forClass(ScriptContext.class);
    verify(mockEngineConfigurator, times(1)).updateConfig(contextCaptor.capture());
    assertThat(contextCaptor.getValue()).isEqualTo(context);
}
Also used : ScriptContext(org.forgerock.openam.scripting.ScriptConstants.ScriptContext) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Example 3 with ScriptContext

use of org.forgerock.openam.scripting.ScriptConstants.ScriptContext in project OpenAM by OpenRock.

the class ScriptEngineConfiguratorTest method shouldUpdateEngineWithAuthenticationServerSideConfig.

@Test
public void shouldUpdateEngineWithAuthenticationServerSideConfig() {
    // given
    ScriptContext context = AUTHENTICATION_SERVER_SIDE;
    String serviceComponent = "/" + context.name() + "/" + ENGINE_CONFIGURATION;
    doCallRealMethod().when(mockEngineConfigurator).globalConfigChanged(anyString(), anyString(), anyString(), anyString(), anyInt());
    // when
    mockEngineConfigurator.globalConfigChanged(ScriptConstants.SERVICE_NAME, "", "", serviceComponent, 0);
    // then
    ArgumentCaptor<ScriptContext> resourceCaptor = ArgumentCaptor.forClass(ScriptContext.class);
    verify(mockEngineConfigurator, times(1)).updateConfig(resourceCaptor.capture());
    assertThat(resourceCaptor.getValue()).isEqualTo(context);
}
Also used : ScriptContext(org.forgerock.openam.scripting.ScriptConstants.ScriptContext) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Aggregations

ScriptContext (org.forgerock.openam.scripting.ScriptConstants.ScriptContext)3 Matchers.anyString (org.mockito.Matchers.anyString)3 Test (org.testng.annotations.Test)3