From fca7dfdd223c73db1ae362cd867650376c3cbc10 Mon Sep 17 00:00:00 2001 From: galsuchetzky-act Date: Fri, 20 Nov 2026 01:34:47 +0200 Subject: [PATCH] test(bedrock): reuse inference-profile metadata test helpers (#9044) Share same-account client construction and successful summary lookup in the existing metadata tests. Preserve each test assertion, region and resource lifetime, including the unavailable-region negative control. Closes #9043 --- ...ferenceProfileMetadataIntegrationTest.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/test/java/io/floci/aws/services/bedrock/BedrockInferenceProfileMetadataIntegrationTest.java b/src/test/java/io/floci/aws/services/bedrock/BedrockInferenceProfileMetadataIntegrationTest.java index ead8c50b5b..fffa81da0c 100644 --- a/src/test/java/io/floci/aws/services/bedrock/BedrockInferenceProfileMetadataIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/bedrock/BedrockInferenceProfileMetadataIntegrationTest.java @@ -22,7 +22,7 @@ class BedrockInferenceProfileMetadataIntegrationTest { @Test void getFoundationModelAdvertisesOnDemandAndInferenceProfileSupport() { - try (BedrockClient client = AwsTestClients.create(BedrockClient.builder(), "741623800022", Region.US_EAST_1)) { + try (BedrockClient client = client(Region.US_EAST_1)) { FoundationModelDetails model = client.getFoundationModel(request -> request.modelIdentifier(MODEL)) .modelDetails(); assertEquals(MODEL, model.modelId()); @@ -32,21 +32,19 @@ class BedrockInferenceProfileMetadataIntegrationTest { @Test void modelWithoutAProfileOnlyAdvertisesOnDemandSupport() { - try (BedrockClient client = AwsTestClients.create(BedrockClient.builder(), "741623800022", Region.US_EAST_1)) { + try (BedrockClient client = client(Region.US_EAST_1)) { String modelId = "amazon.titan-embed-text-v2:0"; assertEquals(List.of("ON_DEMAND"), client.getFoundationModel(request -> request .modelIdentifier(modelId)).modelDetails().inferenceTypesSupportedAsStrings()); - FoundationModelSummary listed = client.listFoundationModels(request -> { }).modelSummaries().stream() - .filter(model -> modelId.equals(model.modelId())).findFirst().orElseThrow(); + FoundationModelSummary listed = summary(client, modelId); assertEquals(List.of("ON_DEMAND"), listed.inferenceTypesSupportedAsStrings()); } } @Test void listFoundationModelsAdvertisesOnDemandAndInferenceProfileSupport() { - try (BedrockClient client = AwsTestClients.create(BedrockClient.builder(), "741623800022", Region.US_EAST_1)) { - FoundationModelSummary model = client.listFoundationModels(request -> { }).modelSummaries().stream() - .filter(candidate -> MODEL.equals(candidate.modelId())).findFirst().orElseThrow(); + try (BedrockClient client = client(Region.US_EAST_1)) { + FoundationModelSummary model = summary(client, MODEL); assertEquals(List.of("ON_DEMAND", "INFERENCE_PROFILE"), model.inferenceTypesSupportedAsStrings()); } } @@ -54,19 +52,17 @@ class BedrockInferenceProfileMetadataIntegrationTest { @Test void profileOnlyRegionAdvertisesOnlyInferenceProfilesOnGetAndList() { String modelId = "amazon.nova-micro-v1:0"; - try (BedrockClient client = AwsTestClients.create(BedrockClient.builder(), "741623800022", Region.EU_CENTRAL_1)) { + try (BedrockClient client = client(Region.EU_CENTRAL_1)) { assertEquals(List.of("INFERENCE_PROFILE"), client.getFoundationModel(request -> request .modelIdentifier(modelId)).modelDetails().inferenceTypesSupportedAsStrings()); - FoundationModelSummary listed = client.listFoundationModels(request -> { }).modelSummaries().stream() - .filter(model -> modelId.equals(model.modelId())).findFirst().orElseThrow(); + FoundationModelSummary listed = summary(client, modelId); assertEquals(List.of("INFERENCE_PROFILE"), listed.inferenceTypesSupportedAsStrings()); } } @Test void unavailableRegionExcludesTheModelAndRetainsGetValidation() { - try (BedrockClient client = AwsTestClients.create(BedrockClient.builder(), "741623800022", - Region.AP_NORTHEAST_3)) { + try (BedrockClient client = client(Region.AP_NORTHEAST_3)) { ValidationException error = assertThrows(ValidationException.class, () -> client.getFoundationModel(request -> request.modelIdentifier(MODEL))); assertEquals(400, error.statusCode()); @@ -75,4 +71,12 @@ class BedrockInferenceProfileMetadataIntegrationTest { } } + private static BedrockClient client(Region region) { + return AwsTestClients.create(BedrockClient.builder(), "741623800022", region); + } + + private static FoundationModelSummary summary(BedrockClient client, String modelId) { + return client.listFoundationModels(request -> { }).modelSummaries().stream() + .filter(model -> modelId.equals(model.modelId())).findFirst().orElseThrow(); + } }