mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1427 - QueryCache should be cleared, if one of a dependent bean is updated
Initial work, does not include propagation across cluster.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package io.ebeaninternal.server.transaction;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class TableModStateTest {
|
||||
|
||||
private TableModState tableModState = new TableModState();
|
||||
|
||||
@Test
|
||||
public void isValid() {
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
tableModState.touch(setOf("one", "two", "three"), now);
|
||||
|
||||
// empty
|
||||
assertTrue(tableModState.isValid(Collections.emptySet(), 12L));
|
||||
|
||||
// no entry
|
||||
assertTrue(tableModState.isValid(setOf("noEntry"), 12L));
|
||||
|
||||
// later timestamp
|
||||
assertTrue(tableModState.isValid(setOf("one"), now + 1));
|
||||
assertTrue(tableModState.isValid(setOf("one", "two", "noEntry"), now + 1));
|
||||
|
||||
// invalid
|
||||
assertFalse(tableModState.isValid(setOf("one"), now - 1));
|
||||
assertFalse(tableModState.isValid(setOf("one", "two"), now - 1));
|
||||
assertFalse(tableModState.isValid(setOf("three", "two"), now - 1));
|
||||
|
||||
}
|
||||
|
||||
private Set<String> setOf(String... tables) {
|
||||
Set<String> touched = new HashSet<>();
|
||||
Collections.addAll(touched, tables);
|
||||
return touched;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user