FINERACT-1694 Categorization for Events
This commit is contained in:
committed by
Aleksandar Vidakovic
parent
af63dbc9fa
commit
5bd804ada8
+5
@@ -156,6 +156,11 @@ class BusinessEventNotifierServiceImplTest {
|
||||
public String getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCategory() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-5
@@ -99,8 +99,8 @@ class SendAsynchronousEventsTaskletTest {
|
||||
@Test
|
||||
public void givenBatchSize2WhenTaskExecutionThenSend2Events() throws Exception {
|
||||
// given
|
||||
List<ExternalEvent> events = Arrays.asList(new ExternalEvent("aType", "aSchema", new byte[0], "aIdemtpotencyKey"),
|
||||
new ExternalEvent("aType", "aSchema", new byte[0], "aIdemtpotencyKey"));
|
||||
List<ExternalEvent> events = Arrays.asList(new ExternalEvent("aType", "aCategory", "aSchema", new byte[0], "aIdemtpotencyKey"),
|
||||
new ExternalEvent("aType", "aCategory", "aSchema", new byte[0], "aIdemtpotencyKey"));
|
||||
// Dummy Message
|
||||
MessageV1 dummyMessage = new MessageV1(1, "aSource", "aType", "nocategory", "aCreateDate", "aTennantId", "anidempotencyKey",
|
||||
"aSchema", Mockito.mock(ByteBuffer.class));
|
||||
@@ -120,8 +120,8 @@ class SendAsynchronousEventsTaskletTest {
|
||||
@Test
|
||||
public void givenBatchSize2WhenEventSendFailsThenExecutionStops() throws Exception {
|
||||
// given
|
||||
List<ExternalEvent> events = Arrays.asList(new ExternalEvent("aType", "aSchema", new byte[0], "aIdemtpotencyKey"),
|
||||
new ExternalEvent("aType", "aSchema", new byte[0], "aIdemtpotencyKey"));
|
||||
List<ExternalEvent> events = Arrays.asList(new ExternalEvent("aType", "aCategory", "aSchema", new byte[0], "aIdemtpotencyKey"),
|
||||
new ExternalEvent("aType", "aCategory", "aSchema", new byte[0], "aIdemtpotencyKey"));
|
||||
MessageV1 dummyMessage = new MessageV1(1, "aSource", "aType", "nocategory", "aCreateDate", "aTennantId", "anidempotencyKey",
|
||||
"aSchema", Mockito.mock(ByteBuffer.class));
|
||||
when(repository.findByStatusOrderById(Mockito.any(), Mockito.any())).thenReturn(events);
|
||||
@@ -140,7 +140,7 @@ class SendAsynchronousEventsTaskletTest {
|
||||
public void givenOneEventWhenEventSentThenEventStatusUpdates() throws Exception {
|
||||
// given
|
||||
ArgumentCaptor<ExternalEvent> externalEventArgumentCaptor = ArgumentCaptor.forClass(ExternalEvent.class);
|
||||
List<ExternalEvent> events = Arrays.asList(new ExternalEvent("aType", "aSchema", new byte[0], "aIdemtpotencyKey"));
|
||||
List<ExternalEvent> events = Arrays.asList(new ExternalEvent("aType", "aCategory", "aSchema", new byte[0], "aIdemtpotencyKey"));
|
||||
MessageV1 dummyMessage = new MessageV1(1, "aSource", "aType", "nocategory", "aCreateDate", "aTennantId", "anidempotencyKey",
|
||||
"aSchema", Mockito.mock(ByteBuffer.class));
|
||||
when(repository.findByStatusOrderById(Mockito.any(), Mockito.any())).thenReturn(events);
|
||||
|
||||
+27
@@ -159,4 +159,31 @@ class ExternalEventServiceTest {
|
||||
assertThat(externalEvent.getType()).isEqualTo(eventType);
|
||||
assertThat(externalEvent.getSchema()).isEqualTo(schema);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostEventShouldSaveEventCategory() throws IOException {
|
||||
// given
|
||||
ArgumentCaptor<ExternalEvent> externalEventArgumentCaptor = ArgumentCaptor.forClass(ExternalEvent.class);
|
||||
String eventSchema = "org.apache.fineract.avro.loan.v1.LoanAccountDataV1";
|
||||
String eventType = "TestType";
|
||||
String eventCategory = "TestCategory";
|
||||
String idempotencyKey = "key";
|
||||
BusinessEvent event = mock(BusinessEvent.class);
|
||||
BusinessEventSerializer eventSerializer = mock(BusinessEventSerializer.class);
|
||||
byte[] data = new byte[0];
|
||||
|
||||
given(event.getType()).willReturn(eventType);
|
||||
given(event.getCategory()).willReturn(eventCategory);
|
||||
given(idempotencyKeyGenerator.generate(event)).willReturn(idempotencyKey);
|
||||
given(serializerFactory.create(event)).willReturn(eventSerializer);
|
||||
given(eventSerializer.getSupportedSchema()).will(invocation -> LoanAccountDataV1.class);
|
||||
given(eventSerializer.serialize(event)).willReturn(data);
|
||||
// when
|
||||
underTest.postEvent(event);
|
||||
// then
|
||||
verify(repository).save(externalEventArgumentCaptor.capture());
|
||||
ExternalEvent externalEvent = externalEventArgumentCaptor.getValue();
|
||||
assertThat(externalEvent.getCategory()).isEqualTo(eventCategory);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user