@Test void testPositionNotProvidedWhenUnderlyingTokensDontProvide() { TrackingToken trackingToken = mock(TrackingToken.class); when(trackingToken.position()).thenReturn(OptionalLong.empty()); testSubject = new MultiSourceTrackingToken(Collections.singletonMap("key", trackingToken)); assertFalse(testSubject.position().isPresent()); }
@Override public OptionalLong position() { if (trackingTokens.entrySet().stream().noneMatch(token -> token.getValue() != null && token.getValue().position().isPresent())) { return OptionalLong.empty(); } long sumOfTokens = trackingTokens.values().stream() .filter(Objects::nonNull) .mapToLong(trackingToken -> trackingToken.position().orElse(0L)) .sum(); return OptionalLong.of(sumOfTokens); }
MultiSourceTrackingToken implements TrackingToken, Serializable { @Override public OptionalLong position() { if (trackingTokens.entrySet().stream().noneMatch(token -> token.getValue() != null && token.getValue().position().isPresent())) { return OptionalLong.empty(); } long sumOfTokens = trackingTokens.values().stream() .filter(Objects::nonNull) .mapToLong(trackingToken -> trackingToken.position().orElse(0L)) .sum(); return OptionalLong.of(sumOfTokens); } }
MultiSourceTrackingToken implements TrackingToken, Serializable { @Override public OptionalLong position() { if (trackingTokens.entrySet().stream().noneMatch(token -> token.getValue() != null && token.getValue().position().isPresent())) { return OptionalLong.empty(); } long sumOfTokens = trackingTokens.values().stream() .filter(Objects::nonNull) .mapToLong(trackingToken -> trackingToken.position().orElse(0L)) .sum(); return OptionalLong.of(sumOfTokens); } @JsonCreator @ConstructorProperties({"trackingTokens"})  MultiSourceTrackingToken(@JsonProperty("trackingTokens") Map<String, TrackingToken> trackingTokens); }
MultiSourceTrackingToken implements TrackingToken, Serializable { @Override public OptionalLong position() { if (trackingTokens.entrySet().stream().noneMatch(token -> token.getValue() != null && token.getValue().position().isPresent())) { return OptionalLong.empty(); } long sumOfTokens = trackingTokens.values().stream() .filter(Objects::nonNull) .mapToLong(trackingToken -> trackingToken.position().orElse(0L)) .sum(); return OptionalLong.of(sumOfTokens); } @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 OptionalLong position() { if (trackingTokens.entrySet().stream().noneMatch(token -> token.getValue() != null && token.getValue().position().isPresent())) { return OptionalLong.empty(); } long sumOfTokens = trackingTokens.values().stream() .filter(Objects::nonNull) .mapToLong(trackingToken -> trackingToken.position().orElse(0L)) .sum(); return OptionalLong.of(sumOfTokens); } @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();  }