Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

toString method for MetaData #240

Merged
merged 3 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ sudo: false
jdk:
- oraclejdk8
install: true
dist: trusty
env:
matrix:
- VERSION_JACKSON='-Dversion.jackson=2.6.7' PROJECTS='-pl !fahrschein-typeresolver,!fahrschein-example'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,15 @@ public String getFlowId() {
public Map<String, String> getSpanCtx() {
return spanCtx;
}

@Override
public String toString() {
return "Metadata{" +
"eventType='" + eventType + '\'' +
", eid='" + eid + '\'' +
", occurredAt=" + occurredAt +
", receivedAt=" + receivedAt +
", flowId='" + flowId + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.zalando.fahrschein.domain;

import org.junit.Assert;
import org.junit.Test;

import java.time.OffsetDateTime;
import java.util.Collections;
import java.util.UUID;

public class MetadataTest {

@Test
public void shouldHaveCleanStringRepresentation() {
final String eventType = "TEST-EVENT-TYPE";
final String eid = "a3e25946-5ae9-3964-91fa-26ecb7588d67";
final OffsetDateTime occurredAt = OffsetDateTime.now();
final OffsetDateTime receivedAt = OffsetDateTime.now();
final String flowId = UUID.randomUUID().toString();

final Metadata metadata = new Metadata(eventType, eid, occurredAt, receivedAt, flowId, Collections.emptyMap());

Assert.assertTrue(metadata.toString().contains(metadata.getEventType()));
Assert.assertTrue(metadata.toString().contains(metadata.getEid()));
Assert.assertTrue(metadata.toString().contains(metadata.getOccurredAt().toString()));
Assert.assertTrue(metadata.toString().contains(metadata.getReceivedAt().toString()));
Assert.assertTrue(metadata.toString().contains(metadata.getFlowId()));
}
}