|
|
|
|
@@ -210,12 +210,26 @@ public class RedisKeyValueAdapterTests {
|
|
|
|
|
assertThat(template.opsForSet().members("persons:address.country:Andor"), hasItems("1"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test // DATAREDIS-425, DATAREDIS-744
|
|
|
|
|
@Test // DATAREDIS-425
|
|
|
|
|
public void getShouldReadSimpleObjectCorrectly() {
|
|
|
|
|
|
|
|
|
|
Map<String, String> map = new LinkedHashMap<>();
|
|
|
|
|
map.put("_class", Person.class.getName());
|
|
|
|
|
map.put("age", "24");
|
|
|
|
|
template.opsForHash().putAll("persons:load-1", map);
|
|
|
|
|
|
|
|
|
|
Object loaded = adapter.get("load-1", "persons");
|
|
|
|
|
|
|
|
|
|
assertThat(loaded, instanceOf(Person.class));
|
|
|
|
|
assertThat(((Person) loaded).age, is(24));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test // DATAREDIS-744
|
|
|
|
|
public void getShouldReadSimpleObjectWithColonInIdCorrectly() {
|
|
|
|
|
|
|
|
|
|
Map<String, String> map = new LinkedHashMap<String, String>();
|
|
|
|
|
map.put("_class", Person.class.getName());
|
|
|
|
|
map.put("age", "24");
|
|
|
|
|
template.opsForHash().putAll("persons:load-1:a", map);
|
|
|
|
|
|
|
|
|
|
Object loaded = adapter.get("load-1:a", "persons");
|
|
|
|
|
@@ -283,7 +297,7 @@ public class RedisKeyValueAdapterTests {
|
|
|
|
|
assertThat(template.opsForSet().members("persons:firstname:rand"), not(hasItem("1")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test // DATAREDIS-425, DATAREDIS-744
|
|
|
|
|
@Test // DATAREDIS-425
|
|
|
|
|
public void keyExpiredEventShouldRemoveHelperStructures() throws Exception {
|
|
|
|
|
|
|
|
|
|
assumeTrue(RedisTestProfileValueSource.matches("runLongTests", "true"));
|
|
|
|
|
@@ -293,6 +307,34 @@ public class RedisKeyValueAdapterTests {
|
|
|
|
|
map.put("firstname", "rand");
|
|
|
|
|
map.put("address.country", "Andor");
|
|
|
|
|
|
|
|
|
|
template.opsForHash().putAll("persons:1", map);
|
|
|
|
|
|
|
|
|
|
template.opsForSet().add("persons", "1");
|
|
|
|
|
template.opsForSet().add("persons:firstname:rand", "1");
|
|
|
|
|
template.opsForSet().add("persons:1:idx", "persons:firstname:rand");
|
|
|
|
|
|
|
|
|
|
template.expire("persons:1", 100, TimeUnit.MILLISECONDS);
|
|
|
|
|
|
|
|
|
|
waitUntilKeyIsGone(template, "persons:1");
|
|
|
|
|
waitUntilKeyIsGone(template, "persons:1:phantom");
|
|
|
|
|
waitUntilKeyIsGone(template, "persons:firstname:rand");
|
|
|
|
|
|
|
|
|
|
assertThat(template.hasKey("persons:1"), is(false));
|
|
|
|
|
assertThat(template.hasKey("persons:firstname:rand"), is(false));
|
|
|
|
|
assertThat(template.hasKey("persons:1:idx"), is(false));
|
|
|
|
|
assertThat(template.opsForSet().members("persons"), not(hasItem("1")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test // DATAREDIS-744
|
|
|
|
|
public void keyExpiredEventShouldRemoveHelperStructuresForObjectsWithColonInId() throws Exception {
|
|
|
|
|
|
|
|
|
|
assumeTrue(RedisTestProfileValueSource.matches("runLongTests", "true"));
|
|
|
|
|
|
|
|
|
|
Map<String, String> map = new LinkedHashMap<String, String>();
|
|
|
|
|
map.put("_class", Person.class.getName());
|
|
|
|
|
map.put("firstname", "rand");
|
|
|
|
|
map.put("address.country", "Andor");
|
|
|
|
|
|
|
|
|
|
template.opsForHash().putAll("persons:1:b", map);
|
|
|
|
|
|
|
|
|
|
template.opsForSet().add("persons", "1");
|
|
|
|
|
@@ -374,12 +416,31 @@ public class RedisKeyValueAdapterTests {
|
|
|
|
|
assertThat(template.opsForSet().isMember("persons:mat:idx", "persons:firstname:mat"), is(true));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test // DATAREDIS-471, DATAREDIS-744
|
|
|
|
|
@Test // DATAREDIS-471
|
|
|
|
|
public void updateShouldAlterIndexDataCorrectly() {
|
|
|
|
|
|
|
|
|
|
Person rand = new Person();
|
|
|
|
|
rand.firstname = "rand";
|
|
|
|
|
|
|
|
|
|
adapter.put("1", rand, "persons");
|
|
|
|
|
|
|
|
|
|
assertThat(template.hasKey("persons:firstname:rand"), is(true));
|
|
|
|
|
|
|
|
|
|
PartialUpdate<Person> update = new PartialUpdate<Person>("1", Person.class) //
|
|
|
|
|
.set("firstname", "mat");
|
|
|
|
|
|
|
|
|
|
adapter.update(update);
|
|
|
|
|
|
|
|
|
|
assertThat(template.hasKey("persons:firstname:rand"), is(false));
|
|
|
|
|
assertThat(template.hasKey("persons:firstname:mat"), is(true));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test // DATAREDIS-744
|
|
|
|
|
public void updateShouldAlterIndexDataForObjectsWithColonInIdCorrectly() {
|
|
|
|
|
|
|
|
|
|
Person rand = new Person();
|
|
|
|
|
rand.firstname = "rand";
|
|
|
|
|
|
|
|
|
|
adapter.put("1:a", rand, "persons");
|
|
|
|
|
|
|
|
|
|
assertThat(template.hasKey("persons:firstname:rand"), is(true));
|
|
|
|
|
|