@Test void lowerBoundDifferentNumberOfTokens() { Map<String, TrackingToken> newTokens = new HashMap<>(); newTokens.put("token1", new GlobalSequenceTrackingToken(1)); assertThrows(IllegalArgumentException.class, () -> testSubject.lowerBound(new MultiSourceTrackingToken(newTokens))); }
@Override public TrackingToken lowerBound(TrackingToken other) { Assert.isTrue(other instanceof MultiSourceTrackingToken, () -> "Incompatible token type provided."); MultiSourceTrackingToken otherMultiToken = (MultiSourceTrackingToken) other; Assert.isTrue(otherMultiToken.trackingTokens.keySet().equals(this.trackingTokens.keySet()), () -> "MultiSourceTrackingTokens contain different keys"); Map<String, TrackingToken> tokenMap = new HashMap<>(); otherMultiToken.trackingTokens .forEach((tokenSourceName, otherToken) -> tokenMap.put(tokenSourceName, trackingTokens.get(tokenSourceName) == null ? null : trackingTokens.get(tokenSourceName).lowerBound(otherToken)) ); return new MultiSourceTrackingToken(tokenMap); }
MultiSourceTrackingToken implements TrackingToken, Serializable { @Override public TrackingToken lowerBound(TrackingToken other) { Assert.isTrue(other instanceof MultiSourceTrackingToken, () -> "Incompatible token type provided."); MultiSourceTrackingToken otherMultiToken = (MultiSourceTrackingToken) other; Assert.isTrue(otherMultiToken.trackingTokens.keySet().equals(this.trackingTokens.keySet()), () -> "MultiSourceTrackingTokens contain different keys"); Map<String, TrackingToken> tokenMap = new HashMap<>(); otherMultiToken.trackingTokens .forEach((tokenSourceName, otherToken) -> tokenMap.put(tokenSourceName, trackingTokens.get(tokenSourceName) == null ? null : trackingTokens.get(tokenSourceName).lowerBound(otherToken)) ); return new MultiSourceTrackingToken(tokenMap); } }
MultiSourceTrackingToken implements TrackingToken, Serializable { @Override public TrackingToken lowerBound(TrackingToken other) { Assert.isTrue(other instanceof MultiSourceTrackingToken, () -> "Incompatible token type provided."); MultiSourceTrackingToken otherMultiToken = (MultiSourceTrackingToken) other; Assert.isTrue(otherMultiToken.trackingTokens.keySet().equals(this.trackingTokens.keySet()), () -> "MultiSourceTrackingTokens contain different keys"); Map<String, TrackingToken> tokenMap = new HashMap<>(); otherMultiToken.trackingTokens .forEach((tokenSourceName, otherToken) -> tokenMap.put(tokenSourceName, trackingTokens.get(tokenSourceName) == null ? null : trackingTokens.get(tokenSourceName).lowerBound(otherToken)) ); return new MultiSourceTrackingToken(tokenMap); } @JsonCreator @ConstructorProperties({"trackingTokens"})  MultiSourceTrackingToken(@JsonProperty("trackingTokens") Map<String, TrackingToken> trackingTokens); }
MultiSourceTrackingToken implements TrackingToken, Serializable { @Override public TrackingToken lowerBound(TrackingToken other) { Assert.isTrue(other instanceof MultiSourceTrackingToken, () -> "Incompatible token type provided."); MultiSourceTrackingToken otherMultiToken = (MultiSourceTrackingToken) other; Assert.isTrue(otherMultiToken.trackingTokens.keySet().equals(this.trackingTokens.keySet()), () -> "MultiSourceTrackingTokens contain different keys"); Map<String, TrackingToken> tokenMap = new HashMap<>(); otherMultiToken.trackingTokens .forEach((tokenSourceName, otherToken) -> tokenMap.put(tokenSourceName, trackingTokens.get(tokenSourceName) == null ? null : trackingTokens.get(tokenSourceName).lowerBound(otherToken)) ); return new MultiSourceTrackingToken(tokenMap); } @JsonCreator @ConstructorProperties({"trackingTokens"})  MultiSourceTrackingToken(@JsonProperty("trackingTokens") Map<String, TrackingToken> trackingTokens); @Override TrackingToken lowerBound(TrackingToken other); @Override TrackingToken upperBound(TrackingToken other); @Override boolean covers(TrackingToken other); MultiSourceTrackingToken advancedTo(String streamName, TrackingToken newTokenForStream); TrackingToken getTokenForStream(String streamName); Map<String, TrackingToken> getTrackingTokens(); @Override OptionalLong position(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
MultiSourceTrackingToken implements TrackingToken, Serializable { @Override public TrackingToken lowerBound(TrackingToken other) { Assert.isTrue(other instanceof MultiSourceTrackingToken, () -> "Incompatible token type provided."); MultiSourceTrackingToken otherMultiToken = (MultiSourceTrackingToken) other; Assert.isTrue(otherMultiToken.trackingTokens.keySet().equals(this.trackingTokens.keySet()), () -> "MultiSourceTrackingTokens contain different keys"); Map<String, TrackingToken> tokenMap = new HashMap<>(); otherMultiToken.trackingTokens .forEach((tokenSourceName, otherToken) -> tokenMap.put(tokenSourceName, trackingTokens.get(tokenSourceName) == null ? null : trackingTokens.get(tokenSourceName).lowerBound(otherToken)) ); return new MultiSourceTrackingToken(tokenMap); } @JsonCreator @ConstructorProperties({"trackingTokens"})  MultiSourceTrackingToken(@JsonProperty("trackingTokens") Map<String, TrackingToken> trackingTokens); @Override TrackingToken lowerBound(TrackingToken other); @Override TrackingToken upperBound(TrackingToken other); @Override boolean covers(TrackingToken other); MultiSourceTrackingToken advancedTo(String streamName, TrackingToken newTokenForStream); TrackingToken getTokenForStream(String streamName); Map<String, TrackingToken> getTrackingTokens(); @Override OptionalLong position(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }