@Test public void should_format_annotation_with_parameters() { AnnotationFormatter annotationFormatter = AnnotationFormatter.INSTANCE; PerfAnnotation2 perfAnnotation2 = new PerfAnnotation2() { @Override public Class<? extends Annotation> annotationType() { return PerfAnnotation2.class; } @Override public int param1() { return 10; } @Override public int param2() { return 20; } }; String formattedAnnotation = annotationFormatter.format(perfAnnotation2); assertThat(formattedAnnotation).contains("@PerfAnnotation2(") .contains("param1=10") .contains("param2=20") .contains(")") ; }
public String format(Annotation perfAnnotation) { return "@" + retrieveAnnotationNameOf(perfAnnotation) + formatParams(perfAnnotation); }
AnnotationFormatter { public String format(Annotation perfAnnotation) { return "@" + retrieveAnnotationNameOf(perfAnnotation) + formatParams(perfAnnotation); } }
AnnotationFormatter { public String format(Annotation perfAnnotation) { return "@" + retrieveAnnotationNameOf(perfAnnotation) + formatParams(perfAnnotation); } private  AnnotationFormatter(); }
AnnotationFormatter { public String format(Annotation perfAnnotation) { return "@" + retrieveAnnotationNameOf(perfAnnotation) + formatParams(perfAnnotation); } private  AnnotationFormatter(); String format(Annotation perfAnnotation); }
AnnotationFormatter { public String format(Annotation perfAnnotation) { return "@" + retrieveAnnotationNameOf(perfAnnotation) + formatParams(perfAnnotation); } private  AnnotationFormatter(); String format(Annotation perfAnnotation); static final AnnotationFormatter INSTANCE; }