Skip to content

Instantly share code, notes, and snippets.

@musketyr
Created March 10, 2026 15:20
Show Gist options
  • Select an option

  • Save musketyr/4a37c82569a45762ebf96aff75dc2c09 to your computer and use it in GitHub Desktop.

Select an option

Save musketyr/4a37c82569a45762ebf96aff75dc2c09 to your computer and use it in GitHub Desktop.
StringUtilsSpec → StringUtilsTest Migration Diff (sc188310)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>StringUtilsSpec → StringUtilsTest Migration Diff (sc188310)</title>
<style>
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; margin: 20px; background: #f6f8fa; }
h1 { color: #24292e; border-bottom: 1px solid #e1e4e8; padding-bottom: 10px; }
h2 { color: #0366d6; margin-top: 30px; }
.section { background: white; border: 1px solid #e1e4e8; border-radius: 6px; margin-bottom: 20px; overflow: hidden; }
.section-header { background: #f1f8ff; padding: 10px 15px; border-bottom: 1px solid #e1e4e8; font-weight: 600; }
.diff-container { display: flex; }
.diff-side { flex: 1; overflow-x: auto; }
.diff-side pre { margin: 0; padding: 15px; font-size: 13px; line-height: 1.5; background: #fafbfc; }
.spock { border-right: 1px solid #e1e4e8; }
.spock .label { background: #ffeef0; color: #cb2431; }
.junit .label { background: #e6ffed; color: #22863a; }
.label { display: inline-block; padding: 3px 8px; border-radius: 3px; font-size: 12px; font-weight: 600; margin-bottom: 10px; }
.highlight-remove { background: #ffeef0; }
.highlight-add { background: #e6ffed; }
code { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; }
.summary { background: #fff3cd; border: 1px solid #ffc107; border-radius: 6px; padding: 15px; margin-bottom: 20px; }
.summary h3 { margin-top: 0; color: #856404; }
.summary ul { margin-bottom: 0; }
</style>
</head>
<body>
<h1>🔄 StringUtilsSpec → StringUtilsTest Migration</h1>
<p><strong>Story:</strong> sc188310 | <strong>Epic:</strong> 188306 "Get rid of spock (analytics/commons)"</p>
<div class="summary">
<h3>📋 Migration Summary</h3>
<ul>
<li><strong>File:</strong> <code>lib-commons-utils</code> module</li>
<li><strong>Tests migrated:</strong> 4</li>
<li><strong>Mocks needed:</strong> None</li>
<li><strong>@TestFactory needed:</strong> No (no where: blocks)</li>
<li><strong>Framework:</strong> Spock → JUnit 5 + AssertJ</li>
</ul>
</div>
<h2>Test 1: shouldReturnNullIfTheStringIsNull</h2>
<div class="section">
<div class="diff-container">
<div class="diff-side spock">
<div class="section-header"><span class="label">SPOCK (removed)</span> StringUtilsSpec.groovy</div>
<pre><code class="highlight-remove">void 'should return null if the string is null'() {
given:
String str = null
when:
String actual = StringUtils.capitalize(str, Locale.ENGLISH)
then:
actual == null
}</code></pre>
</div>
<div class="diff-side junit">
<div class="section-header"><span class="label">JUNIT 5 (added)</span> StringUtilsTest.java</div>
<pre><code class="highlight-add">@Test
void shouldReturnNullIfTheStringIsNull() {
// given
String str = null;
// when
String actual = StringUtils.capitalize(str, Locale.ENGLISH);
// then
assertThat(actual).isNull();
}</code></pre>
</div>
</div>
</div>
<h2>Test 2: shouldReturnEmptyIfTheStringIsEmpty</h2>
<div class="section">
<div class="diff-container">
<div class="diff-side spock">
<div class="section-header"><span class="label">SPOCK (removed)</span> StringUtilsSpec.groovy</div>
<pre><code class="highlight-remove">void 'should return empty if the string is empty'() {
given:
String str = ''
when:
String actual = StringUtils.capitalize(str, Locale.ENGLISH)
then:
actual == ''
}</code></pre>
</div>
<div class="diff-side junit">
<div class="section-header"><span class="label">JUNIT 5 (added)</span> StringUtilsTest.java</div>
<pre><code class="highlight-add">@Test
void shouldReturnEmptyIfTheStringIsEmpty() {
// given
String str = "";
// when
String actual = StringUtils.capitalize(str, Locale.ENGLISH);
// then
assertThat(actual).isEmpty();
}</code></pre>
</div>
</div>
</div>
<h2>Test 3: shouldReturnTheSameStringIfTheStringIsAlreadyCapitalized</h2>
<div class="section">
<div class="diff-container">
<div class="diff-side spock">
<div class="section-header"><span class="label">SPOCK (removed)</span> StringUtilsSpec.groovy</div>
<pre><code class="highlight-remove">void 'should return the same string if the string is already capitalize'() {
given:
String str = 'Capitalize'
when:
String actual = StringUtils.capitalize(str, Locale.ENGLISH)
then:
actual == str
}</code></pre>
</div>
<div class="diff-side junit">
<div class="section-header"><span class="label">JUNIT 5 (added)</span> StringUtilsTest.java</div>
<pre><code class="highlight-add">@Test
void shouldReturnTheSameStringIfTheStringIsAlreadyCapitalized() {
// given
String str = "Capitalize";
// when
String actual = StringUtils.capitalize(str, Locale.ENGLISH);
// then
assertThat(actual).isEqualTo(str);
}</code></pre>
</div>
</div>
</div>
<h2>Test 4: shouldReturnTheStringCapitalizedIfTheStringIsNotCapitalized</h2>
<div class="section">
<div class="diff-container">
<div class="diff-side spock">
<div class="section-header"><span class="label">SPOCK (removed)</span> StringUtilsSpec.groovy</div>
<pre><code class="highlight-remove">void 'should return the string capitalize if the string is not capitalize'() {
given:
String str = 'capitalize'
when:
String actual = StringUtils.capitalize(str, Locale.ENGLISH)
then:
actual == 'Capitalize'
}</code></pre>
</div>
<div class="diff-side junit">
<div class="section-header"><span class="label">JUNIT 5 (added)</span> StringUtilsTest.java</div>
<pre><code class="highlight-add">@Test
void shouldReturnTheStringCapitalizedIfTheStringIsNotCapitalized() {
// given
String str = "capitalize";
// when
String actual = StringUtils.capitalize(str, Locale.ENGLISH);
// then
assertThat(actual).isEqualTo("Capitalize");
}</code></pre>
</div>
</div>
</div>
<h2>📦 Full File Comparison</h2>
<div class="section">
<div class="diff-container">
<div class="diff-side spock">
<div class="section-header"><span class="label">SPOCK (removed)</span> StringUtilsSpec.groovy</div>
<pre><code class="highlight-remove">package agorapulse.commons.utils
import spock.lang.Specification
class StringUtilsSpec extends Specification {
void 'should return null if the string is null'() {
given:
String str = null
when:
String actual = StringUtils.capitalize(str, Locale.ENGLISH)
then:
actual == null
}
void 'should return empty if the string is empty'() {
given:
String str = ''
when:
String actual = StringUtils.capitalize(str, Locale.ENGLISH)
then:
actual == ''
}
void 'should return the same string if the string is already capitalize'() {
given:
String str = 'Capitalize'
when:
String actual = StringUtils.capitalize(str, Locale.ENGLISH)
then:
actual == str
}
void 'should return the string capitalize if the string is not capitalize'() {
given:
String str = 'capitalize'
when:
String actual = StringUtils.capitalize(str, Locale.ENGLISH)
then:
actual == 'Capitalize'
}
}</code></pre>
</div>
<div class="diff-side junit">
<div class="section-header"><span class="label">JUNIT 5 (added)</span> StringUtilsTest.java</div>
<pre><code class="highlight-add">package agorapulse.commons.utils;
import org.junit.jupiter.api.Test;
import java.util.Locale;
import static org.assertj.core.api.Assertions.assertThat;
class StringUtilsTest {
@Test
void shouldReturnNullIfTheStringIsNull() {
// given
String str = null;
// when
String actual = StringUtils.capitalize(str, Locale.ENGLISH);
// then
assertThat(actual).isNull();
}
@Test
void shouldReturnEmptyIfTheStringIsEmpty() {
// given
String str = "";
// when
String actual = StringUtils.capitalize(str, Locale.ENGLISH);
// then
assertThat(actual).isEmpty();
}
@Test
void shouldReturnTheSameStringIfTheStringIsAlreadyCapitalized() {
// given
String str = "Capitalize";
// when
String actual = StringUtils.capitalize(str, Locale.ENGLISH);
// then
assertThat(actual).isEqualTo(str);
}
@Test
void shouldReturnTheStringCapitalizedIfTheStringIsNotCapitalized() {
// given
String str = "capitalize";
// when
String actual = StringUtils.capitalize(str, Locale.ENGLISH);
// then
assertThat(actual).isEqualTo("Capitalize");
}
}</code></pre>
</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment