@SuppressWarnings({ "rawtypes", "unchecked" }) private TestSecurityContext createTestSecurityContext(AnnotatedElement annotated, WithSecurityContext withSecurityContext, TestContext context) { if (withSecurityContext == null) { return null; } withSecurityContext = AnnotationUtils .synthesizeAnnotation(withSecurityContext, annotated); WithSecurityContextFactory factory = createFactory(withSecurityContext, context); Class<? extends Annotation> type = (Class<? extends Annotation>) GenericTypeResolver .resolveTypeArgument(factory.getClass(), WithSecurityContextFactory.class); Annotation annotation = findAnnotation(annotated, type); TestExecutionEvent initialize = withSecurityContext.setupBefore(); try { return new TestSecurityContext(factory.createSecurityContext(annotation), initialize); } catch (RuntimeException e) { throw new IllegalStateException( "Unable to create SecurityContext using " + annotation, e); } }
@SuppressWarnings({ "rawtypes", "unchecked" }) private TestSecurityContext createTestSecurityContext(AnnotatedElement annotated, WithSecurityContext withSecurityContext, TestContext context) { if (withSecurityContext == null) { return null; } withSecurityContext = AnnotationUtils .synthesizeAnnotation(withSecurityContext, annotated); WithSecurityContextFactory factory = createFactory(withSecurityContext, context); Class<? extends Annotation> type = (Class<? extends Annotation>) GenericTypeResolver .resolveTypeArgument(factory.getClass(), WithSecurityContextFactory.class); Annotation annotation = findAnnotation(annotated, type); TestExecutionEvent initialize = withSecurityContext.setupBefore(); try { return new TestSecurityContext(factory.createSecurityContext(annotation), initialize); } catch (RuntimeException e) { throw new IllegalStateException( "Unable to create SecurityContext using " + annotation, e); } }