Skip to content

Commit

Permalink
redis: add test for serializing a raw collection
Browse files Browse the repository at this point in the history
  • Loading branch information
quanticc committed Apr 17, 2023
1 parent 3f3175b commit 69dc003
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ext {
jackson_version = '2.12.4'
commons_lang_version = '3.12.0'
testcontainers_version = '1.15.3'
assertj_version = '3.24.2'

isJitpack = "true" == System.getenv("JITPACK")
isRelease = !version.toString().endsWith('-SNAPSHOT')
Expand Down
1 change: 1 addition & 0 deletions redis/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies {

testImplementation project(':tck')
testImplementation "org.testcontainers:testcontainers:$testcontainers_version"
testImplementation "org.assertj:assertj-core:$assertj_version"
}

javadoc {
Expand Down
16 changes: 16 additions & 0 deletions redis/src/test/java/discord4j/store/redis/SerializerTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@

package discord4j.store.redis;

import discord4j.discordjson.Id;
import discord4j.store.api.util.LongLongTuple2;
import org.assertj.core.api.Assertions;
import org.junit.Test;

import java.util.HashSet;
import java.util.Set;

import static org.junit.Assert.assertEquals;

public class SerializerTests {
Expand Down Expand Up @@ -49,4 +54,15 @@ public void testStringSerializers() {
assertEquals(k2, s2.deserialize(s2.serialize(k2)));
assertEquals(k3, s3.deserialize(s3.serialize(k3)));
}

@SuppressWarnings({"rawtypes", "unchecked"})
@Test
public void testRawTypeSerializer() {
RedisSerializer<Set> rawSerializer = RedisStoreDefaults.jacksonValueSerializerFactory().create(Set.class);
Set rawSet = new HashSet();
rawSet.add(Id.of("123456789012345678").asLong());
byte[] written = rawSerializer.serialize(rawSet);
Set read = rawSerializer.deserialize(written);
Assertions.assertThat(rawSet).hasSameElementsAs(read);
}
}

0 comments on commit 69dc003

Please sign in to comment.