Skip to content

refactor(security_center): remove deprecated setReadTime and migrating security_center sample and deps to java-docs-sample#10285

Open
Kef131 wants to merge 6 commits into
GoogleCloudPlatform:mainfrom
Kef131:refactor(security_center)-remove_deprecated_setreadtime_and_move_javadocssample
Open

refactor(security_center): remove deprecated setReadTime and migrating security_center sample and deps to java-docs-sample#10285
Kef131 wants to merge 6 commits into
GoogleCloudPlatform:mainfrom
Kef131:refactor(security_center)-remove_deprecated_setreadtime_and_move_javadocssample

Conversation

@Kef131

@Kef131 Kef131 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #
b/517939862

Link to original FindingSnippets.java

Refactor Security Center list findings sample to replace deprecated SetReadTime.
Main modified lines on FindingSnippets.java on line 320

This PR migrates the list findings at time snippet to the java-docs-samples repository under a new securitycenter directory, and updates its implementation to use event_time filter criteria instead.
Added ITSourceSnippets.java as a requirement for ITFindingSnippets.java due it uses SourceSnippets.createSource(), then SourceSnippets.java also migrated.

Checklist

  • I have followed Sample Format Guide
  • pom.xml parent set to latest shared-configuration
  • Appropriate changes to README are included in PR
  • These samples need a new API enabled in testing projects to pass: Security Command Center API
  • These samples need a new/updated env vars in testing projects set to pass: GCLOUD_ORGANIZATION
  • Tests pass: mvn clean verify required (Compiles and verifies correctly; requires GCLOUD_ORGANIZATION to run integration tests against a live GCP project)
  • Lint passes: mvn -P lint checkstyle:check required (Passed with 0 violations)
  • Static Analysis: mvn -P lint clean compile pmd:cpd-check spotbugs:check advisory only
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

Kef131 added 2 commits June 19, 2026 17:04
…nter snippets and integration tests to java docs sample
…ix minor documentation and license URL formatting
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Jun 19, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new Maven module securitycenter-snippets containing code snippets and integration tests for Google Cloud Security Command Center's Findings and Sources. The review feedback suggests several improvements to modernize and clean up the code, such as migrating from legacy JUnit 3 assertions to JUnit 4, replacing the ThreeTen backport library with standard Java 8 java.time classes, using assertEquals instead of assertTrue(equals(...)) for better null safety and failure messages, removing the unused com.google.truth dependency, and simplifying list creation with ImmutableList.of.

Comment on lines +320 to +321
ListFindingsRequest.Builder request =
ListFindingsRequest.newBuilder().setParent(sourceName.toString()).setFilter(filter);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously as

 ListFindingsRequest.Builder request =
          ListFindingsRequest.newBuilder()
              .setParent(sourceName.toString())
              .setReadTime(
                  Timestamp.newBuilder()
                      .setSeconds(fiveDaysAgo.getEpochSecond())
                      .setNanos(fiveDaysAgo.getNano()));

Kef131 and others added 3 commits June 19, 2026 15:58
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@Kef131

Kef131 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds Java code snippets and integration tests for Google Security Command Center, covering both findings and sources. The review feedback identifies critical compilation errors in the integration tests, including a missing static import for assertEquals and a missing closing curly brace in ITSourceSnippets.java. Additionally, an unused variable stringValue was found in ITFindingSnippets.java that should be cleaned up.

@Kef131 Kef131 marked this pull request as ready for review June 19, 2026 22:22
@Kef131 Kef131 requested review from a team and yoshi-approver as code owners June 19, 2026 22:22
@snippet-bot

snippet-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@Kef131 Kef131 changed the title refactor(security_center): remove deprecated setReadTime and migrating sample and deps to java-docs-sample refactor(security_center): remove deprecated setReadTime and migrating security_center sample and deps to java-docs-sample Jun 19, 2026

@amcolin amcolin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a folder security-command-center/snippets are they different products? or should we just include this migration on the security-command-center.

@Kef131

Kef131 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

We already have a folder security-command-center/snippets are they different products? or should we just include this migration on the security-command-center.

Indeed, at least on the GoogleCloudJava Readme links repo we have two differents
image

and at least three more folder on the folders
image

I will research on these products and check the folder organization

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants