}
@Test
public void testGetSummaries() {
String role1 = "role1";
IJobKey job1 = JobKeys.from(role1, "env", "name1");
IJobKey job2 = JobKeys.from(role1, "env", "name2");
IJobKey job3 = JobKeys.from(role1, "env", "name3");
IJobKey job4 = JobKeys.from(role1, "env", "name4");
IJobKey job5 = JobKeys.from("role", "env", "name5");
IJobUpdateSummary s1 =
saveSummary(job1, "u1", 1230L, ROLLED_BACK, "user", Optional.of("lock1"));
IJobUpdateSummary s2 = saveSummary(job2, "u2", 1231L, ABORTED, "user", Optional.of("lock2"));
IJobUpdateSummary s3 = saveSummary(job3, "u3", 1239L, ERROR, "user2", Optional.of("lock3"));
IJobUpdateSummary s4 =
saveSummary(job4, "u4", 1234L, ROLL_BACK_PAUSED, "user3", Optional.of("lock4"));
IJobUpdateSummary s5 =
saveSummary(job5, "u5", 1235L, ROLLING_FORWARD, "user4", Optional.of("lock5"));
// Test empty query returns all.
assertEquals(ImmutableList.of(s3, s5, s4, s2, s1), getSummaries(new JobUpdateQuery()));
// Test query by updateId.
assertEquals(ImmutableList.of(s1), getSummaries(new JobUpdateQuery().setUpdateId("u1")));
// Test query by role.
assertEquals(
ImmutableList.of(s3, s4, s2, s1),
getSummaries(new JobUpdateQuery().setRole(role1)));
// Test query by job key.
assertEquals(
ImmutableList.of(s5),
getSummaries(new JobUpdateQuery().setJobKey(job5.newBuilder())));
// Test query by user.
assertEquals(ImmutableList.of(s2, s1), getSummaries(new JobUpdateQuery().setUser("user")));
// Test query by one status.