@Test public void retrievesTagsFromNote () { HashMap<String, Integer> tags = TagsHelper.retrieveTags(note); assertEquals(tags.size(), 4); assertTrue(tags.containsKey(TAG1.getText()) && tags.containsKey(TAG2.getText()) && tags.containsKey(TAG3.getText()) && tags.containsKey(TAG4.getText())); assertFalse(tags.containsKey(TAG_INVALID.getText())); }
public static HashMap<String, Integer> retrieveTags (Note note) { HashMap<String, Integer> tagsMap = new HashMap<>(); String[] words = (note.getTitle() + " " + note.getContent()).replaceAll("\n", " ").trim().split(" "); for (String word : words) { String parsedHashtag = UrlCompleter.parseHashtag(word); if (StringUtils.isNotEmpty(parsedHashtag)) { int count = tagsMap.get(parsedHashtag) == null ? 0 : tagsMap.get(parsedHashtag); tagsMap.put(parsedHashtag, ++count); } } return tagsMap; }
TagsHelper { public static HashMap<String, Integer> retrieveTags (Note note) { HashMap<String, Integer> tagsMap = new HashMap<>(); String[] words = (note.getTitle() + " " + note.getContent()).replaceAll("\n", " ").trim().split(" "); for (String word : words) { String parsedHashtag = UrlCompleter.parseHashtag(word); if (StringUtils.isNotEmpty(parsedHashtag)) { int count = tagsMap.get(parsedHashtag) == null ? 0 : tagsMap.get(parsedHashtag); tagsMap.put(parsedHashtag, ++count); } } return tagsMap; } }
TagsHelper { public static HashMap<String, Integer> retrieveTags (Note note) { HashMap<String, Integer> tagsMap = new HashMap<>(); String[] words = (note.getTitle() + " " + note.getContent()).replaceAll("\n", " ").trim().split(" "); for (String word : words) { String parsedHashtag = UrlCompleter.parseHashtag(word); if (StringUtils.isNotEmpty(parsedHashtag)) { int count = tagsMap.get(parsedHashtag) == null ? 0 : tagsMap.get(parsedHashtag); tagsMap.put(parsedHashtag, ++count); } } return tagsMap; }  }
TagsHelper { public static HashMap<String, Integer> retrieveTags (Note note) { HashMap<String, Integer> tagsMap = new HashMap<>(); String[] words = (note.getTitle() + " " + note.getContent()).replaceAll("\n", " ").trim().split(" "); for (String word : words) { String parsedHashtag = UrlCompleter.parseHashtag(word); if (StringUtils.isNotEmpty(parsedHashtag)) { int count = tagsMap.get(parsedHashtag) == null ? 0 : tagsMap.get(parsedHashtag); tagsMap.put(parsedHashtag, ++count); } } return tagsMap; }  static List<Tag> getAllTags(); static HashMap<String, Integer> retrieveTags(Note note); static Pair<String, List<Tag>> addTagToNote(List<Tag> tags, Integer[] selectedTags, Note note); static Pair<String, String> removeTag(String noteTitle, String noteContent, List<Tag> tagsToRemove); static String[] getTagsArray(List<Tag> tags); static Integer[] getPreselectedTagsArray(Note note, List<Tag> tags); static Integer[] getPreselectedTagsArray(List<Note> notes, List<Tag> tags); }
TagsHelper { public static HashMap<String, Integer> retrieveTags (Note note) { HashMap<String, Integer> tagsMap = new HashMap<>(); String[] words = (note.getTitle() + " " + note.getContent()).replaceAll("\n", " ").trim().split(" "); for (String word : words) { String parsedHashtag = UrlCompleter.parseHashtag(word); if (StringUtils.isNotEmpty(parsedHashtag)) { int count = tagsMap.get(parsedHashtag) == null ? 0 : tagsMap.get(parsedHashtag); tagsMap.put(parsedHashtag, ++count); } } return tagsMap; }  static List<Tag> getAllTags(); static HashMap<String, Integer> retrieveTags(Note note); static Pair<String, List<Tag>> addTagToNote(List<Tag> tags, Integer[] selectedTags, Note note); static Pair<String, String> removeTag(String noteTitle, String noteContent, List<Tag> tagsToRemove); static String[] getTagsArray(List<Tag> tags); static Integer[] getPreselectedTagsArray(Note note, List<Tag> tags); static Integer[] getPreselectedTagsArray(List<Note> notes, List<Tag> tags);  }