Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
Signed-off-by: Kondaka <[email protected]>
  • Loading branch information
kkondaka committed Oct 21, 2024
1 parent c7f1cdd commit 91849be
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ public abstract static class Builder<T extends Builder<T>> {
private String eventType;
private Instant timeReceived;
private Map<String, Object> eventMetadataAttributes;
protected EventHandle eventHandle;
protected transient EventHandle eventHandle;

public abstract T getThis();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -577,6 +578,20 @@ public void testBuild_withEventType() {
assertThat(event.getEventHandle().getInternalOriginationTime(), is(notNullValue()));
}

@Test
public void testBuild_withEventHandle() {
final Instant now = Instant.now();

EventHandle eventHandle = new DefaultEventHandle(now);
event = JacksonEvent.builder()
.withEventType(eventType)
.withEventHandle(eventHandle)
.build();

assertThat(event.getEventHandle(), is(eventHandle));
assertThat(event.getEventHandle().getInternalOriginationTime(), is(equalTo(now)));
}

@Test
public void testBuild_withTimeReceived() {

Expand Down Expand Up @@ -860,6 +875,7 @@ void fromEvent_with_a_JacksonEvent() {
assertThat(createdEvent, notNullValue());
assertThat(createdEvent, not(sameInstance(originalEvent)));
assertThat(event.getEventHandle(), is(notNullValue()));
assertTrue(event.getEventHandle() instanceof DefaultEventHandle);
assertThat(event.getEventHandle().getInternalOriginationTime(), is(notNullValue()));

assertThat(createdEvent.toMap(), equalTo(dataObject));
Expand Down

0 comments on commit 91849be

Please sign in to comment.