Skip to content

Commit

Permalink
Make EventData.SystemProperties completely public (#435)
Browse files Browse the repository at this point in the history
Porting testability changes from .NET Core to Java: provide full access to EventData's SystemProperties so that a complete EventData can be fabricated in tests.
  • Loading branch information
JamesBirdsall authored Mar 8, 2019
1 parent 5826288 commit 6edab2c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,21 @@ static EventData create(final ByteBuffer buffer) {
* @see SystemProperties#getEnqueuedTime
*/
SystemProperties getSystemProperties();
void setSystemProperties(SystemProperties props);

class SystemProperties extends HashMap<String, Object> {
public class SystemProperties extends HashMap<String, Object> {
private static final long serialVersionUID = -2827050124966993723L;

public SystemProperties(final HashMap<String, Object> map) {
super(Collections.unmodifiableMap(map));
}

public SystemProperties(final long sequenceNumber, final Instant enqueuedTimeUtc, final String offset, final String partitionKey) {
this.put(AmqpConstants.SEQUENCE_NUMBER_ANNOTATION_NAME, sequenceNumber);
this.put(AmqpConstants.ENQUEUED_TIME_UTC_ANNOTATION_NAME, new Date(enqueuedTimeUtc.toEpochMilli()));
this.put(AmqpConstants.OFFSET_ANNOTATION_NAME, offset);
this.put(AmqpConstants.PARTITION_KEY_ANNOTATION_NAME, partitionKey);
}

public String getOffset() {
return this.getSystemProperty(AmqpConstants.OFFSET_ANNOTATION_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ public SystemProperties getSystemProperties() {
return this.systemProperties;
}

public void setSystemProperties(EventData.SystemProperties props) {
this.systemProperties = props;
}

// This is intended to be used while sending EventData - so EventData.SystemProperties will not be copied over to the AmqpMessage
Message toAmqpMessage() {
final Message amqpMessage = Proton.message();
Expand Down

0 comments on commit 6edab2c

Please sign in to comment.