@Test public void testProcessAnnotationWithoutParameters() { AnnotationProcessor processor=new AnnotationProcessor(); String name="Interface"; Interaction mobj=new Interaction(); String annotationText=name; CachedJournal journal=new CachedJournal(); Annotation an=processor.getAnnotation(annotationText, mobj.getProperties(), journal); if (journal.hasErrors()) { fail("Error reported"); } mobj.getAnnotations().add(an); Annotation annotation=AnnotationDefinitions.getAnnotation(mobj.getAnnotations(), name); if (annotation == null) { fail("Annotation not associated with object"); } if (annotation.getName().equals(name) == false) { fail("Annotation name is incorrect"); } if (annotation.getProperties().size() != 0) { fail("No properties expected"); } }
public Annotation getAnnotation(String annotation, java.util.Map<String, Object> properties, Journal journal) { java.util.StringTokenizer st=new java.util.StringTokenizer(annotation); String name=st.nextToken(" ("); Annotation an=new Annotation(name); if (st.hasMoreTokens()) { String token=st.nextToken("()"); if (token != null) { String[] props=token.split(","); for (int i=0; i < props.length; i++) { String[] vals=props[i].split("="); if (vals.length != 2) { journal.error("Name/Value of annotation could not be derived", properties); } else { an.getProperties().put(vals[0], vals[1]); } } int index=annotation.indexOf(token); if (index != -1) { index = annotation.indexOf(')', index+token.length()); if (index == -1) { journal.error("')' not found in annotation", properties); } } } else { journal.error("'(' not found in annotation", properties); } } return(an); }
AnnotationProcessor implements org.scribble.protocol.parser.AnnotationProcessor { public Annotation getAnnotation(String annotation, java.util.Map<String, Object> properties, Journal journal) { java.util.StringTokenizer st=new java.util.StringTokenizer(annotation); String name=st.nextToken(" ("); Annotation an=new Annotation(name); if (st.hasMoreTokens()) { String token=st.nextToken("()"); if (token != null) { String[] props=token.split(","); for (int i=0; i < props.length; i++) { String[] vals=props[i].split("="); if (vals.length != 2) { journal.error("Name/Value of annotation could not be derived", properties); } else { an.getProperties().put(vals[0], vals[1]); } } int index=annotation.indexOf(token); if (index != -1) { index = annotation.indexOf(')', index+token.length()); if (index == -1) { journal.error("')' not found in annotation", properties); } } } else { journal.error("'(' not found in annotation", properties); } } return(an); } }
AnnotationProcessor implements org.scribble.protocol.parser.AnnotationProcessor { public Annotation getAnnotation(String annotation, java.util.Map<String, Object> properties, Journal journal) { java.util.StringTokenizer st=new java.util.StringTokenizer(annotation); String name=st.nextToken(" ("); Annotation an=new Annotation(name); if (st.hasMoreTokens()) { String token=st.nextToken("()"); if (token != null) { String[] props=token.split(","); for (int i=0; i < props.length; i++) { String[] vals=props[i].split("="); if (vals.length != 2) { journal.error("Name/Value of annotation could not be derived", properties); } else { an.getProperties().put(vals[0], vals[1]); } } int index=annotation.indexOf(token); if (index != -1) { index = annotation.indexOf(')', index+token.length()); if (index == -1) { journal.error("')' not found in annotation", properties); } } } else { journal.error("'(' not found in annotation", properties); } } return(an); }  }
AnnotationProcessor implements org.scribble.protocol.parser.AnnotationProcessor { public Annotation getAnnotation(String annotation, java.util.Map<String, Object> properties, Journal journal) { java.util.StringTokenizer st=new java.util.StringTokenizer(annotation); String name=st.nextToken(" ("); Annotation an=new Annotation(name); if (st.hasMoreTokens()) { String token=st.nextToken("()"); if (token != null) { String[] props=token.split(","); for (int i=0; i < props.length; i++) { String[] vals=props[i].split("="); if (vals.length != 2) { journal.error("Name/Value of annotation could not be derived", properties); } else { an.getProperties().put(vals[0], vals[1]); } } int index=annotation.indexOf(token); if (index != -1) { index = annotation.indexOf(')', index+token.length()); if (index == -1) { journal.error("')' not found in annotation", properties); } } } else { journal.error("'(' not found in annotation", properties); } } return(an); }  Annotation getAnnotation(String annotation, java.util.Map<String, Object> properties,
								Journal journal); }
AnnotationProcessor implements org.scribble.protocol.parser.AnnotationProcessor { public Annotation getAnnotation(String annotation, java.util.Map<String, Object> properties, Journal journal) { java.util.StringTokenizer st=new java.util.StringTokenizer(annotation); String name=st.nextToken(" ("); Annotation an=new Annotation(name); if (st.hasMoreTokens()) { String token=st.nextToken("()"); if (token != null) { String[] props=token.split(","); for (int i=0; i < props.length; i++) { String[] vals=props[i].split("="); if (vals.length != 2) { journal.error("Name/Value of annotation could not be derived", properties); } else { an.getProperties().put(vals[0], vals[1]); } } int index=annotation.indexOf(token); if (index != -1) { index = annotation.indexOf(')', index+token.length()); if (index == -1) { journal.error("')' not found in annotation", properties); } } } else { journal.error("'(' not found in annotation", properties); } } return(an); }  Annotation getAnnotation(String annotation, java.util.Map<String, Object> properties,
								Journal journal);  }