Created
February 19, 2026 05:44
-
-
Save musketyr/024b09b1b60b7a95636d5a40e9cea7a8 to your computer and use it in GitHub Desktop.
Spock to JUnit 5 Migration Diff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Spock → JUnit 5 Migration: RoiPostInsightSpec</title> | |
| <style> | |
| * { box-sizing: border-box; margin: 0; padding: 0; } | |
| body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f5f5; padding: 20px; line-height: 1.6; } | |
| h1 { text-align: center; margin-bottom: 20px; color: #333; } | |
| .section { background: white; border-radius: 8px; margin-bottom: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); overflow: hidden; } | |
| .section-header { background: #2d3748; color: white; padding: 12px 16px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; } | |
| .section-header:hover { background: #4a5568; } | |
| .section-header h2 { font-size: 16px; font-weight: 600; } | |
| .section-header .toggle { font-size: 12px; } | |
| .section-content { display: block; } | |
| .section-content.collapsed { display: none; } | |
| .diff-container { display: grid; grid-template-columns: 1fr 1fr; } | |
| .diff-panel { padding: 16px; overflow-x: auto; } | |
| .diff-panel.left { background: #fff5f5; border-right: 1px solid #e2e8f0; } | |
| .diff-panel.right { background: #f0fff4; } | |
| .diff-panel h3 { font-size: 12px; text-transform: uppercase; color: #718096; margin-bottom: 12px; letter-spacing: 0.5px; } | |
| pre { font-family: 'SF Mono', Monaco, 'Courier New', monospace; font-size: 13px; white-space: pre-wrap; word-wrap: break-word; } | |
| .left pre { color: #c53030; } | |
| .right pre { color: #276749; } | |
| @media (max-width: 768px) { .diff-container { grid-template-columns: 1fr; } .diff-panel.left { border-right: none; border-bottom: 1px solid #e2e8f0; } } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>🦀 Spock → JUnit 5 Migration: RoiPostInsightSpec</h1> | |
| <p style="text-align: center; color: #666; margin-bottom: 20px;">Story: <a href="https://app.shortcut.com/agorapulse/story/185898">sc185898</a> | PR: <a href="https://github.com/agorapulse/platform/pull/72987">#72987</a></p> | |
| <div class="section"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>📦 Imports</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <div class="diff-container"> | |
| <div class="diff-panel left"> | |
| <h3>Spock (Groovy)</h3> | |
| <pre>package agorapulse.roi.postinsight.model | |
| import agorapulse.link.client.LinkSummary | |
| import agorapulse.organization.client.model.AccountSummary | |
| import agorapulse.report.client.PostInsightSummary | |
| import agorapulse.report.client.insights.PostInsightAttachment | |
| import agorapulse.roi.core.models.RoiContentAttachment | |
| import agorapulse.service.client.api.Service | |
| import spock.lang.Specification | |
| import java.time.Instant | |
| import java.time.LocalDateTime</pre> | |
| </div> | |
| <div class="diff-panel right"> | |
| <h3>JUnit 5 (Java)</h3> | |
| <pre>package agorapulse.roi.postinsight.model; | |
| import agorapulse.link.client.LinkSummary; | |
| import agorapulse.organization.client.model.AccountSummary; | |
| import agorapulse.report.client.PostInsightSummary; | |
| import agorapulse.report.client.insights.PostInsightAttachment; | |
| import agorapulse.roi.core.models.RoiContentAttachment; | |
| import agorapulse.service.client.api.Service; | |
| import org.junit.jupiter.api.Test; | |
| import java.time.Instant; | |
| import java.time.LocalDateTime; | |
| import java.util.List; | |
| import static org.assertj.core.api.Assertions.assertThat;</pre> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="section"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>🏗️ Class & Fields</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <div class="diff-container"> | |
| <div class="diff-panel left"> | |
| <h3>Spock (Groovy)</h3> | |
| <pre>class RoiPostInsightSpec extends Specification { | |
| </pre> | |
| </div> | |
| <div class="diff-panel right"> | |
| <h3>JUnit 5 (Java)</h3> | |
| <pre>class RoiPostInsightTest { | |
| </pre> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="section"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>🧪 should fill insight - nulls</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <div class="diff-container"> | |
| <div class="diff-panel left"> | |
| <h3>Spock (Groovy)</h3> | |
| <pre> void 'should fill insight - nulls'() { | |
| given: | |
| RoiPostInsight roiPostInsight = RoiPostInsight.builder().linkUid('ap_4f8erg34g').build() | |
| LinkSummary link = null | |
| PostInsightSummary reportPostInsight = null | |
| AccountSummary account = null | |
| when: | |
| roiPostInsight.fillInsight(link, reportPostInsight, account) | |
| then: | |
| roiPostInsight == RoiPostInsight.builder().linkUid('ap_4f8erg34g').attachment(new RoiContentAttachment()).build() | |
| }</pre> | |
| </div> | |
| <div class="diff-panel right"> | |
| <h3>JUnit 5 (Java)</h3> | |
| <pre> @Test | |
| void shouldFillInsightWithNulls() { | |
| // given | |
| RoiPostInsight roiPostInsight = RoiPostInsight.builder().linkUid("ap_4f8erg34g").build(); | |
| LinkSummary link = null; | |
| PostInsightSummary reportPostInsight = null; | |
| AccountSummary account = null; | |
| // when | |
| roiPostInsight.fillInsight(link, reportPostInsight, account); | |
| // then | |
| RoiPostInsight expected = RoiPostInsight.builder() | |
| .linkUid("ap_4f8erg34g") | |
| .attachment(new RoiContentAttachment()) | |
| .build(); | |
| assertThat(roiPostInsight).isEqualTo(expected); | |
| }</pre> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="section"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>🧪 should fill insight - no attachment</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <div class="diff-container"> | |
| <div class="diff-panel left"> | |
| <h3>Spock (Groovy)</h3> | |
| <pre> void 'should fill insight - no attachment'() { | |
| given: | |
| RoiPostInsight roiPostInsight = RoiPostInsight.builder().linkUid('ap_4f8erg34g').build() | |
| LinkSummary link = new LinkSummary(uid: 'ap_4f8erg34g', accountUid: 'facebook_3', serviceId: '1654643534', creationDate: LocalDateTime.of(2023, 1, 1, 10, 20)) | |
| PostInsightSummary reportPostInsight = new PostInsightSummary(message: 'message', publishingDate: Instant.parse('2020-02-16T00:00:00Z'), tags: ['fun']) | |
| AccountSummary account = new AccountSummary(name: 'testName', service: Service.facebook) | |
| when: | |
| roiPostInsight.fillInsight(link, reportPostInsight, account) | |
| then: | |
| roiPostInsight == RoiPostInsight.builder() | |
| .linkUid('ap_4f8erg34g') | |
| .accountName('testName') | |
| .accountUid('facebook_3') | |
| .attachment(new RoiContentAttachment()) | |
| .message('message') | |
| .postId('1654643534') | |
| .postType(null) | |
| .publishingDate(Instant.parse('2020-02-16T00:00:00Z')) | |
| .service(Service.facebook) | |
| .tags(['fun']) | |
| .build() | |
| }</pre> | |
| </div> | |
| <div class="diff-panel right"> | |
| <h3>JUnit 5 (Java)</h3> | |
| <pre> @Test | |
| void shouldFillInsightWithNoAttachment() { | |
| // given | |
| RoiPostInsight roiPostInsight = RoiPostInsight.builder().linkUid("ap_4f8erg34g").build(); | |
| LinkSummary link = new LinkSummary(); | |
| link.setUid("ap_4f8erg34g"); | |
| link.setAccountUid("facebook_3"); | |
| link.setServiceId("1654643534"); | |
| link.setCreationDate(LocalDateTime.of(2023, 1, 1, 10, 20)); | |
| PostInsightSummary reportPostInsight = new PostInsightSummary(); | |
| reportPostInsight.setMessage("message"); | |
| reportPostInsight.setPublishingDate(Instant.parse("2020-02-16T00:00:00Z")); | |
| reportPostInsight.setTags(List.of("fun")); | |
| AccountSummary account = new AccountSummary(); | |
| account.setName("testName"); | |
| account.setService(Service.facebook); | |
| // when | |
| roiPostInsight.fillInsight(link, reportPostInsight, account); | |
| // then | |
| RoiPostInsight expected = RoiPostInsight.builder() | |
| .linkUid("ap_4f8erg34g") | |
| .accountName("testName") | |
| .accountUid("facebook_3") | |
| .attachment(new RoiContentAttachment()) | |
| .message("message") | |
| .postId("1654643534") | |
| .postType(null) | |
| .publishingDate(Instant.parse("2020-02-16T00:00:00Z")) | |
| .service(Service.facebook) | |
| .tags(List.of("fun")) | |
| .build(); | |
| assertThat(roiPostInsight).isEqualTo(expected); | |
| }</pre> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="section"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>🧪 should fill insight - carousel attachment</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <div class="diff-container"> | |
| <div class="diff-panel left"> | |
| <h3>Spock (Groovy)</h3> | |
| <pre> void 'should fill insight - carousel attachment'() { | |
| given: | |
| RoiPostInsight roiPostInsight = RoiPostInsight.builder().linkUid('ap_4f8erg34g').build() | |
| LinkSummary link = new LinkSummary(uid: 'ap_4f8erg34g', accountUid: 'facebook_3', serviceId: '1654643534', creationDate: LocalDateTime.of(2023, 1, 1, 10, 20)) | |
| PostInsightSummary reportPostInsight = new PostInsightSummary( | |
| message: 'message', | |
| carousel: true, | |
| attachment: new PostInsightAttachment(multiAttachmentEnabled: true, type: 'image', url: 'https://url.com'), | |
| tags: ['fun'] | |
| ) | |
| AccountSummary account = new AccountSummary(name: 'testName', service: Service.facebook) | |
| when: | |
| roiPostInsight.fillInsight(link, reportPostInsight, account) | |
| then: | |
| roiPostInsight == RoiPostInsight.builder() | |
| .linkUid('ap_4f8erg34g') | |
| .accountName('testName') | |
| .accountUid('facebook_3') | |
| .attachment(new RoiContentAttachment(multiAttachmentEnabled: true, type: 'image', url: 'https://url.com')) | |
| .message('message') | |
| .postId('1654643534') | |
| .postType('carousel') | |
| .publishingDate(Instant.parse('2023-01-01T10:20:00Z')) | |
| .service(Service.facebook) | |
| .tags(['fun']) | |
| .build() | |
| }</pre> | |
| </div> | |
| <div class="diff-panel right"> | |
| <h3>JUnit 5 (Java)</h3> | |
| <pre> @Test | |
| void shouldFillInsightWithCarouselAttachment() { | |
| // given | |
| RoiPostInsight roiPostInsight = RoiPostInsight.builder().linkUid("ap_4f8erg34g").build(); | |
| LinkSummary link = new LinkSummary(); | |
| link.setUid("ap_4f8erg34g"); | |
| link.setAccountUid("facebook_3"); | |
| link.setServiceId("1654643534"); | |
| link.setCreationDate(LocalDateTime.of(2023, 1, 1, 10, 20)); | |
| PostInsightAttachment attachment = new PostInsightAttachment(); | |
| attachment.setMultiAttachmentEnabled(true); | |
| attachment.setType("image"); | |
| attachment.setUrl("https://url.com"); | |
| PostInsightSummary reportPostInsight = new PostInsightSummary(); | |
| reportPostInsight.setMessage("message"); | |
| reportPostInsight.setCarousel(true); | |
| reportPostInsight.setAttachment(attachment); | |
| reportPostInsight.setTags(List.of("fun")); | |
| AccountSummary account = new AccountSummary(); | |
| account.setName("testName"); | |
| account.setService(Service.facebook); | |
| // when | |
| roiPostInsight.fillInsight(link, reportPostInsight, account); | |
| // then | |
| RoiContentAttachment expectedAttachment = new RoiContentAttachment(); | |
| expectedAttachment.setMultiAttachmentEnabled(true); | |
| expectedAttachment.setType("image"); | |
| expectedAttachment.setUrl("https://url.com"); | |
| RoiPostInsight expected = RoiPostInsight.builder() | |
| .linkUid("ap_4f8erg34g") | |
| .accountName("testName") | |
| .accountUid("facebook_3") | |
| .attachment(expectedAttachment) | |
| .message("message") | |
| .postId("1654643534") | |
| .postType("carousel") | |
| .publishingDate(Instant.parse("2023-01-01T10:20:00Z")) | |
| .service(Service.facebook) | |
| .tags(List.of("fun")) | |
| .build(); | |
| assertThat(roiPostInsight).isEqualTo(expected); | |
| }</pre> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="section"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>🧪 should fill insight - reel attachment</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <div class="diff-container"> | |
| <div class="diff-panel left"> | |
| <h3>Spock (Groovy)</h3> | |
| <pre> void 'should fill insight - reel attachment'() { | |
| given: | |
| RoiPostInsight roiPostInsight = RoiPostInsight.builder().linkUid('ap_4f8erg34g').build() | |
| LinkSummary link = new LinkSummary(uid: 'ap_4f8erg34g', accountUid: 'facebook_3', serviceId: '1654643534', creationDate: LocalDateTime.of(2023, 1, 1, 10, 20)) | |
| PostInsightSummary reportPostInsight = new PostInsightSummary( | |
| message: 'message', | |
| reel: true, | |
| attachment: new PostInsightAttachment(multiAttachmentEnabled: false, type: 'video', url: 'https://url.com'), | |
| tags: ['fun'] | |
| ) | |
| AccountSummary account = new AccountSummary(name: 'testName', service: Service.facebook) | |
| when: | |
| roiPostInsight.fillInsight(link, reportPostInsight, account) | |
| then: | |
| roiPostInsight == RoiPostInsight.builder() | |
| .linkUid('ap_4f8erg34g') | |
| .accountName('testName') | |
| .accountUid('facebook_3') | |
| .attachment(new RoiContentAttachment(multiAttachmentEnabled: false, type: 'video', url: 'https://url.com')) | |
| .message('message') | |
| .postId('1654643534') | |
| .postType('reel') | |
| .publishingDate(Instant.parse('2023-01-01T10:20:00Z')) | |
| .service(Service.facebook) | |
| .tags(['fun']) | |
| .build() | |
| }</pre> | |
| </div> | |
| <div class="diff-panel right"> | |
| <h3>JUnit 5 (Java)</h3> | |
| <pre> @Test | |
| void shouldFillInsightWithReelAttachment() { | |
| // given | |
| RoiPostInsight roiPostInsight = RoiPostInsight.builder().linkUid("ap_4f8erg34g").build(); | |
| LinkSummary link = new LinkSummary(); | |
| link.setUid("ap_4f8erg34g"); | |
| link.setAccountUid("facebook_3"); | |
| link.setServiceId("1654643534"); | |
| link.setCreationDate(LocalDateTime.of(2023, 1, 1, 10, 20)); | |
| PostInsightAttachment attachment = new PostInsightAttachment(); | |
| attachment.setMultiAttachmentEnabled(false); | |
| attachment.setType("video"); | |
| attachment.setUrl("https://url.com"); | |
| PostInsightSummary reportPostInsight = new PostInsightSummary(); | |
| reportPostInsight.setMessage("message"); | |
| reportPostInsight.setReel(true); | |
| reportPostInsight.setAttachment(attachment); | |
| reportPostInsight.setTags(List.of("fun")); | |
| AccountSummary account = new AccountSummary(); | |
| account.setName("testName"); | |
| account.setService(Service.facebook); | |
| // when | |
| roiPostInsight.fillInsight(link, reportPostInsight, account); | |
| // then | |
| RoiContentAttachment expectedAttachment = new RoiContentAttachment(); | |
| expectedAttachment.setMultiAttachmentEnabled(false); | |
| expectedAttachment.setType("video"); | |
| expectedAttachment.setUrl("https://url.com"); | |
| RoiPostInsight expected = RoiPostInsight.builder() | |
| .linkUid("ap_4f8erg34g") | |
| .accountName("testName") | |
| .accountUid("facebook_3") | |
| .attachment(expectedAttachment) | |
| .message("message") | |
| .postId("1654643534") | |
| .postType("reel") | |
| .publishingDate(Instant.parse("2023-01-01T10:20:00Z")) | |
| .service(Service.facebook) | |
| .tags(List.of("fun")) | |
| .build(); | |
| assertThat(roiPostInsight).isEqualTo(expected); | |
| }</pre> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| function toggleSection(header) { | |
| const content = header.nextElementSibling; | |
| const toggle = header.querySelector('.toggle'); | |
| content.classList.toggle('collapsed'); | |
| toggle.textContent = content.classList.contains('collapsed') ? '▶' : '▼'; | |
| } | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment