Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<parent>
<groupId>io.split.client</groupId>
<artifactId>java-client-parent</artifactId>
<version>4.18.1</version>
<version>4.18.2</version>
</parent>
<version>4.18.1</version>
<version>4.18.2</version>
<artifactId>java-client</artifactId>
<packaging>jar</packaging>
<name>Java Client</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,34 @@ public void testGetAll() {
Mockito.verify(_userStorageWrapper, Mockito.times(1)).getMany(Mockito.anyObject());
}

@Test
public void testGetSplitNames() {
Split split = getSplit(SPLIT_NAME);
Split split2 = getSplit(SPLIT_NAME+"2");
List<Split> listResultExpected = Stream.of(split, split2).collect(Collectors.toList());
Set<String> keysResult = Stream.of(SPLIT_NAME, SPLIT_NAME+"2").collect(Collectors.toSet());
Mockito.when(_userStorageWrapper.getKeysByPrefix(Mockito.anyObject())).
thenReturn(keysResult);
List<String> splitsResult = _userCustomSplitAdapterConsumer.splitNames();
Assert.assertNotNull(splitsResult);
Assert.assertEquals(listResultExpected.size(), splitsResult.size());
Assert.assertEquals(SPLIT_NAME, splitsResult.get(1));
Assert.assertEquals(SPLIT_NAME+"2", splitsResult.get(0));
Mockito.verify(_userStorageWrapper, Mockito.times(1)).getKeysByPrefix(Mockito.anyString());

// default prefix
listResultExpected = Stream.of(split, split2).collect(Collectors.toList());
keysResult = Stream.of("SPLITIO.split." + SPLIT_NAME, "SPLITIO.split." + SPLIT_NAME+"2").collect(Collectors.toSet());
Mockito.when(_userStorageWrapper.getKeysByPrefix(Mockito.anyObject())).
thenReturn(keysResult);

splitsResult = _userCustomSplitAdapterConsumer.splitNames();
Assert.assertNotNull(splitsResult);
Assert.assertEquals(listResultExpected.size(), splitsResult.size());
Assert.assertEquals(SPLIT_NAME, splitsResult.get(1));
Assert.assertEquals(SPLIT_NAME+"2", splitsResult.get(0));
}

@Test
public void testGetAllWithWrapperFailing() {
Mockito.when(_userStorageWrapper.get(PrefixAdapter.buildGetAllSplit())).
Expand Down
4 changes: 2 additions & 2 deletions okhttp-modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<parent>
<artifactId>java-client-parent</artifactId>
<groupId>io.split.client</groupId>
<version>4.18.1</version>
<version>4.18.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>4.18.1</version>
<version>4.18.2</version>
<artifactId>okhttp-modules</artifactId>
<packaging>jar</packaging>
<name>http-modules</name>
Expand Down
2 changes: 1 addition & 1 deletion pluggable-storage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>java-client-parent</artifactId>
<groupId>io.split.client</groupId>
<version>4.18.1</version>
<version>4.18.2</version>
</parent>

<version>2.1.0</version>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.split.client</groupId>
<artifactId>java-client-parent</artifactId>
<version>4.18.1</version>
<version>4.18.2</version>
<dependencyManagement>
<dependencies>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions redis-wrapper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<parent>
<artifactId>java-client-parent</artifactId>
<groupId>io.split.client</groupId>
<version>4.18.1</version>
<version>4.18.2</version>
</parent>
<artifactId>redis-wrapper</artifactId>
<version>3.1.1</version>
<version>3.1.2</version>
<packaging>jar</packaging>
<name>Package for Redis Wrapper Implementation</name>
<description>Implements Redis Pluggable Storage</description>
Expand Down
4 changes: 3 additions & 1 deletion redis-wrapper/src/main/java/redis/RedisSingle.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ public String getAndSet(String key, String item) throws Exception {
public Set<String> getKeysByPrefix(String prefix) throws Exception {
try (Jedis jedis = this.jedisPool.getResource()) {
Set<String> keysWithPrefix = jedis.keys(_commonRedis.buildKeyWithPrefix(prefix));
keysWithPrefix = keysWithPrefix.stream().map(key -> key.replace(_commonRedis.getPrefix() + ".", "")).collect(Collectors.toSet());
if (!_commonRedis.getPrefix().isEmpty()) {
keysWithPrefix = keysWithPrefix.stream().map(key -> key.replace(_commonRedis.getPrefix() + ".", "")).collect(Collectors.toSet());
}
return keysWithPrefix;
} catch (Exception ex) {
throw new RedisException(ex.getMessage());
Expand Down
24 changes: 24 additions & 0 deletions redis-wrapper/src/test/java/redis/RedisSingleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,30 @@ public void testGetKeysByPrefix() throws Exception {
}
}

@Test
public void testGetKeysByPrefixWithoutCustomPrefix() throws Exception {
Map<String, String> map = new HashMap<>();
map.put("SPLITIO.item-1", "1");
map.put("SPLITIO.item-2", "2");
map.put("SPLITIO.item-3", "3");
map.put("SPLITIO.i-4", "4");
RedisSingle storageWrapper = new RedisSingle(new JedisPool(), "");
try {
for (Map.Entry<String, String> entry : map.entrySet()) {
storageWrapper.set(entry.getKey(), entry.getValue());
}

Set<String> result = storageWrapper.getKeysByPrefix("SPLITIO.item*");

Assert.assertEquals(3, result.size());
Assert.assertTrue(result.contains("SPLITIO.item-1"));
Assert.assertTrue(result.contains("SPLITIO.item-2"));
Assert.assertTrue(result.contains("SPLITIO.item-3"));
} finally {
storageWrapper.delete(new ArrayList<>(map.keySet()));
}
}

@Test
public void testIncrementAndDecrement() throws Exception {
Map<String, String> map = new HashMap<>();
Expand Down
4 changes: 2 additions & 2 deletions testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<parent>
<groupId>io.split.client</groupId>
<artifactId>java-client-parent</artifactId>
<version>4.18.1</version>
<version>4.18.2</version>
</parent>
<artifactId>java-client-testing</artifactId>
<packaging>jar</packaging>
<version>4.18.1</version>
<version>4.18.2</version>
<name>Java Client For Testing</name>
<description>Testing suite for Java SDK for Split</description>
<dependencies>
Expand Down