use of org.eclipse.jgit.util.MutableInteger in project gerrit by GerritCodeReview.
the class ExternalIdIT method insertInvalidButParsableExternalIds.
private Set<ConsistencyProblemInfo> insertInvalidButParsableExternalIds() throws IOException, ConfigInvalidException, OrmException {
MutableInteger i = new MutableInteger();
String scheme = "invalid";
ExternalIdsUpdate u = extIdsUpdate.create();
Set<ConsistencyProblemInfo> expectedProblems = new HashSet<>();
ExternalId extIdForNonExistingAccount = createExternalIdForNonExistingAccount(nextId(scheme, i));
u.insert(extIdForNonExistingAccount);
expectedProblems.add(consistencyError("External ID '" + extIdForNonExistingAccount.key().get() + "' belongs to account that doesn't exist: " + extIdForNonExistingAccount.accountId().get()));
ExternalId extIdWithInvalidEmail = createExternalIdWithInvalidEmail(nextId(scheme, i));
u.insert(extIdWithInvalidEmail);
expectedProblems.add(consistencyError("External ID '" + extIdWithInvalidEmail.key().get() + "' has an invalid email: " + extIdWithInvalidEmail.email()));
ExternalId extIdWithDuplicateEmail = createExternalIdWithDuplicateEmail(nextId(scheme, i));
u.insert(extIdWithDuplicateEmail);
expectedProblems.add(consistencyError("Email '" + extIdWithDuplicateEmail.email() + "' is not unique, it's used by the following external IDs: '" + extIdWithDuplicateEmail.key().get() + "', 'mailto:" + extIdWithDuplicateEmail.email() + "'"));
ExternalId extIdWithBadPassword = createExternalIdWithBadPassword("admin-username");
u.insert(extIdWithBadPassword);
expectedProblems.add(consistencyError("External ID '" + extIdWithBadPassword.key().get() + "' has an invalid password: unrecognized algorithm"));
return expectedProblems;
}
use of org.eclipse.jgit.util.MutableInteger in project gerrit by GerritCodeReview.
the class ExternalIdIT method insertValidExternalIds.
private void insertValidExternalIds() throws IOException, ConfigInvalidException, OrmException {
MutableInteger i = new MutableInteger();
String scheme = "valid";
ExternalIdsUpdate u = extIdsUpdate.create();
// create valid external IDs
u.insert(ExternalId.createWithPassword(ExternalId.Key.parse(nextId(scheme, i)), admin.id, "admin.other@example.com", "secret-password"));
u.insert(createExternalIdWithOtherCaseEmail(nextId(scheme, i)));
}
use of org.eclipse.jgit.util.MutableInteger in project gerrit by GerritCodeReview.
the class ChangeNoteUtil method parseNote.
public List<Comment> parseNote(byte[] note, MutableInteger p, Change.Id changeId) throws ConfigInvalidException {
if (p.value >= note.length) {
return ImmutableList.of();
}
Set<Comment.Key> seen = new HashSet<>();
List<Comment> result = new ArrayList<>();
int sizeOfNote = note.length;
byte[] psb = PATCH_SET.getBytes(UTF_8);
byte[] bpsb = BASE_PATCH_SET.getBytes(UTF_8);
byte[] bpn = PARENT_NUMBER.getBytes(UTF_8);
RevId revId = new RevId(parseStringField(note, p, changeId, REVISION));
String fileName = null;
PatchSet.Id psId = null;
boolean isForBase = false;
Integer parentNumber = null;
while (p.value < sizeOfNote) {
boolean matchPs = match(note, p, psb);
boolean matchBase = match(note, p, bpsb);
if (matchPs) {
fileName = null;
psId = parsePsId(note, p, changeId, PATCH_SET);
isForBase = false;
} else if (matchBase) {
fileName = null;
psId = parsePsId(note, p, changeId, BASE_PATCH_SET);
isForBase = true;
if (match(note, p, bpn)) {
parentNumber = parseParentNumber(note, p, changeId);
}
} else if (psId == null) {
throw parseException(changeId, "missing %s or %s header", PATCH_SET, BASE_PATCH_SET);
}
Comment c = parseComment(note, p, fileName, psId, revId, isForBase, parentNumber);
fileName = c.key.filename;
if (!seen.add(c.key)) {
throw parseException(changeId, "multiple comments for %s in note", c.key);
}
result.add(c);
}
return result;
}
use of org.eclipse.jgit.util.MutableInteger in project gerrit by GerritCodeReview.
the class ChangeRevisionNote method parse.
@Override
protected List<Comment> parse(byte[] raw, int offset) throws IOException, ConfigInvalidException {
MutableInteger p = new MutableInteger();
p.value = offset;
if (isJson(raw, p.value)) {
RevisionNoteData data = parseJson(noteUtil, raw, p.value);
if (status == PatchLineComment.Status.PUBLISHED) {
pushCert = data.pushCert;
} else {
pushCert = null;
}
return data.comments;
}
if (status == PatchLineComment.Status.PUBLISHED) {
pushCert = parsePushCert(changeId, raw, p);
trimLeadingEmptyLines(raw, p);
} else {
pushCert = null;
}
return noteUtil.parseNote(raw, p, changeId);
}
use of org.eclipse.jgit.util.MutableInteger in project gerrit by GerritCodeReview.
the class RevisionNote method parse.
public void parse() throws IOException, ConfigInvalidException {
raw = reader.open(noteId, OBJ_BLOB).getCachedBytes(MAX_NOTE_SZ);
MutableInteger p = new MutableInteger();
trimLeadingEmptyLines(raw, p);
if (p.value >= raw.length) {
comments = ImmutableList.of();
return;
}
comments = ImmutableList.copyOf(parse(raw, p.value));
}
Aggregations