@Test public void testDetermineDelay() throws Exception { BaseActionLoader loader = BeanLoader.loadBaseActionLoader(); when(loader.getSahiProxyProperties().getRequestDelayMs()).thenReturn(500); loader.getActionProperties().setTypeDelay(0.05); JoinPoint joinPoint = mock(JoinPoint.class); Signature signature = mock(Signature.class); when(joinPoint.getSignature()).thenReturn(signature); when(signature.getName()).thenReturn("pasteSomething"); assertEquals(testling.determineDelay(joinPoint, loader).intValue(), 500); when(signature.getName()).thenReturn("typeMasked"); when(joinPoint.getArgs()).thenReturn(new String[]{"1", "MOD"}); assertEquals(testling.determineDelay(joinPoint, loader).intValue(), 550); when(joinPoint.getArgs()).thenReturn(new String[]{"12characters", "MOD"}); assertEquals(testling.determineDelay(joinPoint, loader).intValue(), 12 * 550); }
protected Integer determineDelay(JoinPoint joinPoint, BaseActionLoader loader) { Integer deleay = loader.getSahiProxyProperties().getRequestDelayMs(); if (joinPoint.getSignature().getName().startsWith("type")) { Object[] args = joinPoint.getArgs(); if (args != null && args.length > 0) { Object text = args[0]; if (text instanceof String) { int length = ((String) text).length(); int typeDelayMs = loader.getActionProperties().getTypeDelayMs(); return length * (typeDelayMs + deleay); } } } return deleay; }
ModifySahiTimerAspect extends BaseSakuliAspect { protected Integer determineDelay(JoinPoint joinPoint, BaseActionLoader loader) { Integer deleay = loader.getSahiProxyProperties().getRequestDelayMs(); if (joinPoint.getSignature().getName().startsWith("type")) { Object[] args = joinPoint.getArgs(); if (args != null && args.length > 0) { Object text = args[0]; if (text instanceof String) { int length = ((String) text).length(); int typeDelayMs = loader.getActionProperties().getTypeDelayMs(); return length * (typeDelayMs + deleay); } } } return deleay; } }
ModifySahiTimerAspect extends BaseSakuliAspect { protected Integer determineDelay(JoinPoint joinPoint, BaseActionLoader loader) { Integer deleay = loader.getSahiProxyProperties().getRequestDelayMs(); if (joinPoint.getSignature().getName().startsWith("type")) { Object[] args = joinPoint.getArgs(); if (args != null && args.length > 0) { Object text = args[0]; if (text instanceof String) { int length = ((String) text).length(); int typeDelayMs = loader.getActionProperties().getTypeDelayMs(); return length * (typeDelayMs + deleay); } } } return deleay; }  }
ModifySahiTimerAspect extends BaseSakuliAspect { protected Integer determineDelay(JoinPoint joinPoint, BaseActionLoader loader) { Integer deleay = loader.getSahiProxyProperties().getRequestDelayMs(); if (joinPoint.getSignature().getName().startsWith("type")) { Object[] args = joinPoint.getArgs(); if (args != null && args.length > 0) { Object text = args[0]; if (text instanceof String) { int length = ((String) text).length(); int typeDelayMs = loader.getActionProperties().getTypeDelayMs(); return length * (typeDelayMs + deleay); } } } return deleay; }  @Before("execution(* org.sakuli.actions.environment.*.*(..)) &&" + "@annotation(modifySahiTimer)") void doEnvironmentBefore(JoinPoint joinPoint, ModifySahiTimer modifySahiTimer); @Before("execution(* org.sakuli.actions.screenbased.*.*(..)) &&" + "@annotation(modifySahiTimer)") void doScreenbasedBefore(JoinPoint joinPoint, ModifySahiTimer modifySahiTimer); @After("execution(* org.sakuli.actions.environment.*.*(..)) &&" + "@annotation(modifySahiTimer)") void doEnvironmentAfter(JoinPoint joinPoint, ModifySahiTimer modifySahiTimer); @After("execution(* org.sakuli.actions.screenbased.*.*(..)) &&" + "@annotation(modifySahiTimer)") void doScreenbasedAfter(JoinPoint joinPoint, ModifySahiTimer modifySahiTimer); }
ModifySahiTimerAspect extends BaseSakuliAspect { protected Integer determineDelay(JoinPoint joinPoint, BaseActionLoader loader) { Integer deleay = loader.getSahiProxyProperties().getRequestDelayMs(); if (joinPoint.getSignature().getName().startsWith("type")) { Object[] args = joinPoint.getArgs(); if (args != null && args.length > 0) { Object text = args[0]; if (text instanceof String) { int length = ((String) text).length(); int typeDelayMs = loader.getActionProperties().getTypeDelayMs(); return length * (typeDelayMs + deleay); } } } return deleay; }  @Before("execution(* org.sakuli.actions.environment.*.*(..)) &&" + "@annotation(modifySahiTimer)") void doEnvironmentBefore(JoinPoint joinPoint, ModifySahiTimer modifySahiTimer); @Before("execution(* org.sakuli.actions.screenbased.*.*(..)) &&" + "@annotation(modifySahiTimer)") void doScreenbasedBefore(JoinPoint joinPoint, ModifySahiTimer modifySahiTimer); @After("execution(* org.sakuli.actions.environment.*.*(..)) &&" + "@annotation(modifySahiTimer)") void doEnvironmentAfter(JoinPoint joinPoint, ModifySahiTimer modifySahiTimer); @After("execution(* org.sakuli.actions.screenbased.*.*(..)) &&" + "@annotation(modifySahiTimer)") void doScreenbasedAfter(JoinPoint joinPoint, ModifySahiTimer modifySahiTimer);  }