### Question:
NotesHelper { public static Note mergeNotes (List<Note> notes, boolean keepMergedNotes) { boolean locked = false; ArrayList<Attachment> attachments = new ArrayList<>(); String reminder = null; String reminderRecurrenceRule = null; Double latitude = null; Double longitude = null; Note mergedNote = new Note(); mergedNote.setTitle(notes.get(0).getTitle()); mergedNote.setArchived(notes.get(0).isArchived()); mergedNote.setCategory(notes.get(0).getCategory()); StringBuilder content = new StringBuilder(); boolean includeTitle = false; for (Note note : notes) { appendContent(note, content, includeTitle); locked = locked || note.isLocked(); String currentReminder = note.getAlarm(); if (!StringUtils.isEmpty(currentReminder) && reminder == null) { reminder = currentReminder; reminderRecurrenceRule = note.getRecurrenceRule(); } latitude = ObjectUtils.defaultIfNull(latitude, note.getLatitude()); longitude = ObjectUtils.defaultIfNull(longitude, note.getLongitude()); addAttachments(keepMergedNotes, note, attachments); includeTitle = true; } mergedNote.setContent(content.toString()); mergedNote.setLocked(locked); mergedNote.setAlarm(reminder); mergedNote.setRecurrenceRule(reminderRecurrenceRule); mergedNote.setLatitude(latitude); mergedNote.setLongitude(longitude); mergedNote.setAttachmentsList(attachments); return mergedNote; }  static boolean haveSameId(Note note, Note currentNote); static StringBuilder appendContent(Note note, StringBuilder content, boolean includeTitle); static void addAttachments(boolean keepMergedNotes, Note note, ArrayList<Attachment> attachments); static Note mergeNotes(List<Note> notes, boolean keepMergedNotes); static StatsSingleNote getNoteInfos(Note note); static int getWords(Note note); static int getChars(Note note);  }### Answer:
@Test public void mergingNotesDoesntDuplicateFirstTitle () { final String FIRST_NOTE_TITLE = "test title 1"; Note note1 = getNote(4L, FIRST_NOTE_TITLE, ""); Note note2 = getNote(5L, "test title 2", ""); Note mergedNote = NotesHelper.mergeNotes(Arrays.asList(note1, note2), false); assertFalse(mergedNote.getContent().contains(FIRST_NOTE_TITLE)); }
@Test public void mergeNotes () { int notesNumber = 3; List<Note> notes = new ArrayList<>(); for (int i = 0; i < notesNumber; i++) { Note note = new Note(); note.setTitle("Merged note " + i + " title"); note.setContent("Merged note " + i + " content"); notes.add(note); } Note mergeNote = NotesHelper.mergeNotes(notes, false); assertNotNull(mergeNote); Assert.assertEquals("Merged note 0 title", mergeNote.getTitle()); Assert.assertTrue(mergeNote.getContent().contains("Merged note 0 content")); Assert.assertTrue(mergeNote.getContent().contains("Merged note 1 content")); Assert.assertTrue(mergeNote.getContent().contains("Merged note 2 content")); assertEquals(StringUtils.countMatches(mergeNote.getContent(), Constants.MERGED_NOTES_SEPARATOR), 2); }