MacStringsdictFilterKey extends XMLFilter { protected String getNoteFromXMLCommentsInSkeleton(String skeleton) { String note = null; StringBuilder commentBuilder = new StringBuilder(); Pattern pattern = Pattern.compile(XML_COMMENT_PATTERN); Matcher matcher = pattern.matcher(skeleton); while (matcher.find()) { String comment = matcher.group(XML_COMMENT_GROUP_NAME).trim(); if (!comment.startsWith("Location: ")) { if (commentBuilder.length() > 0) { commentBuilder.append(" "); } commentBuilder.append(comment); } } if (commentBuilder.length() > 0) { note = commentBuilder.toString(); } return note; }  @Override String getName(); @Override List<FilterConfiguration> getConfigurations(); @Override boolean hasNext(); @Override Event next(); @Override void open(RawDocument input); void readNextEvents(); static final String FILTER_CONFIG_ID; static final String MAC_STRINGSDICT_CONFIG_FILE_NAME; }
@Test public void testGetNoteFromXMLCommentsInSkeletonNoComment() { String skeleton = "no comments"; MacStringsdictFilterKey instance = new MacStringsdictFilterKey(); String expResult = null; String result = instance.getNoteFromXMLCommentsInSkeleton(skeleton); assertEquals(expResult, result); }
@Test public void testGetNoteFromXMLCommentsInSkeletonComment() { String skeleton = "blalbala <!-- a comment --> blalba"; MacStringsdictFilterKey instance = new MacStringsdictFilterKey(); String expResult = "a comment"; String result = instance.getNoteFromXMLCommentsInSkeleton(skeleton); assertEquals(expResult, result); }
@Test public void testGetNoteFromXMLCommentsInSkeletonMultipleComments() { String skeleton = "blalbala <!-- line 1 -->\n <!-- line 2 -->\n <!-- line 3 --> blalba"; MacStringsdictFilterKey instance = new MacStringsdictFilterKey(); String expResult = "line 1 line 2 line 3"; String result = instance.getNoteFromXMLCommentsInSkeleton(skeleton); assertEquals(expResult, result); }
@Test public void testGetNoteFromXMLCommentsInSkeletonMultiline() { String skeleton = "blalbala <!-- line 1\nline 2 \nline 3 --> blalba"; MacStringsdictFilterKey instance = new MacStringsdictFilterKey(); String expResult = "line 1\nline 2 \nline 3"; String result = instance.getNoteFromXMLCommentsInSkeleton(skeleton); assertEquals(expResult, result); }