/** * Enrich the method arguments of a method call.<br/> * The Object[] index will match the method parameterType[] index. * * @return the argument values */ private Object[] enrichArguments(Method method, Collection<TestEnricher> enrichers) { Object[] values = new Object[method.getParameterTypes().length]; if (method.getParameterTypes().length == 0) { return values; } for (TestEnricher enricher : enrichers) { mergeValues(values, enricher.resolve(method)); } return values; }
/** * Enrich the method arguments of a method call.<br/> * The Object[] index will match the method parameterType[] index. * * @return the argument values */ private Object[] enrichArguments(Method method, Collection<TestEnricher> enrichers) { Object[] values = new Object[method.getParameterTypes().length]; if (method.getParameterTypes().length == 0) { return values; } for (TestEnricher enricher : enrichers) { mergeValues(values, enricher.resolve(method)); } return values; }
/** * Enrich the method arguments of a method call.<br/> * The Object[] index will match the method parameterType[] index. * * @return the argument values */ private Object[] enrichArguments(Method method, Collection<TestEnricher> enrichers) { Object[] values = new Object[method.getParameterTypes().length]; if (method.getParameterTypes().length == 0) { return values; } for (TestEnricher enricher : enrichers) { mergeValues(values, enricher.resolve(method)); } return values; }
/** * Enrich the method arguments of a method call.<br/> * The Object[] index will match the method parameterType[] index. * * @return the argument values */ private Object[] enrichArguments(Method method, Collection<TestEnricher> enrichers) { Object[] values = new Object[method.getParameterTypes().length]; if (method.getParameterTypes().length == 0) { return values; } for (TestEnricher enricher : enrichers) { mergeValues(values, enricher.resolve(method)); } return values; }
/** * Enrich the method arguments of a method call.<br/> * The Object[] index will match the method parameterType[] index. * * @return the argument values */ private Object[] enrichArguments(Method method, Collection<TestEnricher> enrichers) { Object[] values = new Object[method.getParameterTypes().length]; if (method.getParameterTypes().length == 0) { return values; } for (TestEnricher enricher : enrichers) { mergeValues(values, enricher.resolve(method)); } return values; }
/** * Enrich the method arguments of a method call.<br/> * The Object[] index will match the method parameterType[] index. * * @param method method to enrich arguments * @return the argument values */ private Object[] enrichArguments(Method method, Collection<TestEnricher> enrichers) { Object[] values = new Object[method.getParameterTypes().length]; if (method.getParameterTypes().length == 0) { return values; } for (TestEnricher enricher : enrichers) { mergeValues(values, enricher.resolve(method)); } return values; }
@Test public void testNoArgConstructorResolveMethod() throws NoSuchMethodException { thrown.expect(PageObjectInitializationException.class); getGrapheneEnricher().resolve(NoArgConstructorMethodParamTest.class.getMethod("methodToResolve", NoArgConstructorMethodParamTest.WrongPageObject.class)); }
@Test public void testAbstractTypeResolveMethod() throws NoSuchMethodException { thrown.expect(PageObjectInitializationException.class); getGrapheneEnricher() .resolve(AbstractTypeMethodParamTest.class.getMethod("methodToResolve", AbstractPageType.class)); }
@Test public void shouldBeAbleToInjectBaseContextOnMethod() throws Exception { Method resourceMethod = ObjectClass.class.getMethod("test", Object.class); Mockito.when( resourceProvider.lookup( (ArquillianResource) Mockito.any(), Mockito.argThat(new MethodInjectionAnnotationMatcher()))) .thenReturn(resource); TestEnricher enricher = new ArquillianResourceTestEnricher(); injector.get().inject(enricher); Object[] result = enricher.resolve(resourceMethod); Assert.assertEquals(resource, result[0]); }
@Test public void shouldBeAbleToInjectBaseContextOnMethodWithQualifier() throws Exception { Method resourceMethod = ObjectClass.class.getMethod("testWithQualifier", Object.class); Mockito.when( resourceProvider.lookup( (ArquillianResource) Mockito.any(), Mockito.argThat( new CustomAnnotationMatcher( resourceMethod.getParameterAnnotations()[0][1], ResourceProvider.MethodInjection.class)))) .thenReturn(resource); TestEnricher enricher = new ArquillianResourceTestEnricher(); injector.get().inject(enricher); Object[] result = enricher.resolve(resourceMethod); Assert.assertEquals(resource, result[0]); }
@Test public void shouldBeAbleToInjectBaseContextOnMethodWithQualifier() throws Exception { Method resourceMethod = ObjectClass.class.getMethod("testWithQualifier", Object.class); Mockito.when( resourceProvider.lookup( (ArquillianResource) Mockito.any(), Mockito.argThat( new CustomAnnotationMatcher( resourceMethod.getParameterAnnotations()[0][1], ResourceProvider.MethodInjection.class)))) .thenReturn(resource); TestEnricher enricher = new ArquillianResourceTestEnricher(); injector.get().inject(enricher); Object[] result = enricher.resolve(resourceMethod); Assert.assertEquals(resource, result[0]); }
@Test public void shouldBeAbleToInjectBaseContextOnMethod() throws Exception { Method resourceMethod = ObjectClass.class.getMethod("test", Object.class); Mockito.when( resourceProvider.lookup( (ArquillianResource) Mockito.any(), Mockito.argThat(new MethodInjectionAnnotationMatcher()))) .thenReturn(resource); TestEnricher enricher = new ArquillianResourceTestEnricher(); injector.get().inject(enricher); Object[] result = enricher.resolve(resourceMethod); Assert.assertEquals(resource, result[0]); }
@Test public void shouldThrowExceptionWhenUsedMethodScopeInjectionOnArquillianResource() throws Exception { Method resourceMethod = ObjectClass3.class.getMethod("testWithInjectionQualifier", Object.class); Mockito.when( resourceProvider.lookup( (ArquillianResource) Mockito.any(), Mockito.argThat( new CustomAnnotationMatcher( resourceMethod.getParameterAnnotations()[0][1], ResourceProvider.MethodInjection.class)))) .thenReturn(resource); TestEnricher enricher = new ArquillianResourceTestEnricher(); injector.get().inject(enricher); Throwable cause = null; try { enricher.resolve(resourceMethod); } catch (Exception ex) { cause = ex; } Assert.assertEquals(IllegalStateException.class, cause.getClass()); }
@Test public void shouldThrowExceptionWhenUsedMethodScopeInjectionOnArquillianResource() throws Exception { Method resourceMethod = ObjectClass3.class.getMethod("testWithInjectionQualifier", Object.class); Mockito.when( resourceProvider.lookup( (ArquillianResource) Mockito.any(), Mockito.argThat( new CustomAnnotationMatcher( resourceMethod.getParameterAnnotations()[0][1], ResourceProvider.MethodInjection.class)))) .thenReturn(resource); TestEnricher enricher = new ArquillianResourceTestEnricher(); injector.get().inject(enricher); Throwable cause = null; try { enricher.resolve(resourceMethod); } catch (Exception ex) { cause = ex; } Assert.assertEquals(IllegalStateException.class, cause.getClass()); }