Skip to content

Commit

Permalink
PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagohora committed Dec 2, 2024
1 parent f46c6a6 commit 85195d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.comet.opik.infrastructure;

import com.comet.opik.infrastructure.redis.RedisUrlParser;
import com.comet.opik.infrastructure.redis.RedisUrl;
import com.comet.opik.utils.JsonUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.Valid;
Expand All @@ -20,7 +20,7 @@ public class RedisConfig {
public Config build() {
Config config = new Config();

var redisUrl = RedisUrlParser.parse(singleNodeUrl);
var redisUrl = RedisUrl.parse(singleNodeUrl);

Objects.requireNonNull(singleNodeUrl, "singleNodeUrl must not be null");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import java.net.URI;
import java.net.URISyntaxException;

public record RedisUrlParser(String scheme, String host, int port, int database) {
public record RedisUrl(String scheme, String host, int port, int database) {

public static RedisUrlParser parse(String redisUrl) {
public static RedisUrl parse(String redisUrl) {
try {
URI uri = new URI(redisUrl);
String scheme = uri.getScheme();
Expand All @@ -18,7 +18,7 @@ public static RedisUrlParser parse(String redisUrl) {
database = getDatabase(path);
}

return new RedisUrlParser(scheme, host, port, database);
return new RedisUrl(scheme, host, port, database);
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;

@DisplayName("Redis URL parser Unit Test")
class RedisUrlParserTest {
class RedisUrlTest {

public static Stream<Arguments> testRedisUrlParser() {
return Stream.of(
Expand All @@ -26,12 +26,12 @@ public static Stream<Arguments> testRedisUrlParser() {
@MethodSource
@DisplayName("Test parse method with different URLs")
void testRedisUrlParser(String redisUrl, String scheme, String host, int port, int database) {
RedisUrlParser redisUrlParser = RedisUrlParser.parse(redisUrl);
RedisUrl redisUrlParser = RedisUrl.parse(redisUrl);

assertEquals(scheme, redisUrlParser.scheme());
assertEquals(host, redisUrlParser.host());
assertEquals(port, redisUrlParser.port());
assertEquals(database, redisUrlParser.database());
assertThat(scheme).isEqualTo(redisUrlParser.scheme());
assertThat(host).isEqualTo(redisUrlParser.host());
assertThat(port).isEqualTo(redisUrlParser.port());
assertThat(database).isEqualTo(redisUrlParser.database());
}

}
}

0 comments on commit 85195d7

Please sign in to comment.