lucasbru commented on code in PR #13957: URL: https://github.com/apache/kafka/pull/13957#discussion_r1258008303
########## streams/src/test/java/org/apache/kafka/streams/processor/internals/tasks/DefaultTaskManagerTest.java: ########## @@ -166,6 +168,44 @@ public void shouldNotAssignAnyLockedTask() { assertNull(taskManager.assignNextTask(taskExecutor)); } + @Test + public void shouldNotSetUncaughtExceptionsForUnassignedTasks() { + taskManager.add(Collections.singleton(task)); + + assertThrows(IllegalArgumentException.class, () -> taskManager.setUncaughtException(exception, task.id())); + } + + @Test + public void shouldNotSetUncaughtExceptionsTwice() { + taskManager.add(Collections.singleton(task)); + when(tasks.activeTasks()).thenReturn(Collections.singleton(task)); + taskManager.assignNextTask(taskExecutor); + taskManager.setUncaughtException(exception, task.id()); + + assertThrows(IllegalArgumentException.class, () -> taskManager.setUncaughtException(exception, task.id())); + } + + @Test + public void shouldReturnExceptionsOnDrainExceptions() { + taskManager.add(Collections.singleton(task)); + when(tasks.activeTasks()).thenReturn(Collections.singleton(task)); + taskManager.assignNextTask(taskExecutor); + taskManager.setUncaughtException(exception, task.id()); + + assertEquals(taskManager.drainUncaughtExceptions(), Collections.singletonMap(task.id(), exception)); + } + + @Test + public void shouldClearExceptionsOnDrainExceptions() { + taskManager.add(Collections.singleton(task)); + when(tasks.activeTasks()).thenReturn(Collections.singleton(task)); + taskManager.assignNextTask(taskExecutor); + taskManager.setUncaughtException(exception, task.id()); + taskManager.drainUncaughtExceptions(); + + assertEquals(taskManager.drainUncaughtExceptions(), Collections.emptyMap()); + } Review Comment: Done -- 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