### Question:
TagsHelper { public static Integer[] getPreselectedTagsArray (Note note, List<Tag> tags) { List<Integer> t = new ArrayList<>(); for (String noteTag : TagsHelper.retrieveTags(note).keySet()) { for (Tag tag : tags) { if (tag.getText().equals(noteTag)) { t.add(tags.indexOf(tag)); break; } } } return t.toArray(new Integer[]{}); }  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);  }### Answer:
@Test public void getPreselectedTagsArray () { final Tag anotherTag = new Tag("#anotherTag", 1); Note anotherNote = new Note(); anotherNote.setContent(TAG1.getText() + " " + TAG2.getText() + " " + anotherTag); note.setContent(note.getContent().replace(TAG4.toString(), "")); List<Tag> tags = Arrays.asList(TAG1, TAG2, TAG3, TAG4, anotherTag); List<Note> notes = Arrays.asList(note, anotherNote); Integer[] preselectedTags = TagsHelper.getPreselectedTagsArray(notes, tags); assertEquals(preselectedTags.length, 4); for (Integer preselectedTag : preselectedTags) { assertNotEquals((int) preselectedTag, tags.indexOf(TAG4)); } }