@Test(timeout = 2000, expected = FieldNotFoundException.class) public void givenTypeAndAnnotationAndNameWhenNameAndAnnotationMatchButTypeNotFoundThenFieldNotFoundExceptionIsThrown() throws Exception { FakeRepositoryWithAnnotation repository = new FakeRepositoryWithAnnotation(); new Asynch(repository).perform(); byte one = (byte) 1; await().until(fieldIn(repository).ofType(byte.class).andAnnotatedWith(ExampleAnnotation.class).andWithName("value"), equalTo(one)); assertEquals(1, repository.getValue()); }
/** * Find a field based on the type and an annotation. E.g. * <p> </p> * <code> * await().until(fieldIn(object).ofType(int.class).andAnnotatedWith(MyAnnotation.class), equalTo(2)); * </code> * * @param annotationType The name of the field * @return The supplier */ public NameFieldSupplier<T> andAnnotatedWith(Class<? extends Annotation> annotationType) { assertNotNullParameter(annotationType, "annotationType"); expectedAnnotation = annotationType; return new NameFieldSupplier<T>(); }
/** * Find a field based on the type and an annotation. E.g. * <p> </p> * <code> * await().until(fieldIn(object).ofType(int.class).andAnnotatedWith(MyAnnotation.class), equalTo(2)); * </code> * * @param annotationType The name of the field * @return The supplier */ public NameFieldSupplier<T> andAnnotatedWith(Class<? extends Annotation> annotationType) { assertNotNullParameter(annotationType, "annotationType"); expectedAnnotation = annotationType; return new NameFieldSupplier<T>(); }
@Test(timeout = 2000) public void typeAndAnnotationAndName() throws Exception { FakeRepositoryWithAnnotation repository = new FakeRepositoryWithAnnotation(); new Asynch(repository).perform(); await().until( fieldIn(repository).ofType(int.class).andAnnotatedWith(ExampleAnnotation.class).andWithName("value"), equalTo(1)); assertEquals(1, repository.getValue()); }
@Test(timeout = 2000, expected = FieldNotFoundException.class) public void givenTypeAndAnnotationAndNameWhenNameAndTypeMatchButAnnotationNotFoundThenFieldNotFoundExceptionIsThrown() throws Exception { FakeRepositoryWithAnnotation repository = new FakeRepositoryWithAnnotation(); new Asynch(repository).perform(); await().until( fieldIn(repository).ofType(int.class).andAnnotatedWith(ExampleAnnotation2.class).andWithName("value"), equalTo(1)); assertEquals(1, repository.getValue()); }