@Test void doesNotCover() { Map<String, TrackingToken> newTokens = new HashMap<>(); newTokens.put("token1", new GlobalSequenceTrackingToken(1)); newTokens.put("token2", new GlobalSequenceTrackingToken(0)); assertFalse(testSubject.covers(new MultiSourceTrackingToken(newTokens))); }
@Override public boolean covers(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"); for (Map.Entry<String, TrackingToken> trackingTokenEntry : trackingTokens.entrySet()) { TrackingToken constituent = trackingTokenEntry.getValue(); TrackingToken otherConstituent = otherMultiToken.trackingTokens.get(trackingTokenEntry.getKey()); if (constituent == null) { if (otherConstituent != null) { return false; } } else if (otherConstituent != null && !constituent.covers(otherConstituent)) { return false; } } return true; }
MultiSourceTrackingToken implements TrackingToken, Serializable { @Override public boolean covers(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"); for (Map.Entry<String, TrackingToken> trackingTokenEntry : trackingTokens.entrySet()) { TrackingToken constituent = trackingTokenEntry.getValue(); TrackingToken otherConstituent = otherMultiToken.trackingTokens.get(trackingTokenEntry.getKey()); if (constituent == null) { if (otherConstituent != null) { return false; } } else if (otherConstituent != null && !constituent.covers(otherConstituent)) { return false; } } return true; } }
MultiSourceTrackingToken implements TrackingToken, Serializable { @Override public boolean covers(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"); for (Map.Entry<String, TrackingToken> trackingTokenEntry : trackingTokens.entrySet()) { TrackingToken constituent = trackingTokenEntry.getValue(); TrackingToken otherConstituent = otherMultiToken.trackingTokens.get(trackingTokenEntry.getKey()); if (constituent == null) { if (otherConstituent != null) { return false; } } else if (otherConstituent != null && !constituent.covers(otherConstituent)) { return false; } } return true; } @JsonCreator @ConstructorProperties({"trackingTokens"})  MultiSourceTrackingToken(@JsonProperty("trackingTokens") Map<String, TrackingToken> trackingTokens); }
MultiSourceTrackingToken implements TrackingToken, Serializable { @Override public boolean covers(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"); for (Map.Entry<String, TrackingToken> trackingTokenEntry : trackingTokens.entrySet()) { TrackingToken constituent = trackingTokenEntry.getValue(); TrackingToken otherConstituent = otherMultiToken.trackingTokens.get(trackingTokenEntry.getKey()); if (constituent == null) { if (otherConstituent != null) { return false; } } else if (otherConstituent != null && !constituent.covers(otherConstituent)) { return false; } } return true; } @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 boolean covers(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"); for (Map.Entry<String, TrackingToken> trackingTokenEntry : trackingTokens.entrySet()) { TrackingToken constituent = trackingTokenEntry.getValue(); TrackingToken otherConstituent = otherMultiToken.trackingTokens.get(trackingTokenEntry.getKey()); if (constituent == null) { if (otherConstituent != null) { return false; } } else if (otherConstituent != null && !constituent.covers(otherConstituent)) { return false; } } return true; } @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();  }