use of javax.enterprise.inject.Vetoed in project tomee by apache.
the class TomEEELInvocationHandlerTest method canCreateInvocationHandler.
@Test
public void canCreateInvocationHandler() {
final DatabaseIdentityStoreDefinition annotation = Color.class.getAnnotation(DatabaseIdentityStoreDefinition.class);
final ELProcessor elProcessor = new ELProcessor();
final ELResolver elResolver = bm().getELResolver();
elProcessor.getELManager().addELResolver(elResolver);
// small trick because of the @Vetoed bellow - OWB won't pick it up
// so we will register one ourselves into the processor so it is resolved
elProcessor.defineBean("color", new Color());
final DatabaseIdentityStoreDefinition proxiedAnnotation = TomEEELInvocationHandler.of(DatabaseIdentityStoreDefinition.class, annotation, elProcessor);
Assert.assertEquals("select password from caller where name = ?", proxiedAnnotation.callerQuery());
Assert.assertEquals(90, proxiedAnnotation.priority());
Assert.assertEquals("90", proxiedAnnotation.priorityExpression());
Assert.assertArrayEquals(new IdentityStore.ValidationType[] { IdentityStore.ValidationType.VALIDATE }, proxiedAnnotation.useFor());
Assert.assertEquals("select group_name from caller_groups where caller_name = ?", proxiedAnnotation.groupsQuery());
final String[] hashAlgorithmParameters = proxiedAnnotation.hashAlgorithmParameters();
Assert.assertArrayEquals(new String[] { "Pbkdf2PasswordHash.Iterations=3072", "${color.dyna}" }, hashAlgorithmParameters);
final Set<String> evaluatedHashParameters = stream(hashAlgorithmParameters).flatMap(s -> toStream(eval(elProcessor, s, Object.class))).collect(toSet());
System.out.println(evaluatedHashParameters);
final Map<String, String> parametersMap = evaluatedHashParameters.stream().collect(toMap(s -> (String) s.substring(0, s.indexOf('=')), s -> (String) eval(elProcessor, s.substring(s.indexOf('=') + 1), String.class)));
System.out.println(parametersMap);
}
Aggregations