/** * 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++; } } }
/** * Automatically binds all annotated mocks of a module. * * @param test the test whose {@code Mock} annotated fields will be mocked. */ public ToothPickTestModule(Object test) { bindAllMocks(test); }
public ToothPickRule(Object test, Object scopeName) { this.testModule = new ToothPickTestModule(test); if (scopeName != null) { setScopeName(scopeName); } }
/** * 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++; } } }
/** * Automatically binds all annotated mocks of a module. * * @param test the test whose {@code Mock} annotated fields will be mocked. */ public ToothPickTestModule(Object test) { bindAllMocks(test); }
public ToothPickRule(Object test, Object scopeName) { this.testModule = new ToothPickTestModule(test); if (scopeName != null) { setScopeName(scopeName); } }
/** * 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++; } } }
/** * Automatically binds all annotated mocks of a module. * * @param test the test whose {@code Mock} annotated fields will be mocked. */ public ToothPickTestModule(Object test) { bindAllMocks(test); }