EffectorUtils { public static Object[] prepareArgsForEffector(Effector<?> eff, Object[] args) { return prepareArgsForEffectorFromArray(eff, args); }  static Object[] prepareArgsForEffector(Effector<?> eff, Object[] args); static Object[] prepareArgsForEffector(Effector<?> eff, Map<?,?> args); @Deprecated static Object[] prepareArgsForEffector(Effector<?> eff, Object args); static Map prepareArgsForEffectorAsMapFromArray(Effector<?> eff, Object args[]); static Object[] oldPrepareArgsForEffector(Effector<?> eff, Object args); static T invokeMethodEffector(Entity entity, Effector<T> eff, Map<String,?> args); static RuntimeException handleEffectorException(Entity entity, Effector<?> effector, Throwable throwable); static Task<T> invokeEffectorAsync(Entity entity, Effector<T> eff, Map<String,?> parameters); static Maybe<Effector<?>> findEffector(Collection<? extends Effector<?>> effectors, String effectorName); static Maybe<Effector<?>> findEffectorDeclared(Entity entity, String effectorName); static Map<Object,Object> getTaskFlagsForEffectorInvocation(Entity entity, Effector<?> effector, ConfigBag parameters);  }
@Test public void testPrepareArgsFromMap() throws Exception { assertEquals(EffectorUtils.prepareArgsForEffector(effector, argsMap), expectedArgs); assertEquals(EffectorUtils.prepareArgsForEffector(effector, argsMapRequiringCoercion), expectedArgs); }
@Test public void testPrepareArgsFromArray() throws Exception { assertEquals(EffectorUtils.prepareArgsForEffector(effector, argsArray), expectedArgs); }
@Test(expectedExceptions=IllegalArgumentException.class, expectedExceptionsMessageRegExp=".*Invalid arguments.*missing argument.*stringParam.*") public void testPrepareArgsFromMapThrowsIfMissing() throws Exception { MutableMap<Object, Object> mapMissingArg = MutableMap.builder() .putAll(argsMap) .remove("stringParam") .build(); EffectorUtils.prepareArgsForEffector(effector, mapMissingArg); }
@Test(expectedExceptions=IllegalArgumentException.class, expectedExceptionsMessageRegExp=".*Invalid arguments.*count mismatch.*") public void testPrepareArgsFromArrayThrowsIfMissing() throws Exception { Object[] arrayMissingArg = Arrays.asList(argsArray).subList(0, argsArray.length - 1).toArray(); EffectorUtils.prepareArgsForEffector(effector, arrayMissingArg); }