Skip to content

Commit

Permalink
Fix NPE on contributions events (#1301)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofux authored Nov 20, 2024
1 parent 7c39ec2 commit 224b0f0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class ContributionsApiIT extends AbstractMarketplaceApiIT {
static ProjectId kaaper = ProjectId.of("298a547f-ecb6-4ab2-8975-68f4e9bf7b39");
static RewardId rewardId;
static Application application;
static Long newIssueId;

@Autowired
ProjectContributorLabelFacadePort projectContributorLabelFacadePort;
Expand All @@ -64,6 +65,10 @@ void setup() {
postgresBiProjectorAdapter.onContributionsChanged(ContributionUUID.of(UUID.fromString("0f8d789f-fbbd-3171-ad03-9b2b6f8d9174")));
postgresBiProjectorAdapter.onContributionsChanged(ContributionUUID.of(UUID.fromString("f4db1d9b-4e1d-300c-9277-8d05824c804e")));

final var fooRepo = githubHelper.createRepo("foo");
newIssueId = at("2024-01-01T00:00:00Z", () -> githubHelper.createIssue(fooRepo.getId(), ZonedDateTime.parse("2024-01-01T00:00:00Z"), null, "OPEN",
projectLead));

rewardId = rewardHelper.create(kaaper, projectLead, recipient.githubUserId(), 123, CurrencyHelper.USDC, List.of(
RequestRewardCommand.Item.builder()
.id("1300430041")
Expand Down Expand Up @@ -470,6 +475,32 @@ void should_get_issue_contribution_events() {
""", true);
}


@Test
void should_get_new_issue_contribution_events() {
// When
client.get()
.uri(getApiURI(CONTRIBUTIONS_BY_ID_EVENTS.formatted(ContributionUUID.of(newIssueId).toString())))
// Then
.exchange()
.expectStatus()
.isOk()
.expectBody()
.json("""
{
"events": [
{
"timestamp": "2024-01-01T00:00:00Z",
"type": "ISSUE_CREATED",
"assignee": null,
"mergedBy": null,
"linkedIssueContributionUuid": null
}
]
}
""", true);
}

@Test
void should_get_linked_issue_by_id() {
// When
Expand Down Expand Up @@ -528,8 +559,8 @@ void should_get_contributions() {
.expectBody()
.json("""
{
"totalPageNumber": 4694,
"totalItemNumber": 4694,
"totalPageNumber": 4695,
"totalItemNumber": 4695,
"hasMore": true,
"nextPageIndex": 1,
"contributions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public ResponseEntity<ContributionEventListResponse> getContributionEvents(UUID
.cacheControl(cache.forEverybody(XS))
.body(new ContributionEventListResponse()
.events(events.stream()
.filter(e -> e.getTimestamp() != null)
.sorted(Comparator.comparing(ContributionEventResponse::getTimestamp).reversed())
.toList()));
}
Expand Down

0 comments on commit 224b0f0

Please sign in to comment.