chia7712 commented on code in PR #15862: URL: https://github.com/apache/kafka/pull/15862#discussion_r1622894813
########## core/src/test/java/kafka/test/junit/ClusterTestExtensionsUnitTest.java: ########## @@ -17,29 +17,64 @@ package kafka.test.junit; +import kafka.test.ClusterConfig; import kafka.test.annotation.ClusterTemplate; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.extension.ExtensionContext; + +import java.lang.reflect.Method; +import java.util.Collections; +import java.util.List; + import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class ClusterTestExtensionsUnitTest { + + static List<ClusterConfig> cfgEmpty() { + return Collections.emptyList(); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + private ExtensionContext buildExtensionContext(String methodName) throws Exception { + ExtensionContext extensionContext = mock(ExtensionContext.class); + Class clazz = ClusterTestExtensionsUnitTest.class; + Method method = clazz.getDeclaredMethod(methodName); + when(extensionContext.getRequiredTestClass()).thenReturn(clazz); + when(extensionContext.getRequiredTestMethod()).thenReturn(method); + return extensionContext; + } + @Test - void testProcessClusterTemplate() { + void testProcessClusterTemplate() throws Exception { ClusterTestExtensions ext = new ClusterTestExtensions(); - ExtensionContext context = mock(ExtensionContext.class); + ExtensionContext context = buildExtensionContext("cfgEmpty"); ClusterTemplate annot = mock(ClusterTemplate.class); - when(annot.value()).thenReturn("").thenReturn(" "); + when(annot.value()).thenReturn("").thenReturn(" ").thenReturn("cfgEmpty"); + + Assertions.assertEquals( Review Comment: This test is equal to next one, right? -- 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