From cec72b6a66bb9bc6eeb36edb36e1cf05180fa242 Mon Sep 17 00:00:00 2001 From: elijahgrimaldi <114044477+elijahgrimaldi@users.noreply.github.com> Date: Fri, 3 Nov 2023 16:42:39 -0700 Subject: [PATCH] Added tests for function parseCommaSeparatedStringMapFromString with valid and invalid JSON arguments --- .../com/linkedin/venice/utils/UtilsTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/internal/venice-common/src/test/java/com/linkedin/venice/utils/UtilsTest.java b/internal/venice-common/src/test/java/com/linkedin/venice/utils/UtilsTest.java index baa069c4a4..89e0074451 100644 --- a/internal/venice-common/src/test/java/com/linkedin/venice/utils/UtilsTest.java +++ b/internal/venice-common/src/test/java/com/linkedin/venice/utils/UtilsTest.java @@ -183,4 +183,21 @@ public void testParseMap() { public void testSanitizingStringForLogger() { Assert.assertEquals(Utils.getSanitizedStringForLogger(".abc.123."), "_abc_123_"); } + + @Test + public void testParseCommaSeparatedStringMapFromString() { + try { + Utils.parseCommaSeparatedStringMapFromString( + "{\"changeCaptureView\": {\"viewClassName\": \"com.linkedin.venice.views.ChangeCaptureView\",\"params\": {}}}", + "someField"); // Method that should not throw an exception + } catch (Exception e) { + fail("Expected no exception to be thrown, but got: " + e.getMessage()); + } + + Assert.assertThrows( + VeniceException.class, + () -> Utils.parseCommaSeparatedStringMapFromString( + "{\"changeCaptureView\": {\"viewClassName\": \"com.linkedin.venice.views.ChangeCaptureView\",\"params\":", + "someField")); + } }