### Question:
JavassistUtils { public static List<CtField> getAllInjectedFieldsForAnnotation(CtClass clazz, Class<? extends Annotation> annotationClazz) { List<CtField> result = new ArrayList<CtField>(); CtField[] allFields = clazz.getDeclaredFields(); for (CtField field : allFields) { if (field.hasAnnotation(annotationClazz)) { result.add(field); } } return result; } private  JavassistUtils(); static boolean isArrayOf(CtField field, CtClass typeOfArrayElements); static boolean isArrayOf(CtField field, ClassPool classPool, Class<?> superClass); static boolean isBooleanArray(CtField field); static boolean isByteArray(CtField field); static boolean isCharArray(CtField field); static boolean isDoubleArray(CtField field); static boolean isFloatArray(CtField field); static boolean isIntArray(CtField field); static boolean isLongArray(CtField field); static boolean isShortArray(CtField field); static boolean isCharSequenceArray(CtField field, ClassPool classPool); static boolean isStringArray(CtField field, ClassPool classPool); static boolean isArrayList(CtField field, ClassPool classPool); static boolean isParcelableArray(CtField field, ClassPool classPool); static boolean isSerializableArray(CtField field, ClassPool classPool); static boolean isActivity(CtClass clazz); static boolean isService(CtClass clazz); static boolean isContext(CtClass clazz); static boolean isBroadCastReceiver(CtClass clazz); static boolean isContentProvider(CtClass clazz); static boolean isApplication(CtClass clazz); static boolean isFragment(CtClass clazz); static boolean isSupportFragment(CtClass clazz); static boolean isView(CtClass clazz); static boolean isSubType(ClassPool classPool, CtClass clazz, Class<?> superClass); static boolean isSubClass(ClassPool classPool, CtClass clazz, Class<?> superClass); static boolean isSubClass(ClassPool classPool, CtClass clazz, String superClassName); static List<CtField> getAllInjectedFieldsForAnnotation(CtClass clazz,
      Class<? extends Annotation> annotationClazz); static List<CtConstructor> extractValidConstructors(final CtClass classToTransform,
      CtClassFilter filter); static int findValidParamIndex(CtClass[] parameterTypes, CtClassFilter filter);  }### Answer:
@Test public void testGetAllInjectedFieldsForAnnotation_WhenHasAnnotatedFields() throws Exception { Class<TestClassWithAnnotatedFields> aClass = TestClassWithAnnotatedFields.class; List<CtField> allInjectedFieldsForAnnotation1 = JavassistUtils.getAllInjectedFieldsForAnnotation( ClassPool.getDefault().get(aClass.getName()), Annotation1.class); assertThat(allInjectedFieldsForAnnotation1.size(), is(1)); assertThat(allInjectedFieldsForAnnotation1.get(0).getName(), is("a")); assertThat(allInjectedFieldsForAnnotation1.get(0).getType(), is(CtClass.intType)); }
@Test public void testGetAllInjectedFieldsForAnnotation_WhenHasNoAnnotatedFields() throws Exception { Class<TestClassWithAnnotatedFields> aClass = TestClassWithAnnotatedFields.class; List<CtField> allInjectedFieldsForAnnotation2 = JavassistUtils.getAllInjectedFieldsForAnnotation( ClassPool.getDefault().get(aClass.getName()), Annotation2.class); assertThat(allInjectedFieldsForAnnotation2.size(), is(0)); }