From 81d5bcbf8bfcc46195f44f0600fd4a05dc7ee367 Mon Sep 17 00:00:00 2001
From: roost-io <8110509+mgdevstack@users.noreply.github.com>
Date: Thu, 7 May 2026 12:37:40 +0530
Subject: [PATCH] Unit test generated by RoostGPT
Using AI Model gpt-5
---
core/pom.xml | 21 ++-
.../LlmRequestGetSystemInstructionsTest.java | 170 ++++++++++++++++++
pom.xml | 79 ++++++--
3 files changed, 246 insertions(+), 24 deletions(-)
create mode 100644 core/src/test/java/com/google/adk/models/LlmRequestGetSystemInstructionsTest.java
diff --git a/core/pom.xml b/core/pom.xml
index fe65715f3..7d2032c7e 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -1,4 +1,4 @@
-
+
4.0.0
-
com.google.adk
google-adk-parent
- 0.4.1-SNAPSHOT
+ 0.4.1-SNAPSHOT
+
-
google-adk
Agent Development Kit
Agent Development Kit: an open-source, code-first toolkit designed to simplify building, evaluating, and deploying advanced AI agents anywhere.
-
-
-
com.anthropic
@@ -201,6 +197,15 @@
maven-compiler-plugin
+
+ io.spring.javaformat
+ spring-javaformat-maven-plugin
+ 0.0.40
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/core/src/test/java/com/google/adk/models/LlmRequestGetSystemInstructionsTest.java b/core/src/test/java/com/google/adk/models/LlmRequestGetSystemInstructionsTest.java
new file mode 100644
index 000000000..3f744f9f9
--- /dev/null
+++ b/core/src/test/java/com/google/adk/models/LlmRequestGetSystemInstructionsTest.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// ********RoostGPT********
+/*
+Test generated by RoostGPT for test unit-java-adk using AI Type Azure Open AI and AI Model gpt-5
+
+ROOST_METHOD_HASH=getSystemInstructions_ef573ffc35
+ROOST_METHOD_SIG_HASH=getSystemInstructions_9fece2ef08
+
+[]
+*/
+
+// ********RoostGPT********
+
+package com.google.adk.models;
+
+import static org.mockito.Mockito.when;
+import com.google.common.collect.ImmutableList;
+import com.google.common.truth.Truth;
+import com.google.genai.types.Content;
+import com.google.genai.types.GenerateContentConfig;
+import com.google.genai.types.Part;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Test;
+import org.junit.experimental.runners.Enclosed;
+import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Tag;
+import org.junit.Rule;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.junit.jupiter.api.*;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableList.toImmutableList;
+import static com.google.common.collect.ImmutableMap.toImmutableMap;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.adk.JsonBaseModel;
+import com.google.adk.tools.BaseTool;
+import com.google.auto.value.AutoValue;
+import com.google.common.collect.ImmutableMap;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
+import com.google.genai.types.LiveConnectConfig;
+import com.google.genai.types.Schema;
+import java.util.Map;
+import java.util.stream.Stream;
+
+@RunWith(Enclosed.class)
+public class LlmRequestGetSystemInstructionsTest {
+
+ public static class GetSystemInstructionsScenarios {
+
+ @Rule
+ public MockitoRule rule = MockitoJUnit.rule();
+
+ /*
+ * Scenario: No config present returns empty list Execution: Build LlmRequest with
+ * no config and call getSystemInstructions Validation: Assert returned list is an
+ * empty ImmutableList
+ */
+ @Test
+ @Tag("boundary")
+ public void getSystemInstructions_noConfig_returnsEmptyList() {
+ LlmRequest request = LlmRequest.builder().build();
+ ImmutableList result = request.getSystemInstructions();
+ Truth.assertThat((Object) result).isInstanceOf(ImmutableList.class);
+ Truth.assertThat((List) result).isEmpty();
+ }
+
+ /*
+ * Scenario: Config present but no systemInstruction returns empty list Execution:
+ * Mock GenerateContentConfig.systemInstruction() to Optional.empty and set on
+ * request Validation: Assert returned list is empty
+ */
+ @Test
+ @Tag("invalid")
+ public void getSystemInstructions_configWithoutSystemInstruction_returnsEmptyList() {
+ GenerateContentConfig cfg = Mockito.mock(GenerateContentConfig.class);
+ when(cfg.systemInstruction()).thenReturn(Optional.empty());
+ LlmRequest request = LlmRequest.builder().config(cfg).build();
+ ImmutableList result = request.getSystemInstructions();
+ Truth.assertThat((List) result).isEmpty();
+ }
+
+ /*
+ * Scenario: systemInstruction present but parts empty returns empty list
+ * Execution: Mock Content.parts() to Optional.empty and wire through
+ * GenerateContentConfig Validation: Assert returned list is empty
+ */
+ @Test
+ @Tag("invalid")
+ public void getSystemInstructions_systemInstructionWithoutParts_returnsEmptyList() {
+ Content content = Mockito.mock(Content.class);
+ when(content.parts()).thenReturn(Optional.empty());
+ GenerateContentConfig cfg = Mockito.mock(GenerateContentConfig.class);
+ when(cfg.systemInstruction()).thenReturn(Optional.of(content));
+ LlmRequest request = LlmRequest.builder().config(cfg).build();
+ ImmutableList result = request.getSystemInstructions();
+ Truth.assertThat((List) result).isEmpty();
+ }
+
+ /*
+ * Scenario: parts with empty texts are omitted Execution: Create parts where some
+ * Part.text() are Optional.empty and one has text; collect results Validation:
+ * Assert only non-empty texts appear in order
+ */
+ @Test
+ @Tag("valid")
+ public void getSystemInstructions_filtersEmptyTexts_keepsNonEmptyInOrder() {
+ Part emptyTextPart = Mockito.mock(Part.class);
+ when(emptyTextPart.text()).thenReturn(Optional.empty());
+ Part validPart1 = Mockito.mock(Part.class);
+ when(validPart1.text()).thenReturn(Optional.of("alpha"));
+ Part validPart2Empty = Mockito.mock(Part.class);
+ when(validPart2Empty.text()).thenReturn(Optional.empty());
+ Part validPart2 = Mockito.mock(Part.class);
+ when(validPart2.text()).thenReturn(Optional.of("beta"));
+ List parts = Arrays.asList(emptyTextPart, validPart1, validPart2Empty, validPart2);
+ Content content = Mockito.mock(Content.class);
+ when(content.parts()).thenReturn(Optional.of(parts));
+ GenerateContentConfig cfg = Mockito.mock(GenerateContentConfig.class);
+ when(cfg.systemInstruction()).thenReturn(Optional.of(content));
+ LlmRequest request = LlmRequest.builder().config(cfg).build();
+ ImmutableList result = request.getSystemInstructions();
+ Truth.assertThat((List) result).containsExactly((String) "alpha", (String) "beta").inOrder();
+ }
+
+ /*
+ * Scenario: multiple parts with texts are returned in order Execution: Parts list
+ * with two text values; expect both in same order Validation: Assert list equals
+ * expected order
+ */
+ @Test
+ @Tag("integration")
+ public void getSystemInstructions_multiplePartsTexts_returnedInEncounterOrder() {
+ Part p1 = Mockito.mock(Part.class);
+ when(p1.text()).thenReturn(Optional.of("first"));
+ Part p2 = Mockito.mock(Part.class);
+ when(p2.text()).thenReturn(Optional.of("second"));
+ Content content = Mockito.mock(Content.class);
+ when(content.parts()).thenReturn(Optional.of(Arrays.asList(p1, p2)));
+ GenerateContentConfig cfg = Mockito.mock(GenerateContentConfig.class);
+ when(cfg.systemInstruction()).thenReturn(Optional.of(content));
+ LlmRequest request = LlmRequest.builder().config(cfg).build();
+ ImmutableList result = request.getSystemInstructions();
+ Truth.assertThat((List) result).containsExactly((String) "first", (String) "second").inOrder();
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 6009c7316..b21618b54 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,4 @@
-
+
-
+
4.0.0
-
com.google.adk
google-adk-parent
- 0.4.1-SNAPSHOT
+ 0.4.1-SNAPSHOT
+
pom
-
Google Agent Development Kit Maven Parent POM
https://github.com/google/adk-java
Google Agent Development Kit (ADK) for Java
-
core
dev
@@ -39,12 +35,10 @@
a2a
a2a/webservice
-
17
${java.version}
UTF-8
-
1.11.0
3.4.1
1.49.0
@@ -73,7 +67,6 @@
3.9.0
5.4.3
-
@@ -112,7 +105,6 @@
pom
import
-
com.anthropic
@@ -274,9 +266,21 @@
assertj-core
${assertj.version}
+
+ org.mockito
+ mockito-junit-jupiter
+ 5.2.0
+ test
+
+
+
+ io.spring.javaformat
+ spring-javaformat-formatter
+ 0.0.40
+
+
-
@@ -324,8 +328,7 @@
plain
-
+
**/*Test.java
@@ -469,6 +472,36 @@
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.2.5
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-report-plugin
+ 3.2.5
+
+ testReport
+
+
+
+
+ org.apache.maven.plugins
+ maven-site-plugin
+ 2.1
+
+ testReport
+
+
+
+
+ io.spring.javaformat
+ spring-javaformat-maven-plugin
+ 0.0.40
+
+
@@ -528,7 +561,6 @@
-
The Apache License, Version 2.0
@@ -558,4 +590,19 @@
https://central.sonatype.com/repository/maven-snapshots/
+
+
+ org.mockito
+ mockito-junit-jupiter
+ 5.2.0
+ test
+
+
+
+ io.spring.javaformat
+ spring-javaformat-formatter
+ 0.0.40
+
+
+
\ No newline at end of file