@Test public void parseEmptyAnnotation() { Reporter reporter = new SystemReporter(); ComponentWorkbench workbench = mock(ComponentWorkbench.class); when(workbench.getType()).thenReturn(Type.getType(MyComponent.class)); when(workbench.getClassNode()).thenReturn(new ClassNode()); when(workbench.getElements()).thenReturn(elements); FieldNode node = new FieldNode(Opcodes.ACC_PROTECTED, "template", Type.getDescriptor(Template.class), null, null); WisdomViewVisitor visitor = new WisdomViewVisitor(workbench, reporter, node); visitor.visitEnd(); assertThat(elements).hasSize(0); }
@Override public void visitEnd() { if (name == null || name.length() == 0) { reporter.error("The 'name' attribute of @View from " + workbench.getType().getClassName() + " must be " + "set"); return; } if (! Type.getDescriptor(Template.class).equals(node.desc)) { reporter.error("The type of the field " + field + " from " + workbench.getType().getClassName() + " must " + "be " + Template.class.getName() + " because the field is annotated with @View"); } Element requires = new Element("requires", ""); requires.addAttribute(new Attribute("field", field)); requires.addAttribute(new Attribute("filter", getFilter(name))); workbench.getElements().put(requires, null); }
WisdomViewVisitor extends AnnotationVisitor { @Override public void visitEnd() { if (name == null || name.length() == 0) { reporter.error("The 'name' attribute of @View from " + workbench.getType().getClassName() + " must be " + "set"); return; } if (! Type.getDescriptor(Template.class).equals(node.desc)) { reporter.error("The type of the field " + field + " from " + workbench.getType().getClassName() + " must " + "be " + Template.class.getName() + " because the field is annotated with @View"); } Element requires = new Element("requires", ""); requires.addAttribute(new Attribute("field", field)); requires.addAttribute(new Attribute("filter", getFilter(name))); workbench.getElements().put(requires, null); } }
WisdomViewVisitor extends AnnotationVisitor { @Override public void visitEnd() { if (name == null || name.length() == 0) { reporter.error("The 'name' attribute of @View from " + workbench.getType().getClassName() + " must be " + "set"); return; } if (! Type.getDescriptor(Template.class).equals(node.desc)) { reporter.error("The type of the field " + field + " from " + workbench.getType().getClassName() + " must " + "be " + Template.class.getName() + " because the field is annotated with @View"); } Element requires = new Element("requires", ""); requires.addAttribute(new Attribute("field", field)); requires.addAttribute(new Attribute("filter", getFilter(name))); workbench.getElements().put(requires, null); } WisdomViewVisitor(ComponentWorkbench workbench, Reporter reporter, FieldNode node); }
WisdomViewVisitor extends AnnotationVisitor { @Override public void visitEnd() { if (name == null || name.length() == 0) { reporter.error("The 'name' attribute of @View from " + workbench.getType().getClassName() + " must be " + "set"); return; } if (! Type.getDescriptor(Template.class).equals(node.desc)) { reporter.error("The type of the field " + field + " from " + workbench.getType().getClassName() + " must " + "be " + Template.class.getName() + " because the field is annotated with @View"); } Element requires = new Element("requires", ""); requires.addAttribute(new Attribute("field", field)); requires.addAttribute(new Attribute("filter", getFilter(name))); workbench.getElements().put(requires, null); } WisdomViewVisitor(ComponentWorkbench workbench, Reporter reporter, FieldNode node); @Override void visit(String s, Object o); @Override void visitEnd(); }
WisdomViewVisitor extends AnnotationVisitor { @Override public void visitEnd() { if (name == null || name.length() == 0) { reporter.error("The 'name' attribute of @View from " + workbench.getType().getClassName() + " must be " + "set"); return; } if (! Type.getDescriptor(Template.class).equals(node.desc)) { reporter.error("The type of the field " + field + " from " + workbench.getType().getClassName() + " must " + "be " + Template.class.getName() + " because the field is annotated with @View"); } Element requires = new Element("requires", ""); requires.addAttribute(new Attribute("field", field)); requires.addAttribute(new Attribute("filter", getFilter(name))); workbench.getElements().put(requires, null); } WisdomViewVisitor(ComponentWorkbench workbench, Reporter reporter, FieldNode node); @Override void visit(String s, Object o); @Override void visitEnd();  }