### Question:
AnnotationFormatter { public String format(Annotation perfAnnotation) { return "@" + retrieveAnnotationNameOf(perfAnnotation) + formatParams(perfAnnotation); } private  AnnotationFormatter(); String format(Annotation perfAnnotation); static final AnnotationFormatter INSTANCE; }### Answer:
@Test public void should_format_annotation() { AnnotationFormatter annotationFormatter = AnnotationFormatter.INSTANCE; PerfAnnotation1 perfAnnotation1 = new PerfAnnotation1() { @Override public Class<? extends Annotation> annotationType() { return PerfAnnotation1.class; } }; String formattedAnnotation = annotationFormatter.format(perfAnnotation1); assertThat(formattedAnnotation).isEqualTo("@PerfAnnotation1"); }
@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(")") ; }