DATAREDIS-803 - Polishing.

Remove DefaultRedisMapEntry as it's no longer required. Simplify test to unit test to reduce test scope and test run time.

Original pull request: #326.
This commit is contained in:
Mark Paluch
2018-04-09 09:23:14 +02:00
parent 8ed4703d46
commit 3e9d610228
3 changed files with 60 additions and 57 deletions

View File

@@ -25,7 +25,6 @@ import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
@@ -84,7 +83,7 @@ public abstract class AbstractRedisMapTests<K, V> {
abstract RedisMap<K, V> createMap();
@Before
public void setUp() throws Exception {
public void setUp() {
map = createMap();
}
@@ -398,27 +397,6 @@ public abstract class AbstractRedisMapTests<K, V> {
assertThat(values, not(hasItem(v2)));
}
@Test // DATAREDIS-803
@IfProfileValue(name = "runLongTests", value = "true")
public void testBigEntrySet() {
Set<Entry<K, V>> entries = map.entrySet();
assertTrue(entries.isEmpty());
for (int j = 0; j < 2; j++) {
Map<K, V> m = new HashMap<>();
for (int i = 0; i < 1024 * 1024 / 2 - 1; i++) {
m.put(getKey(), getValue());
}
map.putAll(m);
}
map.put(getKey(), getValue());
entries = map.entrySet();
assertEquals(1024 * 1024 - 1, entries.size());
}
@Test
public void testPutIfAbsent() {

View File

@@ -0,0 +1,58 @@
/*
* Copyright 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.support.collections;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import java.util.Collections;
import java.util.Map.Entry;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.data.redis.core.BoundHashOperations;
/**
* Unit tests for {@link DefaultRedisMap}.
*
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
public class DefaultRedisMapUnitUnitTests {
@Mock BoundHashOperations<String, String, String> operationsMock;
DefaultRedisMap<String, String> map;
@Before
public void before() {
map = new DefaultRedisMap<>(operationsMock);
}
@Test // DATAREDIS-803
public void shouldGetEntrySet() {
when(operationsMock.entries()).thenReturn(Collections.singletonMap("foo", "bar"));
Set<Entry<String, String>> result = map.entrySet();
assertThat(result).hasSize(1);
}
}