From 142f63ca1779177b3db80ecc4a259397cfb99127 Mon Sep 17 00:00:00 2001 From: Hossam Hatem <7ossam7atem1@gmail.com> Date: Thu, 27 Feb 2025 11:12:21 +0200 Subject: [PATCH] FINERACT-2081: Add assertions to BulkBusinessEventTest --- .../domain/BulkBusinessEventTest.java | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/fineract-provider/src/test/java/org/apache/fineract/infrastructure/event/business/domain/BulkBusinessEventTest.java b/fineract-provider/src/test/java/org/apache/fineract/infrastructure/event/business/domain/BulkBusinessEventTest.java index e2eb0c389..e29214a79 100644 --- a/fineract-provider/src/test/java/org/apache/fineract/infrastructure/event/business/domain/BulkBusinessEventTest.java +++ b/fineract-provider/src/test/java/org/apache/fineract/infrastructure/event/business/domain/BulkBusinessEventTest.java @@ -33,26 +33,39 @@ class BulkBusinessEventTest { @Test public void testConstructorWorksForSameAggregateId() { // given + List> events = List.of(new ClientCreateBusinessEvent(client(1L)), new ClientActivateBusinessEvent(client(1L))); + // when - new BulkBusinessEvent(List.of(new ClientCreateBusinessEvent(client(1L)), new ClientActivateBusinessEvent(client(1L)))); - // then no exception thrown + BulkBusinessEvent bulkEvent = new BulkBusinessEvent(events); + + // then + Assertions.assertEquals(1L, bulkEvent.getAggregateRootId()); + Assertions.assertEquals(events, bulkEvent.get()); + Assertions.assertEquals(BulkBusinessEvent.TYPE, bulkEvent.getType()); + Assertions.assertEquals("Bulk", bulkEvent.getCategory()); } @Test public void testConstructorThrowsExceptionForDifferentAggregateId() { // given - // when - Assertions.assertThrows(IllegalArgumentException.class, () -> new BulkBusinessEvent( - List.of(new ClientCreateBusinessEvent(client(1L)), new ClientActivateBusinessEvent(client(2L))))); - // then no exception thrown + List> events = List.of(new ClientCreateBusinessEvent(client(1L)), new ClientActivateBusinessEvent(client(2L))); + + // when/then + IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> new BulkBusinessEvent(events)); + Assertions.assertEquals("The business events are related to multiple aggregate roots which is not allowed", exception.getMessage()); } @Test public void testConstructorWorksForNullAggregateId() { // given + List> events = List.of(new ClientCreateBusinessEvent(client(1L)), new ClientActivateBusinessEvent(client(null))); + // when - new BulkBusinessEvent(List.of(new ClientCreateBusinessEvent(client(1L)), new ClientActivateBusinessEvent(client(null)))); - // then no exception thrown + BulkBusinessEvent bulkEvent = new BulkBusinessEvent(events); + + // then + Assertions.assertEquals(1L, bulkEvent.getAggregateRootId()); + Assertions.assertEquals(events, bulkEvent.get()); } private Client client(Long id) { @@ -60,5 +73,4 @@ class BulkBusinessEventTest { given(client.getId()).willReturn(id); return client; } - }