Usage of long refactored to int in LinkedHashMapRemoveEldest class
Signed-off-by: Oleksandra Matviienko <al.zzzeebra@gmail.com>
This commit is contained in:
parent
dad0c1fb92
commit
1b0b10a15a
@ -489,7 +489,7 @@ public class ActorSystemContext {
|
||||
|
||||
@Value("${actors.session.max_concurrent_sessions_per_device:1}")
|
||||
@Getter
|
||||
private long maxConcurrentSessionsPerDevice;
|
||||
private int maxConcurrentSessionsPerDevice;
|
||||
|
||||
@Value("${actors.session.sync.timeout:10000}")
|
||||
@Getter
|
||||
|
||||
@ -34,10 +34,10 @@ import java.util.function.BiConsumer;
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class LinkedHashMapRemoveEldest<K, V> extends LinkedHashMap<K, V> {
|
||||
final long maxEntries;
|
||||
final int maxEntries;
|
||||
final BiConsumer<K, V> removalConsumer;
|
||||
|
||||
public LinkedHashMapRemoveEldest(long maxEntries, BiConsumer<K, V> removalConsumer) {
|
||||
public LinkedHashMapRemoveEldest(int maxEntries, BiConsumer<K, V> removalConsumer) {
|
||||
this.maxEntries = maxEntries;
|
||||
this.removalConsumer = removalConsumer;
|
||||
}
|
||||
|
||||
@ -27,10 +27,10 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
public class LinkedHashMapRemoveEldestTest {
|
||||
|
||||
public static final long MAX_ENTRIES = 10L;
|
||||
long removeCount = 0;
|
||||
public static final int MAX_ENTRIES = 10;
|
||||
int removeCount = 0;
|
||||
|
||||
void removalConsumer(Long id, String name) {
|
||||
void removalConsumer(Integer id, String name) {
|
||||
removeCount++;
|
||||
assertThat(id, is(Matchers.lessThan(MAX_ENTRIES)));
|
||||
assertThat(name, is(id.toString()));
|
||||
@ -39,7 +39,7 @@ public class LinkedHashMapRemoveEldestTest {
|
||||
@Test
|
||||
public void givenMap_whenOverSized_thenVerifyRemovedEldest() {
|
||||
//given
|
||||
LinkedHashMapRemoveEldest<Long, String> map =
|
||||
LinkedHashMapRemoveEldest<Integer, String> map =
|
||||
new LinkedHashMapRemoveEldest<>(MAX_ENTRIES, this::removalConsumer);
|
||||
|
||||
assertThat(map.getMaxEntries(), is(MAX_ENTRIES));
|
||||
@ -49,14 +49,14 @@ public class LinkedHashMapRemoveEldestTest {
|
||||
assertThat(map.size(), is(0));
|
||||
|
||||
//when
|
||||
for (long i = 0; i < MAX_ENTRIES * 2; i++) {
|
||||
for (int i = 0; i < MAX_ENTRIES * 2; i++) {
|
||||
map.put(i, String.valueOf(i));
|
||||
}
|
||||
|
||||
//then
|
||||
assertThat((long) map.size(), is(MAX_ENTRIES));
|
||||
assertThat( map.size(), is(MAX_ENTRIES));
|
||||
assertThat(removeCount, is(MAX_ENTRIES));
|
||||
for (long i = MAX_ENTRIES; i < MAX_ENTRIES * 2; i++) {
|
||||
for (int i = MAX_ENTRIES; i < MAX_ENTRIES * 2; i++) {
|
||||
assertThat(map.get(i), is(String.valueOf(i)));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user