Merge pull request #669 from stianst/master
Fix AccountTest.viewLog test
This commit is contained in:
commit
3bc27ef366
1 changed files with 22 additions and 23 deletions
|
@ -368,44 +368,43 @@ public class AccountTest {
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<Event> e = new LinkedList<Event>();
|
List<Event> expectedEvents = new LinkedList<Event>();
|
||||||
|
|
||||||
loginPage.open();
|
loginPage.open();
|
||||||
loginPage.clickRegister();
|
loginPage.clickRegister();
|
||||||
|
|
||||||
registerPage.register("view", "log", "view-log@localhost", "view-log", "password", "password");
|
registerPage.register("view", "log", "view-log@localhost", "view-log", "password", "password");
|
||||||
|
|
||||||
e.add(events.poll());
|
expectedEvents.add(events.poll());
|
||||||
e.add(events.poll());
|
expectedEvents.add(events.poll());
|
||||||
|
|
||||||
profilePage.open();
|
profilePage.open();
|
||||||
profilePage.updateProfile("view", "log2", "view-log@localhost");
|
profilePage.updateProfile("view", "log2", "view-log@localhost");
|
||||||
|
|
||||||
e.add(events.poll());
|
expectedEvents.add(events.poll());
|
||||||
|
|
||||||
logPage.open();
|
logPage.open();
|
||||||
|
|
||||||
Collections.reverse(e);
|
|
||||||
|
|
||||||
Assert.assertTrue(logPage.isCurrent());
|
Assert.assertTrue(logPage.isCurrent());
|
||||||
Thread.sleep(100); // seems to be some kind of race here.
|
|
||||||
final int expectedEvents = e.size();
|
|
||||||
Retry.execute(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Assert.assertEquals(expectedEvents, logPage.getEvents().size());
|
|
||||||
}
|
|
||||||
}, 10, 500);
|
|
||||||
|
|
||||||
Iterator<List<String>> itr = logPage.getEvents().iterator();
|
List<List<String>> actualEvents = logPage.getEvents();
|
||||||
for (Event event : e) {
|
|
||||||
List<String> a = itr.next();
|
Assert.assertEquals(expectedEvents.size(), actualEvents.size());
|
||||||
Assert.assertEquals(event.getType().toString().replace('_', ' ').toLowerCase(), a.get(1));
|
|
||||||
Assert.assertEquals(event.getIpAddress(), a.get(2));
|
for (Event e : expectedEvents) {
|
||||||
Assert.assertEquals(event.getClientId(), a.get(3));
|
boolean match = false;
|
||||||
|
for (List<String> a : logPage.getEvents()) {
|
||||||
|
if (e.getType().toString().replace('_', ' ').toLowerCase().equals(a.get(1)) &&
|
||||||
|
e.getIpAddress().equals(a.get(2)) &&
|
||||||
|
e.getClientId().equals(a.get(3))) {
|
||||||
|
match = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!match) {
|
||||||
|
Assert.fail("Event not found " + e.getType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
} finally {
|
||||||
keycloakRule.update(new KeycloakSetup() {
|
keycloakRule.update(new KeycloakSetup() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue