diff --git a/core/src/test/java/com/google/adk/flows/llmflows/RequestConfirmationLlmRequestProcessorTest.java b/core/src/test/java/com/google/adk/flows/llmflows/RequestConfirmationLlmRequestProcessorTest.java index 815477c7..b93e02ed 100644 --- a/core/src/test/java/com/google/adk/flows/llmflows/RequestConfirmationLlmRequestProcessorTest.java +++ b/core/src/test/java/com/google/adk/flows/llmflows/RequestConfirmationLlmRequestProcessorTest.java @@ -36,38 +36,35 @@ import com.google.genai.types.FunctionCall; import com.google.genai.types.FunctionResponse; import com.google.genai.types.Part; +import java.util.Optional; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public class RequestConfirmationLlmRequestProcessorTest { - private static final String ORIGINAL_FUNCTION_CALL_ID = "fc0"; - private static final String REQUEST_CONFIRMATION_FUNCTION_CALL_ID = "fc1"; private static final String ECHO_TOOL_NAME = "echo_tool"; + private static final String ORIGINAL_FUNCTION_CALL_ID = "original_fc_id"; + private static final ImmutableMap ORIGINAL_FUNCTION_CALL_ARGS = + ImmutableMap.of("say", "hello"); + private static final String FUNCTION_CALL_ID = "fc_id"; + private static final ImmutableMap ARGS = + ImmutableMap.of( + "originalFunctionCall", + ImmutableMap.of( // original function call as a map + "id", + Optional.of("original_fc_id"), + "name", + Optional.of(ECHO_TOOL_NAME), + "args", + Optional.of(ORIGINAL_FUNCTION_CALL_ARGS))); + private static final FunctionCall FUNCTION_CALL = + FunctionCall.builder().id(FUNCTION_CALL_ID).name(ECHO_TOOL_NAME).args(ARGS).build(); private static final Event REQUEST_CONFIRMATION_EVENT = Event.builder() .author("model") - .content( - Content.fromParts( - Part.builder() - .functionCall( - FunctionCall.builder() - .id(REQUEST_CONFIRMATION_FUNCTION_CALL_ID) - .name(REQUEST_CONFIRMATION_FUNCTION_CALL_NAME) - .args( - ImmutableMap.of( - "originalFunctionCall", - ImmutableMap.of( - "id", - ORIGINAL_FUNCTION_CALL_ID, - "name", - ECHO_TOOL_NAME, - "args", - ImmutableMap.of("say", "hello")))) - .build()) - .build())) + .content(Content.fromParts(Part.builder().functionCall(FUNCTION_CALL).build())) .build(); private static final Event USER_CONFIRMATION_EVENT = @@ -78,7 +75,7 @@ public class RequestConfirmationLlmRequestProcessorTest { Part.builder() .functionResponse( FunctionResponse.builder() - .id(REQUEST_CONFIRMATION_FUNCTION_CALL_ID) + .id(FUNCTION_CALL_ID) .name(REQUEST_CONFIRMATION_FUNCTION_CALL_NAME) .response(ImmutableMap.of("confirmed", true)) .build()) @@ -93,7 +90,7 @@ public class RequestConfirmationLlmRequestProcessorTest { Part.builder() .functionResponse( FunctionResponse.builder() - .id(REQUEST_CONFIRMATION_FUNCTION_CALL_ID) + .id(FUNCTION_CALL_ID) .name(REQUEST_CONFIRMATION_FUNCTION_CALL_NAME) .response(ImmutableMap.of("confirmed", false)) .build()) @@ -123,7 +120,7 @@ public void runAsync_withConfirmation_callsOriginalFunction() { FunctionResponse fr = event.functionResponses().get(0); assertThat(fr.id()).hasValue(ORIGINAL_FUNCTION_CALL_ID); assertThat(fr.name()).hasValue(ECHO_TOOL_NAME); - assertThat(fr.response()).hasValue(ImmutableMap.of("result", ImmutableMap.of("say", "hello"))); + assertThat(fr.response()).hasValue(ImmutableMap.of("result", ORIGINAL_FUNCTION_CALL_ARGS)); } @Test @@ -163,8 +160,7 @@ public void runAsync_withConfirmationAndToolAlreadyCalled_doesNotCallOriginalFun FunctionResponse.builder() .id(ORIGINAL_FUNCTION_CALL_ID) .name(ECHO_TOOL_NAME) - .response( - ImmutableMap.of("result", ImmutableMap.of("say", "hello"))) + .response(ImmutableMap.of("result", ORIGINAL_FUNCTION_CALL_ARGS)) .build()) .build())) .build();