bachmanity1 commented on code in PR #14153: URL: https://github.com/apache/kafka/pull/14153#discussion_r1286933684
########## connect/runtime/src/test/java/org/apache/kafka/connect/util/KafkaBasedLogTest.java: ########## @@ -531,48 +478,28 @@ public void testReadEndOffsetsUsingAdminThatFailsWithRetriable() throws Exceptio endOffsets.put(TP0, 0L); endOffsets.put(TP1, 0L); // Getting end offsets upon startup should work fine - admin.retryEndOffsets(EasyMock.eq(tps), EasyMock.anyObject(), EasyMock.anyLong()); - PowerMock.expectLastCall().andReturn(endOffsets).times(1); + when(admin.retryEndOffsets(eq(tps), any(), anyLong())).thenReturn(endOffsets); // Getting end offsets using the admin client should fail with leader not available - admin.endOffsets(EasyMock.eq(tps)); - PowerMock.expectLastCall().andThrow(new LeaderNotAvailableException("retry")); - - PowerMock.replayAll(); + when(admin.endOffsets(eq(tps))).thenThrow(new LeaderNotAvailableException("retry")); store.start(); assertThrows(LeaderNotAvailableException.class, () -> store.readEndOffsets(tps, false)); } - @SuppressWarnings("unchecked") private void setupWithAdmin() { Supplier<TopicAdmin> adminSupplier = () -> admin; java.util.function.Consumer<TopicAdmin> initializer = admin -> { }; - store = PowerMock.createPartialMock(KafkaBasedLog.class, new String[]{"createConsumer", "createProducer"}, - TOPIC, PRODUCER_PROPS, CONSUMER_PROPS, adminSupplier, consumedCallback, time, initializer); - } - - private void expectProducerAndConsumerCreate() throws Exception { - PowerMock.expectPrivate(store, "createProducer") - .andReturn(producer); - PowerMock.expectPrivate(store, "createConsumer") - .andReturn(consumer); - } - - private void expectStart() throws Exception { - initializer.run(); - EasyMock.expectLastCall().times(1); - - expectProducerAndConsumerCreate(); + store = spy(new KafkaBasedLog<>(TOPIC, PRODUCER_PROPS, CONSUMER_PROPS, adminSupplier, consumedCallback, time, initializer)); Review Comment: yes, I think we can merge `setupWithAdmin` into `setUp`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org