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,186 @@
// ********RoostGPT********
/*
Test generated by RoostGPT for test unit-java-adk using AI Type Azure Open AI and AI Model gpt-5

ROOST_METHOD_HASH=content_f95ec3ddc9
ROOST_METHOD_SIG_HASH=content_accc65ce1a


Scenario 1: Returns the same Content instance that was supplied at construction

Details:
TestName: returnsSameContentInstance
Description: Verify that the content() method returns the exact Content object that was used to build the AutoValue_MemoryEntry instance (reference identity, not a copy).

Execution:
Arrange: Create a valid Content instance (e.g., a concrete instance or a simple test double) and build a MemoryEntry via the Builder with that Content.
Act: Call content() on the built MemoryEntry.
Assert: Use JUnit assertions to confirm that the returned Content is the same object instance as the one provided during construction (reference equality).

Validation:
This assertion verifies that content() is a simple accessor returning the internal field without copying or transforming it. It ensures the method exposes the exact Content reference stored in the entry, which is important for consumers relying on object identity or avoiding unnecessary allocations.

*/

// ********RoostGPT********
package com.google.adk.memory;

import static org.junit.jupiter.api.Assertions.*;

import com.google.genai.types.Content;
import javax.annotation.processing.Generated;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

@Generated("AutoValueMemoryEntryContentTest")
@ExtendWith(MockitoExtension.class)
public class AutoValueMemoryEntryContentTest {

@Mock private Content contentMock;

@Mock private Content otherContentMock;

@Test
@Tag("valid")
@DisplayName(
"returnsSameContentInstance: content() returns the exact Content instance supplied at construction")
public void testReturnsSameContentInstance() {
MemoryEntry entry =
MemoryEntry.builder()
.content(contentMock)
.author("author-1")
.timestamp("2023-01-01T00:00:00Z")
.build();
Content actual = entry.content();
assertSame(
(Object) contentMock,
(Object) actual,
"Expected content() to return the same Content instance");
}

@Test
@Tag("valid")
@DisplayName("contentIsNotNullWhenConstructedWithValidContent")
public void testContentIsNotNull() {
MemoryEntry entry =
MemoryEntry.builder()
.content(contentMock)
.author("author-2")
.timestamp("2024-01-01T12:34:56Z")
.build();
Content actual = entry.content();
assertNotNull((Object) actual, "Expected non-null Content from content()");
}

@Test
@Tag("valid")
@DisplayName(
"contentReferencePreservedByToBuilder: toBuilder().build() preserves original content reference")
public void testContentReferencePreservedByToBuilder() {
MemoryEntry original =
MemoryEntry.builder()
.content(contentMock)
.author("author-3")
.timestamp("2025-05-05T05:05:05Z")
.build();
MemoryEntry copied = original.toBuilder().build();
assertSame(
(Object) original.content(),
(Object) copied.content(),
"Expected copied entry to preserve same Content reference");
}

@Test
@Tag("valid")
@DisplayName(
"contentReferenceChangesWhenReplaced: toBuilder().content(new).build() updates content reference")
public void testContentReferenceChangesWhenReplaced() {
MemoryEntry original =
MemoryEntry.builder()
.content(contentMock)
.author("author-4")
.timestamp("2026-06-06T06:06:06Z")
.build();
MemoryEntry updated = original.toBuilder().content(otherContentMock).build();
assertSame(
(Object) otherContentMock,
(Object) updated.content(),
"Expected updated entry to return the new Content reference");
assertNotSame(
(Object) original.content(),
(Object) updated.content(),
"Expected updated entry content to differ from original content");
}

@Test
@Tag("boundary")
@DisplayName(
"builderAllowsNullOptionalFields: author and timestamp can be null without affecting content")
public void testBuilderAllowsNullAuthorAndTimestamp() {
MemoryEntry entry =
MemoryEntry.builder()
.content(contentMock)
.author((String) null)
.timestamp((String) null)
.build();
assertSame(
(Object) contentMock,
(Object) entry.content(),
"Expected content() to return the provided Content instance");
assertNull((String) entry.author(), "Expected author() to be null when not provided");
assertNull((String) entry.timestamp(), "Expected timestamp() to be null when not provided");
}

@Test
@Tag("invalid")
@DisplayName("buildingWithNullContentThrows: builder rejects null content")
public void testBuildingWithNullContentThrowsException() {
NullPointerException ex =
assertThrows(
NullPointerException.class,
() ->
MemoryEntry.builder()
.content((Content) null) // Explicit cast to avoid ambiguity
.author("author-5")
.timestamp("2027-07-07T07:07:07Z")
.build(),
"Expected NullPointerException when content is null");
assertNotNull((Object) ex, "Expected an exception instance to be thrown");
}

@Test
@Tag("valid")
@DisplayName(
"distinctEntriesSameContentRef: different entries built with the same Content reference return the same instance via content()")
public void testDistinctEntriesWithSameContentReturnSameReference() {
MemoryEntry entryA =
MemoryEntry.builder()
.content(contentMock)
.author("author-A")
.timestamp("2028-08-08T08:08:08Z")
.build();
MemoryEntry entryB =
MemoryEntry.builder()
.content(contentMock) // reusing the same reference
.author("author-B")
.timestamp("2029-09-09T09:09:09Z")
.build();
assertSame(
(Object) contentMock,
(Object) entryA.content(),
"Expected entryA to return same Content reference supplied");
assertSame(
(Object) contentMock,
(Object) entryB.content(),
"Expected entryB to return same Content reference supplied");
assertSame(
(Object) entryA.content(),
(Object) entryB.content(),
"Expected both entries to return the same Content reference");
}
}
Loading