@Test
public void testFlashScope() throws Exception {
MockApplication<?> app = application("plugin.controller.scope.flash").init();
//
MockClient client = app.client();
//
client.render();
long id1 = Registry.<Long>unset("car");
int status = Registry.<Integer>unset("status");
assertEquals(Identifiable.MANAGED, status);
assertEquals(1, client.getFlashHistory(1).size());
Identifiable car1 = (Identifiable)client.getFlashHistory(1).iterator().next().get();
assertEquals(car1.getIdentityHashCode(), id1);
assertEquals(Identifiable.DESTROYED, car1.getStatus());
//
client.invoke(Registry.<String>unset("action"));
long id2 = Registry.<Long>unset("car");
status = Registry.<Integer>unset("status");
assertEquals(Identifiable.MANAGED, status);
assertNotSame(id1, id2);
assertEquals(1, client.getFlashHistory(0).size());
Identifiable car2 = (Identifiable)client.getFlashHistory(0).iterator().next().get();
assertNotSame(car1, car2);
assertEquals(Identifiable.MANAGED, car2.getStatus());
//
client.render();
long id3 = Registry.<Long>unset("car");
status = Registry.<Integer>unset("status");
assertEquals(Identifiable.MANAGED, status);
assertEquals(id2, id3);
assertEquals(1, client.getFlashHistory(1).size());
Identifiable car3 = (Identifiable)client.getFlashHistory(1).iterator().next().get();
assertSame(car2, car3);
assertEquals(Identifiable.DESTROYED, car2.getStatus());
}