Skip to content

Commit

Permalink
Merge branch 'MarquezProject:main' into web/add_dataset_drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsharp7 authored Nov 29, 2023
2 parents 7790bc1 + d578a3f commit 45120ec
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
10 changes: 2 additions & 8 deletions clients/java/src/main/java/marquez/client/MarquezPathV1.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
package marquez.client;

import com.google.common.annotations.VisibleForTesting;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import com.google.common.net.UrlEscapers;
import java.util.Arrays;
import java.util.Iterator;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -57,11 +55,7 @@ Converts path template (prepended with BASE_PATH), where path parts are separate
}

static String encode(String input) {
try {
return URLEncoder.encode(input, StandardCharsets.UTF_8.toString());
} catch (UnsupportedEncodingException e) {
throw new MarquezClientException(e);
}
return UrlEscapers.urlPathSegmentEscaper().escape(input);
}

static String listNamespacesPath() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void testClient_preservesBaseURL() throws Exception {
public void testClient_properlyFormatsNamespaces() throws Exception {
final String pathTemplate = "/namespaces/%s";
final String pathArg = "database://localhost:1234";
final String path = "/namespaces/database%3A%2F%2Flocalhost%3A1234";
final String path = "/namespaces/database:%2F%2Flocalhost:1234";

URL expected = new URL(BASE_URL + BASE_PATH + path);
URL actual = marquezUrl.from(path(pathTemplate, pathArg));
Expand Down
25 changes: 17 additions & 8 deletions clients/java/src/test/java/marquez/client/MarquezPathV1Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,26 @@ void testPath_namespaceUrl(String expected, String namespaceName) {

private static Stream<Arguments> testPath_namespaceUrl() {
return Stream.of(
Arguments.of("/api/v1/namespaces/s3%3A%2F%2Fbucket", "s3://bucket"),
Arguments.of("/api/v1/namespaces/bigquery%3A", "bigquery:"),
Arguments.of("/api/v1/namespaces/s3:%2F%2Fbucket", "s3://bucket"),
Arguments.of("/api/v1/namespaces/bigquery:", "bigquery:"),
Arguments.of("/api/v1/namespaces/usual-namespace-name", "usual-namespace-name"),
Arguments.of("/api/v1/namespaces/a%3A%5C%3Aa", "a:\\:a"));
Arguments.of("/api/v1/namespaces/a:%5C:a", "a:\\:a"));
}

@Test
void testPath_datasetUrl() {
Assertions.assertEquals(
"/api/v1/namespaces/s3%3A%2F%2Fbuckets/datasets/source-file.json",
MarquezPathV1.datasetPath("s3://buckets", "source-file.json"));
@ParameterizedTest
@MethodSource
void testPath_datasetUrl(String expected, String namespaceName, String datasetName) {
Assertions.assertEquals(expected, MarquezPathV1.datasetPath(namespaceName, datasetName));
}

private static Stream<Arguments> testPath_datasetUrl() {
return Stream.of(
Arguments.of(
"/api/v1/namespaces/s3:%2F%2Fbucket/datasets/source-file.json",
"s3://bucket", "source-file.json"),
Arguments.of(
"/api/v1/namespaces/snowflake:%2F%2Faccount/datasets/DATABASE.SCHEMA.%22Exotic%20Table%20Name!%22",
"snowflake://account", "DATABASE.SCHEMA.\"Exotic Table Name!\""));
}

@Test
Expand Down

0 comments on commit 45120ec

Please sign in to comment.