/** * Bind all {@code Mock} annotated field of a given test. * * @param test the test whose fields are going to be injected. */ @SuppressWarnings("unchecked") public void bindAllMocks(Object test) { mockCount = 0; for (Field field : test.getClass().getDeclaredFields()) { Annotation mockAnnotation = findMockAnnotation(field); String injectionName = findInjectionName(field); if (mockAnnotation != null) { FieldValueProvider mockProvider = new FieldValueProvider(field, test); if (injectionName != null) { bind(field.getType()).withName(injectionName).toProviderInstance(mockProvider); } else { bind(field.getType()).toProviderInstance(mockProvider); } mockCount++; } } }
/** * Bind all {@code Mock} annotated field of a given test. * * @param test the test whose fields are going to be injected. */ @SuppressWarnings("unchecked") public void bindAllMocks(Object test) { mockCount = 0; for (Field field : test.getClass().getDeclaredFields()) { Annotation mockAnnotation = findMockAnnotation(field); String injectionName = findInjectionName(field); if (mockAnnotation != null) { FieldValueProvider mockProvider = new FieldValueProvider(field, test); if (injectionName != null) { bind(field.getType()).withName(injectionName).toProviderInstance(mockProvider); } else { bind(field.getType()).toProviderInstance(mockProvider); } mockCount++; } } }
/** * Bind all {@code Mock} annotated field of a given test. * * @param test the test whose fields are going to be injected. */ @SuppressWarnings("unchecked") public void bindAllMocks(Object test) { mockCount = 0; for (Field field : test.getClass().getDeclaredFields()) { Annotation mockAnnotation = findMockAnnotation(field); String injectionName = findInjectionName(field); if (mockAnnotation != null) { FieldValueProvider mockProvider = new FieldValueProvider(field, test); if (injectionName != null) { bind(field.getType()).withName(injectionName).toProvider(mockProvider); } else { bind(field.getType()).toProvider(mockProvider); } mockCount++; } } }