@Test public void parseChanges() throws Exception { String output = "Change 1234 on 2008/10/13 11:30:00 by ADMIN@UserWorkspaceName\n" + "\tComment given to changelist within single qoutes, this is change one\n" + "Change 6543 on 2008/10/08 18:25:38 by USER@USER_WS\n" + "\t'Comment given to changelist within single qoutes'\n" + "Change 7654 on 2008/09/30 01:00:01 by USER@USER_WS\n" + "\t'Comment given to changelist within single qoutes'\n" + "Change 2345 on 2008/09/30 17:45:33 by ADMIN@Workspace2\n" + "\t'Comment given to changelist within single qoutes'\n"; PerforceHistoryParser parser = new PerforceHistoryParser(new PerforceRepository()); History result = parser.parseChanges(new StringReader(output)); assertNotNull(result); assertEquals(4, result.getHistoryEntries().size()); HistoryEntry e1 = result.getHistoryEntries().get(0); assertEquals("1234", e1.getRevision()); assertEquals("ADMIN", e1.getAuthor()); assertEquals(0, e1.getFiles().size()); assertTrue(e1.getMessage().contains("change one")); HistoryEntry e2 = result.getHistoryEntries().get(1); assertNotNull(e2); HistoryEntry e3 = result.getHistoryEntries().get(2); assertNotNull(e3); HistoryEntry e4 = result.getHistoryEntries().get(3); assertEquals("2345", e4.getRevision()); assertDate(e1, 2008, Calendar.OCTOBER, 13); assertDate(e2, 2008, Calendar.OCTOBER, 8); assertDate(e3, 2008, Calendar.SEPTEMBER, 30); assertDate(e4, 2008, Calendar.SEPTEMBER, 30); }
History parseChanges(Reader fileHistory) throws IOException { List<HistoryEntry> entries = new ArrayList<>(); HistoryEntry entry = null; StringBuilder messageBuilder = new StringBuilder(); try (BufferedReader reader = new BufferedReader(fileHistory)) { String line; while ((line = reader.readLine()) != null) { Matcher matcher = CHANGE_PATTERN.matcher(line); if (matcher.find()) { entry = parseEntryLine(entries, entry, messageBuilder, matcher); } else if (line.startsWith("\t")) { messageBuilder.append(line.substring(1)); messageBuilder.append("\n"); } } } if (entry != null) { entry.setMessage(messageBuilder.toString().trim()); entries.add(entry); } History history = new History(); history.setHistoryEntries(entries); return history; }
PerforceHistoryParser { History parseChanges(Reader fileHistory) throws IOException { List<HistoryEntry> entries = new ArrayList<>(); HistoryEntry entry = null; StringBuilder messageBuilder = new StringBuilder(); try (BufferedReader reader = new BufferedReader(fileHistory)) { String line; while ((line = reader.readLine()) != null) { Matcher matcher = CHANGE_PATTERN.matcher(line); if (matcher.find()) { entry = parseEntryLine(entries, entry, messageBuilder, matcher); } else if (line.startsWith("\t")) { messageBuilder.append(line.substring(1)); messageBuilder.append("\n"); } } } if (entry != null) { entry.setMessage(messageBuilder.toString().trim()); entries.add(entry); } History history = new History(); history.setHistoryEntries(entries); return history; } }
PerforceHistoryParser { History parseChanges(Reader fileHistory) throws IOException { List<HistoryEntry> entries = new ArrayList<>(); HistoryEntry entry = null; StringBuilder messageBuilder = new StringBuilder(); try (BufferedReader reader = new BufferedReader(fileHistory)) { String line; while ((line = reader.readLine()) != null) { Matcher matcher = CHANGE_PATTERN.matcher(line); if (matcher.find()) { entry = parseEntryLine(entries, entry, messageBuilder, matcher); } else if (line.startsWith("\t")) { messageBuilder.append(line.substring(1)); messageBuilder.append("\n"); } } } if (entry != null) { entry.setMessage(messageBuilder.toString().trim()); entries.add(entry); } History history = new History(); history.setHistoryEntries(entries); return history; } PerforceHistoryParser(PerforceRepository repo); }
PerforceHistoryParser { History parseChanges(Reader fileHistory) throws IOException { List<HistoryEntry> entries = new ArrayList<>(); HistoryEntry entry = null; StringBuilder messageBuilder = new StringBuilder(); try (BufferedReader reader = new BufferedReader(fileHistory)) { String line; while ((line = reader.readLine()) != null) { Matcher matcher = CHANGE_PATTERN.matcher(line); if (matcher.find()) { entry = parseEntryLine(entries, entry, messageBuilder, matcher); } else if (line.startsWith("\t")) { messageBuilder.append(line.substring(1)); messageBuilder.append("\n"); } } } if (entry != null) { entry.setMessage(messageBuilder.toString().trim()); entries.add(entry); } History history = new History(); history.setHistoryEntries(entries); return history; } PerforceHistoryParser(PerforceRepository repo);  }
PerforceHistoryParser { History parseChanges(Reader fileHistory) throws IOException { List<HistoryEntry> entries = new ArrayList<>(); HistoryEntry entry = null; StringBuilder messageBuilder = new StringBuilder(); try (BufferedReader reader = new BufferedReader(fileHistory)) { String line; while ((line = reader.readLine()) != null) { Matcher matcher = CHANGE_PATTERN.matcher(line); if (matcher.find()) { entry = parseEntryLine(entries, entry, messageBuilder, matcher); } else if (line.startsWith("\t")) { messageBuilder.append(line.substring(1)); messageBuilder.append("\n"); } } } if (entry != null) { entry.setMessage(messageBuilder.toString().trim()); entries.add(entry); } History history = new History(); history.setHistoryEntries(entries); return history; } PerforceHistoryParser(PerforceRepository repo);   }