Implement NoteDB portion of resolvablility

The server doesn't need to handle resolvedness of a thread; the plan is
for it to be an entirely client-side implementation. Whatever value the
most recent comment has for 'unresolved' is the value that will
determine whether the thread is resolved, but each individual comment
will still have that value populated so as to keep a log of when it was
changed and who it was changed by.

Change-Id: If45057935f4f30bb6babbe5e80223b8da3fa694f
This commit is contained in:
Kasper Nilsson
2016-12-13 12:27:31 -08:00
parent b148a81817
commit c101b42cc3
11 changed files with 185 additions and 61 deletions

View File

@@ -34,6 +34,7 @@ public abstract class Comment {
public String inReplyTo; public String inReplyTo;
public Timestamp updated; public Timestamp updated;
public String message; public String message;
public boolean unresolved;
public static class Range { public static class Range {
public int startLine; public int startLine;
@@ -101,7 +102,8 @@ public abstract class Comment {
&& Objects.equals(range, c.range) && Objects.equals(range, c.range)
&& Objects.equals(inReplyTo, c.inReplyTo) && Objects.equals(inReplyTo, c.inReplyTo)
&& Objects.equals(updated, c.updated) && Objects.equals(updated, c.updated)
&& Objects.equals(message, c.message); && Objects.equals(message, c.message)
&& Objects.equals(unresolved, c.unresolved);
} }
return false; return false;
} }

View File

@@ -216,7 +216,7 @@ public class LocalComments {
} else { } else {
line = Integer.parseInt(elements[offset + 4]); line = Integer.parseInt(elements[offset + 4]);
} }
CommentInfo info = CommentInfo.create(path, side, line, range); CommentInfo info = CommentInfo.create(path, side, line, range, false);
info.message(storage.getItem(key)); info.message(storage.getItem(key));
if (key.startsWith("patchReply-")) { if (key.startsWith("patchReply-")) {
info.inReplyTo(elements[1]); info.inReplyTo(elements[1]);

View File

@@ -24,12 +24,12 @@ import java.sql.Timestamp;
public class CommentInfo extends JavaScriptObject { public class CommentInfo extends JavaScriptObject {
public static CommentInfo create(String path, Side side, public static CommentInfo create(String path, Side side,
int line, CommentRange range) { int line, CommentRange range, Boolean unresolved) {
return create(path, side, 0, line, range); return create(path, side, 0, line, range, unresolved);
} }
public static CommentInfo create(String path, Side side, int parent, public static CommentInfo create(String path, Side side, int parent,
int line, CommentRange range) { int line, CommentRange range, boolean unresolved) {
CommentInfo n = createObject().cast(); CommentInfo n = createObject().cast();
n.path(path); n.path(path);
n.side(side); n.side(side);
@@ -40,6 +40,7 @@ public class CommentInfo extends JavaScriptObject {
} else if (line > 0) { } else if (line > 0) {
n.line(line); n.line(line);
} }
n.unresolved(unresolved);
return n; return n;
} }
@@ -55,6 +56,7 @@ public class CommentInfo extends JavaScriptObject {
} else if (r.hasLine()) { } else if (r.hasLine()) {
n.line(r.line()); n.line(r.line());
} }
n.unresolved(r.unresolved());
return n; return n;
} }
@@ -72,6 +74,7 @@ public class CommentInfo extends JavaScriptObject {
} else if (s.hasLine()) { } else if (s.hasLine()) {
n.line(s.line()); n.line(s.line());
} }
n.unresolved(s.unresolved());
return n; return n;
} }
@@ -81,6 +84,7 @@ public class CommentInfo extends JavaScriptObject {
public final native void range(CommentRange r) /*-{ this.range = r }-*/; public final native void range(CommentRange r) /*-{ this.range = r }-*/;
public final native void inReplyTo(String i) /*-{ this.in_reply_to = i }-*/; public final native void inReplyTo(String i) /*-{ this.in_reply_to = i }-*/;
public final native void message(String m) /*-{ this.message = m }-*/; public final native void message(String m) /*-{ this.message = m }-*/;
public final native void unresolved(boolean b) /*-{ this.unresolved = b }-*/;
public final void side(Side side) { public final void side(Side side) {
sideRaw(side.toString()); sideRaw(side.toString());
@@ -93,6 +97,7 @@ public class CommentInfo extends JavaScriptObject {
public final native String id() /*-{ return this.id }-*/; public final native String id() /*-{ return this.id }-*/;
public final native String inReplyTo() /*-{ return this.in_reply_to }-*/; public final native String inReplyTo() /*-{ return this.in_reply_to }-*/;
public final native int patchSet() /*-{ return this.patch_set }-*/; public final native int patchSet() /*-{ return this.patch_set }-*/;
public final native boolean unresolved() /*-{ return this.unresolved }-*/;
public final Side side() { public final Side side() {
String s = sideRaw(); String s = sideRaw();

View File

@@ -196,7 +196,8 @@ abstract class CommentManager {
getStoredSideFromDisplaySide(side), getStoredSideFromDisplaySide(side),
getParentNumFromDisplaySide(side), getParentNumFromDisplaySide(side),
line, line,
null)).setEdit(true); null,
false)).setEdit(true);
} }
} }

View File

@@ -87,7 +87,8 @@ class SideBySideCommentManager extends CommentManager {
getStoredSideFromDisplaySide(cm.side()), getStoredSideFromDisplaySide(cm.side()),
getParentNumFromDisplaySide(cm.side()), getParentNumFromDisplaySide(cm.side()),
line, line,
CommentRange.create(fromTo))).setEdit(true); CommentRange.create(fromTo),
false)).setEdit(true);
cm.setCursor(fromTo.to()); cm.setCursor(fromTo.to());
cm.setSelection(cm.getCursor()); cm.setSelection(cm.getCursor());
} else { } else {

View File

@@ -176,7 +176,8 @@ class UnifiedCommentManager extends CommentManager {
getPath(), getPath(),
getStoredSideFromDisplaySide(side), getStoredSideFromDisplaySide(side),
to.line() + 1, to.line() + 1,
CommentRange.create(fromTo))).setEdit(true); CommentRange.create(fromTo),
false)).setEdit(true);
cm.setCursor(Pos.create(host.getCmLine(to.line(), side), to.ch())); cm.setCursor(Pos.create(host.getCmLine(to.line(), side), to.ch()));
cm.setSelection(cm.getCursor()); cm.setSelection(cm.getCursor());
} else { } else {

View File

@@ -148,7 +148,7 @@ public class CommentsUtil {
Comment c = new Comment( Comment c = new Comment(
new Comment.Key(ChangeUtil.messageUUID(ctx.getDb()), path, psId.get()), new Comment.Key(ChangeUtil.messageUUID(ctx.getDb()), path, psId.get()),
ctx.getUser().getAccountId(), ctx.getWhen(), side, message, serverId, ctx.getUser().getAccountId(), ctx.getWhen(), side, message, serverId,
true); false);
ctx.getUser().updateRealAccountId(c::setRealAuthor); ctx.getUser().updateRealAccountId(c::setRealAuthor);
return c; return c;
} }

View File

@@ -147,6 +147,7 @@ class CommentJson {
r.updated = c.writtenOn; r.updated = c.writtenOn;
r.range = toRange(c.range); r.range = toRange(c.range);
r.tag = c.tag; r.tag = c.tag;
r.unresolved = c.unresolved;
if (loader != null) { if (loader != null) {
r.author = loader.get(c.author.getId()); r.author = loader.get(c.author.getId());
} }

View File

@@ -249,9 +249,16 @@ public class ChangeNoteUtil {
boolean hasParent = boolean hasParent =
(RawParseUtils.match(note, curr.value, PARENT.getBytes(UTF_8))) != -1; (RawParseUtils.match(note, curr.value, PARENT.getBytes(UTF_8))) != -1;
String parentUUID = null; String parentUUID = null;
boolean unresolved = false;
if (hasParent) { if (hasParent) {
parentUUID = parseStringField(note, curr, changeId, PARENT); parentUUID = parseStringField(note, curr, changeId, PARENT);
} }
boolean hasUnresolved =
(RawParseUtils.match(note, curr.value,
UNRESOLVED.getBytes(UTF_8))) != -1;
if (hasUnresolved) {
unresolved = parseBooleanField(note, curr, changeId, UNRESOLVED);
}
String uuid = parseStringField(note, curr, changeId, UUID); String uuid = parseStringField(note, curr, changeId, UUID);
@@ -277,7 +284,7 @@ public class ChangeNoteUtil {
: (short) 1, : (short) 1,
message, message,
serverId, serverId,
false); unresolved);
c.lineNbr = range.getEndLine(); c.lineNbr = range.getEndLine();
c.parentUuid = parentUUID; c.parentUuid = parentUUID;
c.tag = tag; c.tag = tag;
@@ -458,6 +465,17 @@ public class ChangeNoteUtil {
return checkResult(commentLength, "comment length", changeId); return checkResult(commentLength, "comment length", changeId);
} }
private boolean parseBooleanField(byte[] note, MutableInteger curr,
Change.Id changeId, String fieldName) throws ConfigInvalidException {
String str = parseStringField(note, curr, changeId, fieldName);
if ("true".equalsIgnoreCase(str)) {
return true;
} else if ("false".equalsIgnoreCase(str)) {
return false;
}
throw parseException(changeId, "invalid boolean for %s: %s", fieldName, str);
}
private static <T> T checkResult(T o, String fieldName, private static <T> T checkResult(T o, String fieldName,
Change.Id changeId) throws ConfigInvalidException { Change.Id changeId) throws ConfigInvalidException {
if (o == null) { if (o == null) {
@@ -590,6 +608,7 @@ public class ChangeNoteUtil {
appendHeaderField(writer, PARENT, parent); appendHeaderField(writer, PARENT, parent);
} }
appendHeaderField(writer, UNRESOLVED, Boolean.toString(c.unresolved));
appendHeaderField(writer, UUID, c.key.uuid); appendHeaderField(writer, UUID, c.key.uuid);
if (c.tag != null) { if (c.tag != null) {

View File

@@ -251,7 +251,8 @@ public abstract class AbstractChangeNotesTest extends GerritBaseTests {
protected Comment newComment(PatchSet.Id psId, String filename, String UUID, protected Comment newComment(PatchSet.Id psId, String filename, String UUID,
CommentRange range, int line, IdentifiedUser commenter, String parentUUID, CommentRange range, int line, IdentifiedUser commenter, String parentUUID,
Timestamp t, String message, short side, String commitSHA1) { Timestamp t, String message, short side, String commitSHA1,
boolean unresolved) {
Comment c = new Comment( Comment c = new Comment(
new Comment.Key(UUID, filename, psId.get()), new Comment.Key(UUID, filename, psId.get()),
commenter.getAccountId(), commenter.getAccountId(),
@@ -259,7 +260,7 @@ public abstract class AbstractChangeNotesTest extends GerritBaseTests {
side, side,
message, message,
serverId, serverId,
false); unresolved);
c.lineNbr = line; c.lineNbr = line;
c.parentUuid = parentUUID; c.parentUuid = parentUUID;
c.revId = commitSHA1; c.revId = commitSHA1;

View File

@@ -128,7 +128,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.putComment(Status.PUBLISHED, update.putComment(Status.PUBLISHED,
newComment(c.currentPatchSetId(), "a.txt", "uuid1", newComment(c.currentPatchSetId(), "a.txt", "uuid1",
new CommentRange(1, 2, 3, 4), 1, changeOwner, null, new CommentRange(1, 2, 3, 4), 1, changeOwner, null,
TimeUtil.nowTs(), "Comment", (short) 1, commit.name())); TimeUtil.nowTs(), "Comment", (short) 1, commit.name(), false));
update.setTag(tag); update.setTag(tag);
update.commit(); update.commit();
@@ -183,7 +183,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.putComment(Status.PUBLISHED, update.putComment(Status.PUBLISHED,
newComment(c.currentPatchSetId(), "a.txt", "uuid1", newComment(c.currentPatchSetId(), "a.txt", "uuid1",
new CommentRange(1, 2, 3, 4), 1, changeOwner, null, new CommentRange(1, 2, 3, 4), 1, changeOwner, null,
TimeUtil.nowTs(), "Comment", (short) 1, commit.name())); TimeUtil.nowTs(), "Comment", (short) 1, commit.name(), false));
update.setChangeMessage("coverage verification"); update.setChangeMessage("coverage verification");
update.setTag(coverageTag); update.setTag(coverageTag);
update.commit(); update.commit();
@@ -1039,7 +1039,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.putComment(Status.PUBLISHED, update.putComment(Status.PUBLISHED,
newComment(c.currentPatchSetId(), "a.txt", "uuid1", newComment(c.currentPatchSetId(), "a.txt", "uuid1",
new CommentRange(1, 2, 3, 4), 1, changeOwner, null, new CommentRange(1, 2, 3, 4), 1, changeOwner, null,
TimeUtil.nowTs(), "Comment", (short) 1, commit.name())); TimeUtil.nowTs(), "Comment", (short) 1, commit.name(), false));
update.commit(); update.commit();
ChangeNotes notes = newNotes(c); ChangeNotes notes = newNotes(c);
@@ -1137,7 +1137,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
Timestamp ts = TimeUtil.nowTs(); Timestamp ts = TimeUtil.nowTs();
update.putComment(Status.PUBLISHED, update.putComment(Status.PUBLISHED,
newComment(psId2, "a.txt", "uuid1", new CommentRange(1, 2, 3, 4), 1, newComment(psId2, "a.txt", "uuid1", new CommentRange(1, 2, 3, 4), 1,
changeOwner, null, ts, "Comment", (short) 1, commit.name())); changeOwner, null, ts, "Comment", (short) 1, commit.name(), false));
update.commit(); update.commit();
notes = newNotes(c); notes = newNotes(c);
@@ -1157,6 +1157,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
+ "1:2-3:4\n" + "1:2-3:4\n"
+ ChangeNoteUtil.formatTime(serverIdent, ts) + "\n" + ChangeNoteUtil.formatTime(serverIdent, ts) + "\n"
+ "Author: Change Owner <1@gerrit>\n" + "Author: Change Owner <1@gerrit>\n"
+ "Unresolved: false\n"
+ "UUID: uuid1\n" + "UUID: uuid1\n"
+ "Bytes: 7\n" + "Bytes: 7\n"
+ "Comment\n" + "Comment\n"
@@ -1217,7 +1218,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
updateManagerFactory.create(project)) { updateManagerFactory.create(project)) {
Comment comment1 = newComment(psId, "file1", Comment comment1 = newComment(psId, "file1",
uuid1, range1, range1.getEndLine(), otherUser, null, time1, message1, uuid1, range1, range1.getEndLine(), otherUser, null, time1, message1,
(short) 0, "abcd1234abcd1234abcd1234abcd1234abcd1234"); (short) 0, "abcd1234abcd1234abcd1234abcd1234abcd1234", false);
update1.setPatchSetId(psId); update1.setPatchSetId(psId);
update1.putComment(Status.PUBLISHED, comment1); update1.putComment(Status.PUBLISHED, comment1);
updateManager.add(update1); updateManager.add(update1);
@@ -1444,7 +1445,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
Comment comment = newComment(psId, "file1", Comment comment = newComment(psId, "file1",
"uuid", null, 0, otherUser, null, "uuid", null, 0, otherUser, null,
TimeUtil.nowTs(), "message", (short) 1, revId.get()); TimeUtil.nowTs(), "message", (short) 1, revId.get(), false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment); update.putComment(Status.PUBLISHED, comment);
update.commit(); update.commit();
@@ -1464,7 +1465,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
Comment comment = newComment(psId, "file1", Comment comment = newComment(psId, "file1",
"uuid", range, range.getEndLine(), otherUser, null, "uuid", range, range.getEndLine(), otherUser, null,
TimeUtil.nowTs(), "message", (short) 1, revId.get()); TimeUtil.nowTs(), "message", (short) 1, revId.get(), false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment); update.putComment(Status.PUBLISHED, comment);
update.commit(); update.commit();
@@ -1484,7 +1485,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
Comment comment = newComment(psId, "file", Comment comment = newComment(psId, "file",
"uuid", range, range.getEndLine(), otherUser, null, "uuid", range, range.getEndLine(), otherUser, null,
TimeUtil.nowTs(), "message", (short) 1, revId.get()); TimeUtil.nowTs(), "message", (short) 1, revId.get(), false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment); update.putComment(Status.PUBLISHED, comment);
update.commit(); update.commit();
@@ -1503,7 +1504,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
CommentRange range = new CommentRange(1, 2, 3, 4); CommentRange range = new CommentRange(1, 2, 3, 4);
Comment comment = newComment(psId, "", "uuid", range, range.getEndLine(), Comment comment = newComment(psId, "", "uuid", range, range.getEndLine(),
otherUser, null, TimeUtil.nowTs(), "message", (short) 1, revId.get()); otherUser, null, TimeUtil.nowTs(), "message", (short) 1, revId.get(),
false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment); update.putComment(Status.PUBLISHED, comment);
update.commit(); update.commit();
@@ -1531,7 +1533,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
Comment comment1 = newComment(psId, "file1", uuid1, range1, Comment comment1 = newComment(psId, "file1", uuid1, range1,
range1.getEndLine(), otherUser, null, time1, message1, (short) 1, range1.getEndLine(), otherUser, null, time1, message1, (short) 1,
"abcd1234abcd1234abcd1234abcd1234abcd1234"); "abcd1234abcd1234abcd1234abcd1234abcd1234", false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment1); update.putComment(Status.PUBLISHED, comment1);
update.commit(); update.commit();
@@ -1540,7 +1542,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
CommentRange range2 = new CommentRange(2, 1, 3, 1); CommentRange range2 = new CommentRange(2, 1, 3, 1);
Comment comment2 = newComment(psId, "file1", uuid2, range2, Comment comment2 = newComment(psId, "file1", uuid2, range2,
range2.getEndLine(), otherUser, null, time2, message2, (short) 1, range2.getEndLine(), otherUser, null, time2, message2, (short) 1,
"abcd1234abcd1234abcd1234abcd1234abcd1234"); "abcd1234abcd1234abcd1234abcd1234abcd1234", false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment2); update.putComment(Status.PUBLISHED, comment2);
update.commit(); update.commit();
@@ -1549,7 +1551,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
CommentRange range3 = new CommentRange(3, 0, 4, 1); CommentRange range3 = new CommentRange(3, 0, 4, 1);
Comment comment3 = newComment(psId, "file2", uuid3, range3, Comment comment3 = newComment(psId, "file2", uuid3, range3,
range3.getEndLine(), otherUser, null, time3, message3, (short) 1, range3.getEndLine(), otherUser, null, time3, message3, (short) 1,
"abcd1234abcd1234abcd1234abcd1234abcd1234"); "abcd1234abcd1234abcd1234abcd1234abcd1234", false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment3); update.putComment(Status.PUBLISHED, comment3);
update.commit(); update.commit();
@@ -1575,6 +1577,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
+ "1:1-2:1\n" + "1:1-2:1\n"
+ ChangeNoteUtil.formatTime(serverIdent, time1) + "\n" + ChangeNoteUtil.formatTime(serverIdent, time1) + "\n"
+ "Author: Other Account <2@gerrit>\n" + "Author: Other Account <2@gerrit>\n"
+ "Unresolved: false\n"
+ "UUID: uuid1\n" + "UUID: uuid1\n"
+ "Bytes: 9\n" + "Bytes: 9\n"
+ "comment 1\n" + "comment 1\n"
@@ -1582,6 +1585,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
+ "2:1-3:1\n" + "2:1-3:1\n"
+ ChangeNoteUtil.formatTime(serverIdent, time2) + "\n" + ChangeNoteUtil.formatTime(serverIdent, time2) + "\n"
+ "Author: Other Account <2@gerrit>\n" + "Author: Other Account <2@gerrit>\n"
+ "Unresolved: false\n"
+ "UUID: uuid2\n" + "UUID: uuid2\n"
+ "Bytes: 9\n" + "Bytes: 9\n"
+ "comment 2\n" + "comment 2\n"
@@ -1591,6 +1595,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
+ "3:0-4:1\n" + "3:0-4:1\n"
+ ChangeNoteUtil.formatTime(serverIdent, time3) + "\n" + ChangeNoteUtil.formatTime(serverIdent, time3) + "\n"
+ "Author: Other Account <2@gerrit>\n" + "Author: Other Account <2@gerrit>\n"
+ "Unresolved: false\n"
+ "UUID: uuid3\n" + "UUID: uuid3\n"
+ "Bytes: 9\n" + "Bytes: 9\n"
+ "comment 3\n" + "comment 3\n"
@@ -1614,7 +1619,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
Comment comment1 = newComment(psId, "file1", Comment comment1 = newComment(psId, "file1",
uuid1, range1, range1.getEndLine(), otherUser, null, time1, message1, uuid1, range1, range1.getEndLine(), otherUser, null, time1, message1,
(short) 0, "abcd1234abcd1234abcd1234abcd1234abcd1234"); (short) 0, "abcd1234abcd1234abcd1234abcd1234abcd1234", false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment1); update.putComment(Status.PUBLISHED, comment1);
update.commit(); update.commit();
@@ -1623,7 +1628,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
CommentRange range2 = new CommentRange(2, 1, 3, 1); CommentRange range2 = new CommentRange(2, 1, 3, 1);
Comment comment2 = newComment(psId, "file1", Comment comment2 = newComment(psId, "file1",
uuid2, range2, range2.getEndLine(), otherUser, null, time2, message2, uuid2, range2, range2.getEndLine(), otherUser, null, time2, message2,
(short) 0, "abcd1234abcd1234abcd1234abcd1234abcd1234"); (short) 0, "abcd1234abcd1234abcd1234abcd1234abcd1234", false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment2); update.putComment(Status.PUBLISHED, comment2);
update.commit(); update.commit();
@@ -1649,6 +1654,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
+ "1:1-2:1\n" + "1:1-2:1\n"
+ ChangeNoteUtil.formatTime(serverIdent, time1) + "\n" + ChangeNoteUtil.formatTime(serverIdent, time1) + "\n"
+ "Author: Other Account <2@gerrit>\n" + "Author: Other Account <2@gerrit>\n"
+ "Unresolved: false\n"
+ "UUID: uuid1\n" + "UUID: uuid1\n"
+ "Bytes: 9\n" + "Bytes: 9\n"
+ "comment 1\n" + "comment 1\n"
@@ -1656,6 +1662,74 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
+ "2:1-3:1\n" + "2:1-3:1\n"
+ ChangeNoteUtil.formatTime(serverIdent, time2) + "\n" + ChangeNoteUtil.formatTime(serverIdent, time2) + "\n"
+ "Author: Other Account <2@gerrit>\n" + "Author: Other Account <2@gerrit>\n"
+ "Unresolved: false\n"
+ "UUID: uuid2\n"
+ "Bytes: 9\n"
+ "comment 2\n"
+ "\n");
}
}
}
@Test
public void patchLineCommentNotesResolvedChangesValue() throws Exception {
Change c = newChange();
ChangeUpdate update = newUpdate(c, otherUser);
String uuid1 = "uuid1";
String uuid2 = "uuid2";
String message1 = "comment 1";
String message2 = "comment 2";
CommentRange range1 = new CommentRange(1, 1, 2, 1);
Timestamp time1 = TimeUtil.nowTs();
Timestamp time2 = TimeUtil.nowTs();
PatchSet.Id psId = c.currentPatchSetId();
Comment comment1 = newComment(psId, "file1",
uuid1, range1, range1.getEndLine(), otherUser, null, time1, message1,
(short) 0, "abcd1234abcd1234abcd1234abcd1234abcd1234", false);
update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment1);
update.commit();
update = newUpdate(c, otherUser);
Comment comment2 = newComment(psId, "file1",
uuid2, range1, range1.getEndLine(), otherUser, uuid1, time2, message2,
(short) 0, "abcd1234abcd1234abcd1234abcd1234abcd1234", true);
update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment2);
update.commit();
ChangeNotes notes = newNotes(c);
try (RevWalk walk = new RevWalk(repo)) {
ArrayList<Note> notesInTree =
Lists.newArrayList(notes.revisionNoteMap.noteMap.iterator());
Note note = Iterables.getOnlyElement(notesInTree);
byte[] bytes =
walk.getObjectReader().open(
note.getData(), Constants.OBJ_BLOB).getBytes();
String noteString = new String(bytes, UTF_8);
if (!testJson()) {
assertThat(noteString).isEqualTo(
"Revision: abcd1234abcd1234abcd1234abcd1234abcd1234\n"
+ "Base-for-patch-set: 1\n"
+ "File: file1\n"
+ "\n"
+ "1:1-2:1\n"
+ ChangeNoteUtil.formatTime(serverIdent, time1) + "\n"
+ "Author: Other Account <2@gerrit>\n"
+ "Unresolved: false\n"
+ "UUID: uuid1\n"
+ "Bytes: 9\n"
+ "comment 1\n"
+ "\n"
+ "1:1-2:1\n"
+ ChangeNoteUtil.formatTime(serverIdent, time2) + "\n"
+ "Author: Other Account <2@gerrit>\n"
+ "Parent: uuid1\n"
+ "Unresolved: true\n"
+ "UUID: uuid2\n" + "UUID: uuid2\n"
+ "Bytes: 9\n" + "Bytes: 9\n"
+ "comment 2\n" + "comment 2\n"
@@ -1684,13 +1758,13 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
Comment comment1 = Comment comment1 =
newComment(psId1, "file1", uuid1, range1, range1.getEndLine(), newComment(psId1, "file1", uuid1, range1, range1.getEndLine(),
otherUser, null, time, message1, (short) 0, revId.get()); otherUser, null, time, message1, (short) 0, revId.get(), false);
Comment comment2 = Comment comment2 =
newComment(psId1, "file1", uuid2, range2, range2.getEndLine(), newComment(psId1, "file1", uuid2, range2, range2.getEndLine(),
otherUser, null, time, message2, (short) 0, revId.get()); otherUser, null, time, message2, (short) 0, revId.get(), false);
Comment comment3 = Comment comment3 =
newComment(psId2, "file1", uuid3, range1, range1.getEndLine(), newComment(psId2, "file1", uuid3, range1, range1.getEndLine(),
otherUser, null, time, message3, (short) 0, revId.get()); otherUser, null, time, message3, (short) 0, revId.get(), false);
ChangeUpdate update = newUpdate(c, otherUser); ChangeUpdate update = newUpdate(c, otherUser);
update.setPatchSetId(psId2); update.setPatchSetId(psId2);
@@ -1721,6 +1795,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
+ "1:1-2:1\n" + "1:1-2:1\n"
+ timeStr + "\n" + timeStr + "\n"
+ "Author: Other Account <2@gerrit>\n" + "Author: Other Account <2@gerrit>\n"
+ "Unresolved: false\n"
+ "UUID: uuid1\n" + "UUID: uuid1\n"
+ "Bytes: 9\n" + "Bytes: 9\n"
+ "comment 1\n" + "comment 1\n"
@@ -1728,6 +1803,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
+ "2:1-3:1\n" + "2:1-3:1\n"
+ timeStr + "\n" + timeStr + "\n"
+ "Author: Other Account <2@gerrit>\n" + "Author: Other Account <2@gerrit>\n"
+ "Unresolved: false\n"
+ "UUID: uuid2\n" + "UUID: uuid2\n"
+ "Bytes: 9\n" + "Bytes: 9\n"
+ "comment 2\n" + "comment 2\n"
@@ -1738,6 +1814,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
+ "1:1-2:1\n" + "1:1-2:1\n"
+ timeStr + "\n" + timeStr + "\n"
+ "Author: Other Account <2@gerrit>\n" + "Author: Other Account <2@gerrit>\n"
+ "Unresolved: false\n"
+ "UUID: uuid3\n" + "UUID: uuid3\n"
+ "Bytes: 9\n" + "Bytes: 9\n"
+ "comment 3\n" + "comment 3\n"
@@ -1766,7 +1843,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
Comment comment = newComment(psId, "file", uuid, range, Comment comment = newComment(psId, "file", uuid, range,
range.getEndLine(), otherUser, null, time, message, (short) 1, range.getEndLine(), otherUser, null, time, message, (short) 1,
revId.get()); revId.get(), false);
comment.setRealAuthor(changeOwner.getAccountId()); comment.setRealAuthor(changeOwner.getAccountId());
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment); update.putComment(Status.PUBLISHED, comment);
@@ -1794,6 +1871,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
+ ChangeNoteUtil.formatTime(serverIdent, time) + "\n" + ChangeNoteUtil.formatTime(serverIdent, time) + "\n"
+ "Author: Other Account <2@gerrit>\n" + "Author: Other Account <2@gerrit>\n"
+ "Real-author: Change Owner <1@gerrit>\n" + "Real-author: Change Owner <1@gerrit>\n"
+ "Unresolved: false\n"
+ "UUID: uuid\n" + "UUID: uuid\n"
+ "Bytes: 7\n" + "Bytes: 7\n"
+ "comment\n" + "comment\n"
@@ -1821,7 +1899,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
Comment comment = newComment(psId, "file1", uuid, range, range.getEndLine(), Comment comment = newComment(psId, "file1", uuid, range, range.getEndLine(),
user, null, time, "comment", (short) 1, user, null, time, "comment", (short) 1,
"abcd1234abcd1234abcd1234abcd1234abcd1234"); "abcd1234abcd1234abcd1234abcd1234abcd1234", false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment); update.putComment(Status.PUBLISHED, comment);
update.commit(); update.commit();
@@ -1848,6 +1926,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
+ "1:1-2:1\n" + "1:1-2:1\n"
+ timeStr + "\n" + timeStr + "\n"
+ "Author: Weird\u0002User <3@gerrit>\n" + "Author: Weird\u0002User <3@gerrit>\n"
+ "Unresolved: false\n"
+ "UUID: uuid\n" + "UUID: uuid\n"
+ "Bytes: 7\n" + "Bytes: 7\n"
+ "comment\n" + "comment\n"
@@ -1875,7 +1954,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
Comment commentForBase = Comment commentForBase =
newComment(psId, "filename", uuid1, range, range.getEndLine(), newComment(psId, "filename", uuid1, range, range.getEndLine(),
otherUser, null, now, messageForBase, (short) 0, rev1); otherUser, null, now, messageForBase, (short) 0, rev1, false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, commentForBase); update.putComment(Status.PUBLISHED, commentForBase);
update.commit(); update.commit();
@@ -1884,7 +1963,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
Comment commentForPS = Comment commentForPS =
newComment(psId, "filename", uuid2, range, range.getEndLine(), newComment(psId, "filename", uuid2, range, range.getEndLine(),
otherUser, null, now, messageForPS, otherUser, null, now, messageForPS,
(short) 1, rev2); (short) 1, rev2, false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, commentForPS); update.putComment(Status.PUBLISHED, commentForPS);
update.commit(); update.commit();
@@ -1911,7 +1990,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
Timestamp timeForComment2 = TimeUtil.nowTs(); Timestamp timeForComment2 = TimeUtil.nowTs();
Comment comment1 = Comment comment1 =
newComment(psId, filename, uuid1, range, range.getEndLine(), otherUser, newComment(psId, filename, uuid1, range, range.getEndLine(), otherUser,
null, timeForComment1, "comment 1", side, rev); null, timeForComment1, "comment 1", side, rev, false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment1); update.putComment(Status.PUBLISHED, comment1);
update.commit(); update.commit();
@@ -1919,7 +1998,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update = newUpdate(c, otherUser); update = newUpdate(c, otherUser);
Comment comment2 = Comment comment2 =
newComment(psId, filename, uuid2, range, range.getEndLine(), otherUser, newComment(psId, filename, uuid2, range, range.getEndLine(), otherUser,
null, timeForComment2, "comment 2", side, rev); null, timeForComment2, "comment 2", side, rev, false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment2); update.putComment(Status.PUBLISHED, comment2);
update.commit(); update.commit();
@@ -1946,7 +2025,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
Timestamp now = TimeUtil.nowTs(); Timestamp now = TimeUtil.nowTs();
Comment comment1 = newComment(psId, filename1, Comment comment1 = newComment(psId, filename1,
uuid, range, range.getEndLine(), otherUser, null, now, "comment 1", uuid, range, range.getEndLine(), otherUser, null, now, "comment 1",
side, rev); side, rev, false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment1); update.putComment(Status.PUBLISHED, comment1);
update.commit(); update.commit();
@@ -1954,7 +2033,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update = newUpdate(c, otherUser); update = newUpdate(c, otherUser);
Comment comment2 = newComment(psId, filename2, Comment comment2 = newComment(psId, filename2,
uuid, range, range.getEndLine(), otherUser, null, now, "comment 2", uuid, range, range.getEndLine(), otherUser, null, now, "comment 2",
side, rev); side, rev, false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment2); update.putComment(Status.PUBLISHED, comment2);
update.commit(); update.commit();
@@ -1979,7 +2058,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeUpdate update = newUpdate(c, otherUser); ChangeUpdate update = newUpdate(c, otherUser);
Timestamp now = TimeUtil.nowTs(); Timestamp now = TimeUtil.nowTs();
Comment comment1 = newComment(ps1, filename, uuid, range, Comment comment1 = newComment(ps1, filename, uuid, range,
range.getEndLine(), otherUser, null, now, "comment on ps1", side, rev1); range.getEndLine(), otherUser, null, now, "comment on ps1",
side, rev1, false);
update.setPatchSetId(ps1); update.setPatchSetId(ps1);
update.putComment(Status.PUBLISHED, comment1); update.putComment(Status.PUBLISHED, comment1);
update.commit(); update.commit();
@@ -1990,7 +2070,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update = newUpdate(c, otherUser); update = newUpdate(c, otherUser);
now = TimeUtil.nowTs(); now = TimeUtil.nowTs();
Comment comment2 = newComment(ps2, filename, uuid, range, Comment comment2 = newComment(ps2, filename, uuid, range,
range.getEndLine(), otherUser, null, now, "comment on ps2", side, rev2); range.getEndLine(), otherUser, null, now, "comment on ps2",
side, rev2, false);
update.setPatchSetId(ps2); update.setPatchSetId(ps2);
update.putComment(Status.PUBLISHED, comment2); update.putComment(Status.PUBLISHED, comment2);
update.commit(); update.commit();
@@ -2014,7 +2095,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeUpdate update = newUpdate(c, otherUser); ChangeUpdate update = newUpdate(c, otherUser);
Timestamp now = TimeUtil.nowTs(); Timestamp now = TimeUtil.nowTs();
Comment comment1 = newComment(ps1, filename, uuid, range, Comment comment1 = newComment(ps1, filename, uuid, range,
range.getEndLine(), otherUser, null, now, "comment on ps1", side, rev); range.getEndLine(), otherUser, null, now, "comment on ps1",
side, rev, false);
update.setPatchSetId(ps1); update.setPatchSetId(ps1);
update.putComment(Status.DRAFT, comment1); update.putComment(Status.DRAFT, comment1);
update.commit(); update.commit();
@@ -2053,9 +2135,11 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeUpdate update = newUpdate(c, otherUser); ChangeUpdate update = newUpdate(c, otherUser);
update.setPatchSetId(psId); update.setPatchSetId(psId);
Comment comment1 = newComment(psId, filename, uuid1, range1, Comment comment1 = newComment(psId, filename, uuid1, range1,
range1.getEndLine(), otherUser, null, now, "comment on ps1", side, rev); range1.getEndLine(), otherUser, null, now, "comment on ps1",
side, rev, false);
Comment comment2 = newComment(psId, filename, uuid2, range2, Comment comment2 = newComment(psId, filename, uuid2, range2,
range2.getEndLine(), otherUser, null, now, "other on ps1", side, rev); range2.getEndLine(), otherUser, null, now, "other on ps1",
side, rev, false);
update.putComment(Status.DRAFT, comment1); update.putComment(Status.DRAFT, comment1);
update.putComment(Status.DRAFT, comment2); update.putComment(Status.DRAFT, comment2);
update.commit(); update.commit();
@@ -2099,10 +2183,10 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.setPatchSetId(psId); update.setPatchSetId(psId);
Comment baseComment = Comment baseComment =
newComment(psId, filename, uuid1, range1, range1.getEndLine(), newComment(psId, filename, uuid1, range1, range1.getEndLine(),
otherUser, null, now, "comment on base", (short) 0, rev1); otherUser, null, now, "comment on base", (short) 0, rev1, false);
Comment psComment = Comment psComment =
newComment(psId, filename, uuid2, range2, range2.getEndLine(), newComment(psId, filename, uuid2, range2, range2.getEndLine(),
otherUser, null, now, "comment on ps", (short) 1, rev2); otherUser, null, now, "comment on ps", (short) 1, rev2, false);
update.putComment(Status.DRAFT, baseComment); update.putComment(Status.DRAFT, baseComment);
update.putComment(Status.DRAFT, psComment); update.putComment(Status.DRAFT, psComment);
@@ -2145,7 +2229,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeUpdate update = newUpdate(c, otherUser); ChangeUpdate update = newUpdate(c, otherUser);
Timestamp now = TimeUtil.nowTs(); Timestamp now = TimeUtil.nowTs();
Comment comment = newComment(psId, filename, uuid, range, Comment comment = newComment(psId, filename, uuid, range,
range.getEndLine(), otherUser, null, now, "comment on ps1", side, rev); range.getEndLine(), otherUser, null, now, "comment on ps1",
side, rev, false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.DRAFT, comment); update.putComment(Status.DRAFT, comment);
update.commit(); update.commit();
@@ -2183,7 +2268,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeUpdate update = newUpdate(c, otherUser); ChangeUpdate update = newUpdate(c, otherUser);
Timestamp now = TimeUtil.nowTs(); Timestamp now = TimeUtil.nowTs();
Comment comment1 = newComment(ps1, filename, uuid, range, Comment comment1 = newComment(ps1, filename, uuid, range,
range.getEndLine(), otherUser, null, now, "comment on ps1", side, rev1); range.getEndLine(), otherUser, null, now, "comment on ps1",
side, rev1, false);
update.setPatchSetId(ps1); update.setPatchSetId(ps1);
update.putComment(Status.DRAFT, comment1); update.putComment(Status.DRAFT, comment1);
update.commit(); update.commit();
@@ -2194,7 +2280,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update = newUpdate(c, otherUser); update = newUpdate(c, otherUser);
now = TimeUtil.nowTs(); now = TimeUtil.nowTs();
Comment comment2 = newComment(ps2, filename, uuid, range, Comment comment2 = newComment(ps2, filename, uuid, range,
range.getEndLine(), otherUser, null, now, "comment on ps2", side, rev2); range.getEndLine(), otherUser, null, now, "comment on ps2",
side, rev2, false);
update.setPatchSetId(ps2); update.setPatchSetId(ps2);
update.putComment(Status.DRAFT, comment2); update.putComment(Status.DRAFT, comment2);
update.commit(); update.commit();
@@ -2229,7 +2316,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeUpdate update = newUpdate(c, otherUser); ChangeUpdate update = newUpdate(c, otherUser);
Timestamp now = TimeUtil.nowTs(); Timestamp now = TimeUtil.nowTs();
Comment comment = newComment(ps1, filename, uuid, range, range.getEndLine(), Comment comment = newComment(ps1, filename, uuid, range, range.getEndLine(),
otherUser, null, now, "comment on ps1", side, rev); otherUser, null, now, "comment on ps1", side, rev, false);
update.putComment(Status.PUBLISHED, comment); update.putComment(Status.PUBLISHED, comment);
update.commit(); update.commit();
@@ -2252,7 +2339,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
Timestamp now = TimeUtil.nowTs(); Timestamp now = TimeUtil.nowTs();
Comment draft = Comment draft =
newComment(ps1, filename, "uuid1", range, range.getEndLine(), otherUser, newComment(ps1, filename, "uuid1", range, range.getEndLine(), otherUser,
null, now, "draft comment on ps1", side, rev); null, now, "draft comment on ps1", side, rev, false);
update.putComment(Status.DRAFT, draft); update.putComment(Status.DRAFT, draft);
update.commit(); update.commit();
@@ -2262,7 +2349,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update = newUpdate(c, otherUser); update = newUpdate(c, otherUser);
Comment pub = newComment(ps1, filename, "uuid2", range, range.getEndLine(), Comment pub = newComment(ps1, filename, "uuid2", range, range.getEndLine(),
otherUser, null, now, "comment on ps1", side, rev); otherUser, null, now, "comment on ps1", side, rev, false);
update.putComment(Status.PUBLISHED, pub); update.putComment(Status.PUBLISHED, pub);
update.commit(); update.commit();
@@ -2280,7 +2367,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
PatchSet.Id psId = c.currentPatchSetId(); PatchSet.Id psId = c.currentPatchSetId();
Comment comment = newComment(psId, "filename", uuid, null, 0, otherUser, Comment comment = newComment(psId, "filename", uuid, null, 0, otherUser,
null, now, messageForBase, (short) 0, rev); null, now, messageForBase, (short) 0, rev, false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment); update.putComment(Status.PUBLISHED, comment);
update.commit(); update.commit();
@@ -2300,7 +2387,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
PatchSet.Id psId = c.currentPatchSetId(); PatchSet.Id psId = c.currentPatchSetId();
Comment comment = newComment(psId, "filename", uuid, null, 1, otherUser, Comment comment = newComment(psId, "filename", uuid, null, 1, otherUser,
null, now, messageForBase, (short) 0, rev); null, now, messageForBase, (short) 0, rev, false);
update.setPatchSetId(psId); update.setPatchSetId(psId);
update.putComment(Status.PUBLISHED, comment); update.putComment(Status.PUBLISHED, comment);
update.commit(); update.commit();
@@ -2327,9 +2414,11 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.setPatchSetId(ps2); update.setPatchSetId(ps2);
Timestamp now = TimeUtil.nowTs(); Timestamp now = TimeUtil.nowTs();
Comment comment1 = newComment(ps1, filename, uuid, range, Comment comment1 = newComment(ps1, filename, uuid, range,
range.getEndLine(), otherUser, null, now, "comment on ps1", side, rev1); range.getEndLine(), otherUser, null, now, "comment on ps1",
side, rev1, false);
Comment comment2 = newComment(ps2, filename, uuid, range, Comment comment2 = newComment(ps2, filename, uuid, range,
range.getEndLine(), otherUser, null, now, "comment on ps2", side, rev2); range.getEndLine(), otherUser, null, now, "comment on ps2",
side, rev2, false);
update.putComment(Status.DRAFT, comment1); update.putComment(Status.DRAFT, comment1);
update.putComment(Status.DRAFT, comment2); update.putComment(Status.DRAFT, comment2);
update.commit(); update.commit();
@@ -2361,9 +2450,11 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.setPatchSetId(ps1); update.setPatchSetId(ps1);
Timestamp now = TimeUtil.nowTs(); Timestamp now = TimeUtil.nowTs();
Comment comment1 = newComment(ps1, "file1", "uuid1", range, Comment comment1 = newComment(ps1, "file1", "uuid1", range,
range.getEndLine(), otherUser, null, now, "comment1", side, rev1.get()); range.getEndLine(), otherUser, null, now, "comment1",
side, rev1.get(), false);
Comment comment2 = newComment(ps1, "file2", "uuid2", range, Comment comment2 = newComment(ps1, "file2", "uuid2", range,
range.getEndLine(), otherUser, null, now, "comment2", side, rev1.get()); range.getEndLine(), otherUser, null, now, "comment2",
side, rev1.get(), false);
update.putComment(Status.DRAFT, comment1); update.putComment(Status.DRAFT, comment1);
update.putComment(Status.DRAFT, comment2); update.putComment(Status.DRAFT, comment2);
update.commit(); update.commit();
@@ -2412,10 +2503,10 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
Timestamp now = TimeUtil.nowTs(); Timestamp now = TimeUtil.nowTs();
Comment comment1 = Comment comment1 =
newComment(ps1, "file1", "uuid1", range, range.getEndLine(), otherUser, newComment(ps1, "file1", "uuid1", range, range.getEndLine(), otherUser,
null, now, "comment on ps1", side, rev1.get()); null, now, "comment on ps1", side, rev1.get(), false);
Comment comment2 = Comment comment2 =
newComment(ps1, "file2", "uuid2", range, range.getEndLine(), otherUser, newComment(ps1, "file2", "uuid2", range, range.getEndLine(), otherUser,
null, now, "another comment", side, rev1.get()); null, now, "another comment", side, rev1.get(), false);
update.putComment(Status.DRAFT, comment1); update.putComment(Status.DRAFT, comment1);
update.putComment(Status.DRAFT, comment2); update.putComment(Status.DRAFT, comment2);
update.commit(); update.commit();
@@ -2472,13 +2563,15 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
ChangeUpdate update1 = newUpdate(c, otherUser); ChangeUpdate update1 = newUpdate(c, otherUser);
Comment comment1 = newComment(c.currentPatchSetId(), "filename", Comment comment1 = newComment(c.currentPatchSetId(), "filename",
"uuid1", range, range.getEndLine(), otherUser, null, "uuid1", range, range.getEndLine(), otherUser, null,
new Timestamp(update1.getWhen().getTime()), "comment 1", (short) 1, rev); new Timestamp(update1.getWhen().getTime()), "comment 1",
(short) 1, rev, false);
update1.putComment(Status.PUBLISHED, comment1); update1.putComment(Status.PUBLISHED, comment1);
ChangeUpdate update2 = newUpdate(c, otherUser); ChangeUpdate update2 = newUpdate(c, otherUser);
Comment comment2 = newComment(c.currentPatchSetId(), "filename", Comment comment2 = newComment(c.currentPatchSetId(), "filename",
"uuid2", range, range.getEndLine(), otherUser, null, "uuid2", range, range.getEndLine(), otherUser, null,
new Timestamp(update2.getWhen().getTime()), "comment 2", (short) 1, rev); new Timestamp(update2.getWhen().getTime()), "comment 2",
(short) 1, rev, false);
update2.putComment(Status.PUBLISHED, comment2); update2.putComment(Status.PUBLISHED, comment2);
try (NoteDbUpdateManager manager = updateManagerFactory.create(project)) { try (NoteDbUpdateManager manager = updateManagerFactory.create(project)) {
@@ -2527,7 +2620,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
Comment comment = newComment(update.getPatchSetId(), "filename", Comment comment = newComment(update.getPatchSetId(), "filename",
"uuid", range, range.getEndLine(), changeOwner, null, "uuid", range, range.getEndLine(), changeOwner, null,
new Timestamp(update.getWhen().getTime()), "comment", (short) 1, new Timestamp(update.getWhen().getTime()), "comment", (short) 1,
"abcd1234abcd1234abcd1234abcd1234abcd1234"); "abcd1234abcd1234abcd1234abcd1234abcd1234", false);
update.putComment(Status.PUBLISHED, comment); update.putComment(Status.PUBLISHED, comment);
update.commit(); update.commit();