Source:
<code>private void testOffsetValidationWithGivenEpochOffset(final EpochEndOffset epochEndOffset, OffsetResetStrategy offsetResetStrategy) { buildFetcher(offsetResetStrategy); assignFromUser(singleton(tp0)); Map<String, Integer> partitionCounts = new HashMap<>(); partitionCounts.put(tp0.topic(), 4); final int epochOne = 1; metadata.updateWithCurrentRequestVersion(TestUtils.metadataUpdateWith("dummy", 1, Collections.emptyMap(), partitionCounts, tp -> epochOne), false, 0L); Node node = metadata.fetch().nodes().get(0); apiVersions.update(node.idString(), NodeApiVersions.create()); Metadata.LeaderAndEpoch leaderAndEpoch = new Metadata.LeaderAndEpoch(metadata.currentLeader(tp0).leader, Optional.of(epochOne)); subscriptions.seekUnvalidated(tp0, new SubscriptionState.FetchPosition(0, Optional.of(epochOne), leaderAndEpoch)); fetcher.validateOffsetsIfNeeded(); consumerClient.poll(time.timer(Duration.ZERO)); assertTrue(subscriptions.awaitingValidation(tp0)); assertTrue(client.hasInFlightRequests()); client.respond(request -> { OffsetsForLeaderEpochRequest epochRequest = (OffsetsForLeaderEpochRequest) request; OffsetsForLeaderEpochRequest.PartitionData partitionData = epochRequest.epochsByTopicPartition().get(tp0); return partitionData.currentLeaderEpoch.equals(Optional.of(epochOne)) && partitionData.leaderEpoch == epochOne; }, new OffsetsForLeaderEpochResponse(singletonMap(tp0, epochEndOffset))); consumerClient.poll(time.timer(Duration.ZERO)); assertEquals(0, subscriptions.position(tp0).offset); if (offsetResetStrategy == OffsetResetStrategy.NONE) { assertTrue(subscriptions.awaitingValidation(tp0)); } else { <START> assertFalse(subscriptions.awaitingValidation(tp0)); <END> } }</code><technical_language>Hmm.. assert raised exception somehow? clear is raised appropriately tests for it</technical_language>

Target:
private void testOffsetValidationWithGivenEpochOffset(final EpochEndOffset epochEndOffset, OffsetResetStrategy offsetResetStrategy) { buildFetcher(offsetResetStrategy); assignFromUser(singleton(tp0)); Map<String, Integer> partitionCounts = new HashMap<>(); partitionCounts.put(tp0.topic(), 4); final int epochOne = 1; final long initialOffset = 5; metadata.updateWithCurrentRequestVersion(TestUtils.metadataUpdateWith("dummy", 1, Collections.emptyMap(), partitionCounts, tp -> epochOne), false, 0L); Node node = metadata.fetch().nodes().get(0); apiVersions.update(node.idString(), NodeApiVersions.create()); Metadata.LeaderAndEpoch leaderAndEpoch = new Metadata.LeaderAndEpoch(metadata.currentLeader(tp0).leader, Optional.of(epochOne)); subscriptions.seekUnvalidated(tp0, new SubscriptionState.FetchPosition(initialOffset, Optional.of(epochOne), leaderAndEpoch)); fetcher.validateOffsetsIfNeeded(); consumerClient.poll(time.timer(Duration.ZERO)); assertTrue(subscriptions.awaitingValidation(tp0)); assertTrue(client.hasInFlightRequests()); client.respond(request -> { OffsetsForLeaderEpochRequest epochRequest = (OffsetsForLeaderEpochRequest) request; OffsetsForLeaderEpochRequest.PartitionData partitionData = epochRequest.epochsByTopicPartition().get(tp0); return partitionData.currentLeaderEpoch.equals(Optional.of(epochOne)) && partitionData.leaderEpoch == epochOne; }, new OffsetsForLeaderEpochResponse(singletonMap(tp0, epochEndOffset))); consumerClient.poll(time.timer(Duration.ZERO)); assertEquals(initialOffset, subscriptions.position(tp0).offset); if (offsetResetStrategy == OffsetResetStrategy.NONE) { OffsetOutOfRangeException thrown = assertThrows(OffsetOutOfRangeException.class, () -> fetcher.validateOffsetsIfNeeded()); if (!epochEndOffset.hasUndefinedEpochOrOffset()) { assertTrue(thrown instanceof LogTruncationException); } assertTrue(subscriptions.awaitingValidation(tp0)); } else { fetcher.validateOffsetsIfNeeded(); assertFalse(subscriptions.awaitingValidation(tp0)); } }