From 04b5522e7f594060b53cc0ef0f02ce75bb3d44f9 Mon Sep 17 00:00:00 2001
From: Jon Michael Aanes <jon.michael.aanes@secata.com>
Date: Thu, 27 Feb 2025 17:13:47 +0100
Subject: [PATCH] Substitute out links

---
 standardize_test_format/__init__.py | 10 +++++++---
 test/test_standardize.py            | 18 ++++++++++++++++++
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/standardize_test_format/__init__.py b/standardize_test_format/__init__.py
index 41b0d08..ab13f2c 100644
--- a/standardize_test_format/__init__.py
+++ b/standardize_test_format/__init__.py
@@ -39,9 +39,11 @@ def to_camel_case(description: str) -> str:
     description = description.strip(' \t.').replace(',',' ')
     words = description.split(' ')
 
-    words[0] = words[0].lower()
+    words[0] = words[0][0].lower() + words[0][1:]
     for i in range(1, len(words)):
-        words[i] = words[i].capitalize()
+        if words[i] == '':
+            continue
+        words[i] = words[i][0].upper() + words[i][1:]
 
     return ''.join(words)
 
@@ -51,7 +53,9 @@ def from_camel_case(name: str) -> str:
 def parse_javadoc_to_description(text: str| None):
     if text is None:
         return ''
-    return re.sub(r'\n\s*\*', ' ', text).strip()
+    text = re.sub(r'\n\s*\*', ' ', text).strip()
+    text = re.sub(r'\{@link\s+(\w+)\}', r'\1', text)
+    return text
 
 def replace_test_pattern(match: re.Match, with_javadoc: bool, with_display_name: bool) -> str:
     javadoc = parse_javadoc_to_description(match.group('javadoc'))
diff --git a/test/test_standardize.py b/test/test_standardize.py
index 3ae78fb..4e3f048 100644
--- a/test/test_standardize.py
+++ b/test/test_standardize.py
@@ -52,6 +52,21 @@ OUTPUT_4 = """
 public void concatTwoProducesANewArrayWithTheTwoInputArraysJoinedTogetherWithNoSeparators()
 """
 
+INPUT_5 = """
+/**
+ * {@link ZkBinderContextImpl} propagates a lot of fields directly from the underlying {@link
+ * ZkBinderContext}.
+ */
+@Test
+public void propagate()
+"""
+
+OUTPUT_5 = """
+@Test
+@DisplayName("ZkBinderContextImpl propagates a lot of fields directly from the underlying ZkBinderContext")
+public void zkBinderContextImplPropagatesALotOfFieldsDirectlyFromTheUnderlyingZkBinderContext()
+"""
+
 
 def test_javadoc_parsing():
     assert re.match(PATTERN_JAVADOC, '/** Hello World */') is not None
@@ -71,3 +86,6 @@ def test_3():
 def test_4():
     assert standardize_java_text(INPUT_4.strip(),False,True) == OUTPUT_4.strip()
 
+def test_5():
+    assert standardize_java_text(INPUT_5.strip(),False,True) == OUTPUT_5.strip()
+