use of com.google.gerrit.server.data.RefUpdateAttribute in project gerrit by GerritCodeReview.
the class EventFactory method asRefUpdateAttribute.
/**
* Create a RefUpdateAttribute for the given old ObjectId, new ObjectId, and branch that is
* suitable for serialization to JSON.
*
* @param oldId
* @param newId
* @param refName
* @return object suitable for serialization to JSON
*/
public RefUpdateAttribute asRefUpdateAttribute(ObjectId oldId, ObjectId newId, Branch.NameKey refName) {
RefUpdateAttribute ru = new RefUpdateAttribute();
ru.newRev = newId != null ? newId.getName() : ObjectId.zeroId().getName();
ru.oldRev = oldId != null ? oldId.getName() : ObjectId.zeroId().getName();
ru.project = refName.getParentKey().get();
ru.refName = refName.get();
return ru;
}
use of com.google.gerrit.server.data.RefUpdateAttribute in project gerrit by GerritCodeReview.
the class EventRecorder method assertRefUpdatedEvents.
public void assertRefUpdatedEvents(String project, String branch, String... expected) throws Exception {
ImmutableList<RefUpdatedEvent> events = getRefUpdatedEvents(project, branch, expected.length / 2);
int i = 0;
for (RefUpdatedEvent event : events) {
RefUpdateAttribute actual = event.refUpdate.get();
String oldRev = expected[i] == null ? ObjectId.zeroId().name() : expected[i];
String newRev = expected[i + 1] == null ? ObjectId.zeroId().name() : expected[i + 1];
assertThat(actual.oldRev).isEqualTo(oldRev);
assertThat(actual.newRev).isEqualTo(newRev);
i += 2;
}
}
use of com.google.gerrit.server.data.RefUpdateAttribute in project gerrit by GerritCodeReview.
the class EventJsonTest method refUpdatedEvent.
@Test
public void refUpdatedEvent() {
RefUpdatedEvent event = new RefUpdatedEvent();
RefUpdateAttribute refUpdatedAttribute = new RefUpdateAttribute();
refUpdatedAttribute.refName = REF;
event.refUpdate = createSupplier(refUpdatedAttribute);
event.submitter = newAccount("submitter");
assertThatJsonMap(event).isEqualTo(ImmutableMap.builder().put("submitter", ImmutableMap.builder().put("name", event.submitter.get().name).put("email", event.submitter.get().email).put("username", event.submitter.get().username).build()).put("refUpdate", ImmutableMap.of("refName", REF)).put("type", "ref-updated").put("eventCreatedOn", TS1).build());
}
use of com.google.gerrit.server.data.RefUpdateAttribute in project gerrit by GerritCodeReview.
the class EventDeserializerTest method refUpdatedEvent.
@Test
public void refUpdatedEvent() {
RefUpdatedEvent orig = new RefUpdatedEvent();
RefUpdateAttribute refUpdatedAttribute = new RefUpdateAttribute();
refUpdatedAttribute.refName = "refs/heads/master";
orig.refUpdate = createSupplier(refUpdatedAttribute);
AccountAttribute accountAttribute = new AccountAttribute();
accountAttribute.email = "some.user@domain.com";
orig.submitter = createSupplier(accountAttribute);
RefUpdatedEvent e = roundTrip(orig);
assertThat(e).isNotNull();
assertThat(e.refUpdate).isInstanceOf(Supplier.class);
assertThat(e.refUpdate.get().refName).isEqualTo(refUpdatedAttribute.refName);
assertThat(e.submitter).isInstanceOf(Supplier.class);
assertThat(e.submitter.get().email).isEqualTo(accountAttribute.email);
}
use of com.google.gerrit.server.data.RefUpdateAttribute in project gerrit by GerritCodeReview.
the class EventRecorder method assertRefUpdatedEvents.
public void assertRefUpdatedEvents(String project, String branch, RevCommit... expected) throws Exception {
ImmutableList<RefUpdatedEvent> events = getRefUpdatedEvents(project, branch, expected.length / 2);
int i = 0;
for (RefUpdatedEvent event : events) {
RefUpdateAttribute actual = event.refUpdate.get();
String oldRev = expected[i] == null ? ObjectId.zeroId().name() : expected[i].name();
String newRev = expected[i + 1] == null ? ObjectId.zeroId().name() : expected[i + 1].name();
assertThat(actual.oldRev).isEqualTo(oldRev);
assertThat(actual.newRev).isEqualTo(newRev);
i += 2;
}
}
Aggregations