Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0"?>
<!--
Copyright 2025 Google LLC

Expand All @@ -16,19 +16,15 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.google.adk</groupId>
<artifactId>google-adk-parent</artifactId>
<version>0.4.1-SNAPSHOT</version><!-- {x-version-update:google-adk:current} -->
<version>0.4.1-SNAPSHOT</version>
<!-- {x-version-update:google-adk:current} -->
</parent>

<artifactId>google-adk</artifactId>
<name>Agent Development Kit</name>
<description>Agent Development Kit: an open-source, code-first toolkit designed to simplify building, evaluating, and deploying advanced AI agents anywhere.</description>



<dependencies>
<dependency>
<groupId>com.anthropic</groupId>
Expand Down Expand Up @@ -201,6 +197,15 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
<version>0.0.40</version>
<!--Plugin added by RoostGPT-->
</plugin>
</plugins>
<pluginManagement>
<plugins/>
</pluginManagement>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -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<String> result = request.getSystemInstructions();
Truth.assertThat((Object) result).isInstanceOf(ImmutableList.class);
Truth.assertThat((List<String>) 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<String> result = request.getSystemInstructions();
Truth.assertThat((List<String>) 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<String> result = request.getSystemInstructions();
Truth.assertThat((List<String>) 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<Part> 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<String> result = request.getSystemInstructions();
Truth.assertThat((List<String>) 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<String> result = request.getSystemInstructions();
Truth.assertThat((List<String>) result).containsExactly((String) "first", (String) "second").inOrder();
}

}

}
79 changes: 63 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0"?>
<!-- Copyright 2025 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -12,20 +12,16 @@
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. -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.google.adk</groupId>
<artifactId>google-adk-parent</artifactId>
<version>0.4.1-SNAPSHOT</version><!-- {x-version-update:google-adk:current} -->
<version>0.4.1-SNAPSHOT</version>
<!-- {x-version-update:google-adk:current} -->
<packaging>pom</packaging>

<name>Google Agent Development Kit Maven Parent POM</name>
<url>https://github.com/google/adk-java</url>
<description>Google Agent Development Kit (ADK) for Java</description>

<modules>
<module>core</module>
<module>dev</module>
Expand All @@ -39,12 +35,10 @@
<module>a2a</module>
<module>a2a/webservice</module>
</modules>

<properties>
<java.version>17</java.version>
<maven.compiler.release>${java.version}</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<auto-value.version>1.11.0</auto-value.version>
<spring-boot.version>3.4.1</spring-boot.version>
<otel.version>1.49.0</otel.version>
Expand Down Expand Up @@ -73,7 +67,6 @@
<maven-plugin-tools.version>3.9.0</maven-plugin-tools.version>
<httpclient5.version>5.4.3</httpclient5.version>
</properties>

<dependencyManagement>
<dependencies>
<!-- BOMs for dependency management -->
Expand Down Expand Up @@ -112,7 +105,6 @@
<type>pom</type>
<scope>import</scope>
</dependency>

<!-- Direct dependencies -->
<dependency>
<groupId>com.anthropic</groupId>
Expand Down Expand Up @@ -274,9 +266,21 @@
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>5.2.0</version>
<scope>test</scope>
<!--Dependency added by RoostGPT-->
</dependency>
<dependency>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-formatter</artifactId>
<version>0.0.40</version>
<!--Dependency added by RoostGPT-->
</dependency>
</dependencies>
</dependencyManagement>

<build>
<extensions>
<extension>
Expand Down Expand Up @@ -324,8 +328,7 @@
</dependencies>
<configuration>
<reportFormat>plain</reportFormat>
<statelessTestsetInfoReporter
implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter" />
<statelessTestsetInfoReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter"/>
<includes>
<include>**/*Test.java</include>
</includes>
Expand Down Expand Up @@ -469,6 +472,36 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<!--Plugin added by RoostGPT-->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.2.5</version>
<configuration>
<outputDirectory>testReport</outputDirectory>
</configuration>
<!--Plugin added by RoostGPT-->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>2.1</version>
<configuration>
<outputDirectory>testReport</outputDirectory>
</configuration>
<!--Plugin added by RoostGPT-->
</plugin>
<plugin>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
<version>0.0.40</version>
<!--Plugin added by RoostGPT-->
</plugin>
</plugins>
</build>
<profiles>
Expand Down Expand Up @@ -528,7 +561,6 @@
</build>
</profile>
</profiles>

<licenses>
<license>
<name>The Apache License, Version 2.0</name>
Expand Down Expand Up @@ -558,4 +590,19 @@
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>5.2.0</version>
<scope>test</scope>
<!--Dependency added by RoostGPT-->
</dependency>
<dependency>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-formatter</artifactId>
<version>0.0.40</version>
<!--Dependency added by RoostGPT-->
</dependency>
</dependencies>
</project>