@Test void produceAvroDataFormatFromNonStaticFieldShouldThrow() { IllegalArgumentException iaex = assertThrows(IllegalArgumentException.class, () -> { instance.produceAvroDataFormat(mockInjectionPoint); }); assertNotNull(iaex.getMessage()); }
@Produces AvroDataFormat produceAvroDataFormat(InjectionPoint injectionPoint) { Member member = injectionPoint.getMember(); if (member instanceof Field) { Field field = (Field) member; if (!Modifier.isStatic(member.getModifiers()) && field.getAnnotation(BuildTimeAvroDataFormat.class) != null) { String injectedFieldId = member.getDeclaringClass().getName() + "." + member.getName(); Schema schema = schemaRegistry.get(injectedFieldId); return new AvroDataFormat(schema); } } String message = "AvroDataFormat beans can only be injected into non-static field annotated with @"; throw new IllegalArgumentException(message + BuildTimeAvroDataFormat.class.getName()); }
AvroDataFormatProducer { @Produces AvroDataFormat produceAvroDataFormat(InjectionPoint injectionPoint) { Member member = injectionPoint.getMember(); if (member instanceof Field) { Field field = (Field) member; if (!Modifier.isStatic(member.getModifiers()) && field.getAnnotation(BuildTimeAvroDataFormat.class) != null) { String injectedFieldId = member.getDeclaringClass().getName() + "." + member.getName(); Schema schema = schemaRegistry.get(injectedFieldId); return new AvroDataFormat(schema); } } String message = "AvroDataFormat beans can only be injected into non-static field annotated with @"; throw new IllegalArgumentException(message + BuildTimeAvroDataFormat.class.getName()); } }
AvroDataFormatProducer { @Produces AvroDataFormat produceAvroDataFormat(InjectionPoint injectionPoint) { Member member = injectionPoint.getMember(); if (member instanceof Field) { Field field = (Field) member; if (!Modifier.isStatic(member.getModifiers()) && field.getAnnotation(BuildTimeAvroDataFormat.class) != null) { String injectedFieldId = member.getDeclaringClass().getName() + "." + member.getName(); Schema schema = schemaRegistry.get(injectedFieldId); return new AvroDataFormat(schema); } } String message = "AvroDataFormat beans can only be injected into non-static field annotated with @"; throw new IllegalArgumentException(message + BuildTimeAvroDataFormat.class.getName()); }  }
AvroDataFormatProducer { @Produces AvroDataFormat produceAvroDataFormat(InjectionPoint injectionPoint) { Member member = injectionPoint.getMember(); if (member instanceof Field) { Field field = (Field) member; if (!Modifier.isStatic(member.getModifiers()) && field.getAnnotation(BuildTimeAvroDataFormat.class) != null) { String injectedFieldId = member.getDeclaringClass().getName() + "." + member.getName(); Schema schema = schemaRegistry.get(injectedFieldId); return new AvroDataFormat(schema); } } String message = "AvroDataFormat beans can only be injected into non-static field annotated with @"; throw new IllegalArgumentException(message + BuildTimeAvroDataFormat.class.getName()); }  void registerAvroSchema(String injectedFieldId, Schema schema); }
AvroDataFormatProducer { @Produces AvroDataFormat produceAvroDataFormat(InjectionPoint injectionPoint) { Member member = injectionPoint.getMember(); if (member instanceof Field) { Field field = (Field) member; if (!Modifier.isStatic(member.getModifiers()) && field.getAnnotation(BuildTimeAvroDataFormat.class) != null) { String injectedFieldId = member.getDeclaringClass().getName() + "." + member.getName(); Schema schema = schemaRegistry.get(injectedFieldId); return new AvroDataFormat(schema); } } String message = "AvroDataFormat beans can only be injected into non-static field annotated with @"; throw new IllegalArgumentException(message + BuildTimeAvroDataFormat.class.getName()); }  void registerAvroSchema(String injectedFieldId, Schema schema);  }