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[]{});
  }
@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(4, preselectedTags.length);
    for (Integer preselectedTag : preselectedTags) {
      assertNotEquals((int) preselectedTag, tags.indexOf(TAG4));
    }
  }