From 52a2e37f69daf2cfe867ef3bf01e615c9f6aa07e Mon Sep 17 00:00:00 2001 From: Hector Ventura Date: Tue, 27 Oct 2026 09:17:55 -0500 Subject: [PATCH] chore: import fully qualified types, appsync to iot (#6738) --- .../cloudhsmv2/CloudHsmV2JsonHandler.java | 8 +++++--- .../AppSyncExecutionIntegrationTest.java | 5 +++-- ...ionManagedPolicyUpdateIntegrationTest.java | 18 +++++++++-------- .../CloudTrailCfnProvisionerTest.java | 3 ++- .../CloudFrontSignedUrlServingTest.java | 10 +++++----- ...issionAccountIsolationIntegrationTest.java | 18 ++++++++++------- .../docdb/DocDbLegacyMigrationRaceTest.java | 16 ++++++++------- .../services/ec2/Ec2IpamServiceTest.java | 3 ++- .../EcsContainerManagerSecurityGroupTest.java | 6 ++++-- .../eks/EksIrsaDockerIntegrationTest.java | 6 ++++-- .../FirehoseDataFormatConversionTest.java | 20 ++++++++++--------- .../fis/FisModelSerializationTest.java | 3 ++- .../services/glue/GlueJsonHandlerTest.java | 6 ++++-- .../services/iam/IamConcurrencyTest.java | 17 ++++++++-------- ...tionRoleIamEnforcementIntegrationTest.java | 20 ++++++++++++------- .../floci/services/iot/IotServiceTest.java | 6 ++++-- tools/checkstyle/suppressions.xml | 13 ------------ 17 files changed, 98 insertions(+), 80 deletions(-) diff --git a/src/main/java/io/github/hectorvent/floci/services/cloudhsmv2/CloudHsmV2JsonHandler.java b/src/main/java/io/github/hectorvent/floci/services/cloudhsmv2/CloudHsmV2JsonHandler.java index ff80b44537..f2f5516363 100644 --- a/src/main/java/io/github/hectorvent/floci/services/cloudhsmv2/CloudHsmV2JsonHandler.java +++ b/src/main/java/io/github/hectorvent/floci/services/cloudhsmv2/CloudHsmV2JsonHandler.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import io.github.hectorvent.floci.core.common.AwsArnUtils; import io.github.hectorvent.floci.core.common.AwsErrorResponse; import io.github.hectorvent.floci.core.common.AwsException; +import io.github.hectorvent.floci.core.common.JsonErrorResponseUtils; import io.github.hectorvent.floci.services.cloudhsmv2.model.Backup; import io.github.hectorvent.floci.services.cloudhsmv2.model.BackupRetentionPolicy; import io.github.hectorvent.floci.services.cloudhsmv2.model.Certificates; @@ -17,6 +18,7 @@ import jakarta.inject.Inject; import jakarta.ws.rs.core.Response; import org.jboss.logging.Logger; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Base64; import java.util.Collection; @@ -74,10 +76,10 @@ public class CloudHsmV2JsonHandler { .build(); }; } catch (AwsException e) { - return io.github.hectorvent.floci.core.common.JsonErrorResponseUtils.createErrorResponse(e); + return JsonErrorResponseUtils.createErrorResponse(e); } catch (Exception e) { LOG.errorf(e, "CloudHSM v2 error processing action %s", action); - return io.github.hectorvent.floci.core.common.JsonErrorResponseUtils.createErrorResponse(e); + return JsonErrorResponseUtils.createErrorResponse(e); } } @@ -600,7 +602,7 @@ public class CloudHsmV2JsonHandler { return value; } try { - return new String(Base64.getDecoder().decode(value), java.nio.charset.StandardCharsets.UTF_8); + return new String(Base64.getDecoder().decode(value), StandardCharsets.UTF_8); } catch (IllegalArgumentException e) { return value; } diff --git a/src/test/java/io/github/hectorvent/floci/services/appsync/AppSyncExecutionIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/appsync/AppSyncExecutionIntegrationTest.java index edec867183..8251344afd 100644 --- a/src/test/java/io/github/hectorvent/floci/services/appsync/AppSyncExecutionIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/appsync/AppSyncExecutionIntegrationTest.java @@ -1,6 +1,7 @@ package io.github.hectorvent.floci.services.appsync; import io.github.hectorvent.floci.services.appsync.graphql.AppSyncErrorFormatter; +import io.github.hectorvent.floci.services.appsync.graphql.SchemaCreationWorker; import io.github.hectorvent.floci.services.appsync.graphql.SchemaRegistry; import io.github.hectorvent.floci.testing.RestAssuredJsonUtils; import io.github.hectorvent.floci.testing.SidecarContainersProfile; @@ -425,9 +426,9 @@ class AppSyncExecutionIntegrationTest { } @Inject - io.github.hectorvent.floci.services.appsync.graphql.SchemaCreationWorker schemaCreationWorker; + SchemaCreationWorker schemaCreationWorker; - private io.github.hectorvent.floci.services.appsync.graphql.SchemaCreationWorker rehydrateWorker() { + private SchemaCreationWorker rehydrateWorker() { return schemaCreationWorker; } diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationManagedPolicyUpdateIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationManagedPolicyUpdateIntegrationTest.java index 3c11e26eab..da59b65918 100644 --- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationManagedPolicyUpdateIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationManagedPolicyUpdateIntegrationTest.java @@ -1,9 +1,11 @@ package io.github.hectorvent.floci.services.cloudformation; import io.github.hectorvent.floci.core.common.AwsException; +import io.github.hectorvent.floci.core.storage.StorageBackend; import io.github.hectorvent.floci.services.cloudformation.model.Stack; import io.github.hectorvent.floci.services.iam.IamService; import io.github.hectorvent.floci.services.iam.model.IamRole; +import io.quarkus.arc.ClientProxy; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.mockito.InjectSpy; import io.restassured.specification.RequestSpecification; @@ -11,11 +13,13 @@ import jakarta.inject.Inject; import org.junit.jupiter.api.Test; import java.lang.reflect.Field; +import java.util.Arrays; import java.util.Map; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doThrow; @@ -55,7 +59,7 @@ class CloudFormationManagedPolicyUpdateIntegrationTest { @SuppressWarnings("unchecked") private void forgetPolicyId(String stackName, String logicalId) throws ReflectiveOperationException { - Object target = cloudFormationService instanceof io.quarkus.arc.ClientProxy proxy + Object target = cloudFormationService instanceof ClientProxy proxy ? proxy.arc_contextualInstance() : cloudFormationService; Field stacksField = CloudFormationService.class.getDeclaredField("stacks"); @@ -70,15 +74,13 @@ class CloudFormationManagedPolicyUpdateIntegrationTest { @SuppressWarnings("unchecked") private void markServiceLinked(String roleName) throws ReflectiveOperationException { - Object target = iamService instanceof io.quarkus.arc.ClientProxy proxy + Object target = iamService instanceof ClientProxy proxy ? proxy.arc_contextualInstance() : iamService; Field rolesField = IamService.class.getDeclaredField("roles"); rolesField.setAccessible(true); - io.github.hectorvent.floci.core.storage.StorageBackend roles = - (io.github.hectorvent.floci.core.storage.StorageBackend) rolesField.get(target); + StorageBackend roles = + (StorageBackend) rolesField.get(target); IamRole role = roles.get(roleName).orElseThrow(); // isServiceLinkedRole() alone triggers the guard; the path must also look like a real // service-linked path since the guard's error message parses the principal back out of it. @@ -362,7 +364,7 @@ class CloudFormationManagedPolicyUpdateIntegrationTest { } private static String literalRoleManagedPolicyTemplate(String policyName, String action, String... roleNames) { - String roleList = String.join(",", java.util.Arrays.stream(roleNames) + String roleList = String.join(",", Arrays.stream(roleNames) .map(name -> "\"" + name + "\"").toList()); return """ { @@ -547,7 +549,7 @@ class CloudFormationManagedPolicyUpdateIntegrationTest { // that state is gone. boolean prunedContentSurvives = iamService.listPolicyVersions(policyArn(policyName)).stream() .anyMatch(v -> v.getDocument().contains("s3:GetObject")); - org.junit.jupiter.api.Assertions.assertTrue(prunedContentSurvives, + assertTrue(prunedContentSurvives, "pruned v1 content (s3:GetObject) was permanently lost despite UPDATE_ROLLBACK_COMPLETE"); } } diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/CloudTrailCfnProvisionerTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/CloudTrailCfnProvisionerTest.java index 18dbaf96b0..aba4f61dd5 100644 --- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/CloudTrailCfnProvisionerTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/CloudTrailCfnProvisionerTest.java @@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.cloudformation.provisioners; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; +import io.github.hectorvent.floci.core.common.AwsException; import io.github.hectorvent.floci.services.cloudformation.CloudFormationTemplateEngine; import io.github.hectorvent.floci.services.cloudformation.model.StackResource; import io.github.hectorvent.floci.services.cloudtrail.CloudTrailService; @@ -101,7 +102,7 @@ class CloudTrailCfnProvisionerTest { .set("Equals", mapper.createArrayNode().add("Data")))))); StackResource resource = resource(); - assertThrows(io.github.hectorvent.floci.core.common.AwsException.class, + assertThrows(AwsException.class, () -> provisioner.provision(resource, props, context())); assertEquals(created.trailArn(), resource.getPhysicalId(), "physicalId must be recorded right after createTrail succeeds, " diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontSignedUrlServingTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontSignedUrlServingTest.java index e055071682..b733657fbb 100644 --- a/src/test/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontSignedUrlServingTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontSignedUrlServingTest.java @@ -6,8 +6,10 @@ import io.github.hectorvent.floci.services.cloudfront.model.Distribution; import io.github.hectorvent.floci.services.cloudfront.model.DistributionConfig; import io.github.hectorvent.floci.services.cloudfront.model.KeyGroup; import io.github.hectorvent.floci.services.cloudfront.model.Origin; +import io.github.hectorvent.floci.services.cloudfront.model.PublicKey; import io.github.hectorvent.floci.services.s3.S3Service; import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; import jakarta.inject.Inject; import org.junit.jupiter.api.Test; @@ -60,8 +62,7 @@ class CloudFrontSignedUrlServingTest { + Base64.getMimeEncoder().encodeToString(keyPair.getPublic().getEncoded()) + "\n-----END PUBLIC KEY-----"; - io.github.hectorvent.floci.services.cloudfront.model.PublicKey publicKey = - new io.github.hectorvent.floci.services.cloudfront.model.PublicKey(); + PublicKey publicKey = new PublicKey(); publicKey.setName("pk-" + suffix); publicKey.setCallerReference("cr-" + suffix); publicKey.setEncodedKey(pem); @@ -183,8 +184,7 @@ class CloudFrontSignedUrlServingTest { String pem = "-----BEGIN PUBLIC KEY-----\n" + Base64.getMimeEncoder().encodeToString(keyPair.getPublic().getEncoded()) + "\n-----END PUBLIC KEY-----"; - io.github.hectorvent.floci.services.cloudfront.model.PublicKey publicKey = - new io.github.hectorvent.floci.services.cloudfront.model.PublicKey(); + PublicKey publicKey = new PublicKey(); publicKey.setName("pk-" + suffix); publicKey.setCallerReference("cr-" + suffix); publicKey.setEncodedKey(pem); @@ -234,7 +234,7 @@ class CloudFrontSignedUrlServingTest { } private static String rawGet(String host, String pathAndQuery) throws Exception { - try (Socket socket = new Socket("127.0.0.1", io.restassured.RestAssured.port)) { + try (Socket socket = new Socket("127.0.0.1", RestAssured.port)) { String request = "GET " + pathAndQuery + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n"; diff --git a/src/test/java/io/github/hectorvent/floci/services/cur/CurDailyEmissionAccountIsolationIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cur/CurDailyEmissionAccountIsolationIntegrationTest.java index 153288144e..4179d48fd4 100644 --- a/src/test/java/io/github/hectorvent/floci/services/cur/CurDailyEmissionAccountIsolationIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/cur/CurDailyEmissionAccountIsolationIntegrationTest.java @@ -1,7 +1,11 @@ package io.github.hectorvent.floci.services.cur; +import io.github.hectorvent.floci.core.common.RequestContext; +import io.github.hectorvent.floci.services.cur.model.ReportDefinition; import io.github.hectorvent.floci.testing.RestAssuredJsonUtils; import io.github.hectorvent.floci.testing.SidecarContainersProfile; +import io.quarkus.arc.Arc; +import io.quarkus.arc.ManagedContext; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; import jakarta.inject.Inject; @@ -9,6 +13,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; +import java.util.List; import java.util.Map; import static io.restassured.RestAssured.given; @@ -16,6 +21,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasKey; /** * Verifies that the daily emission loop honors per-report owner accounts: @@ -88,21 +94,19 @@ class CurDailyEmissionAccountIsolationIntegrationTest { // helper below mirrors what CurEmissionScheduler.runUnderAccount does, // since the @Test thread is also outside any incoming HTTP scope here // (the prior REST-Assured calls have terminated their request scopes). - Map> grouped = + Map> grouped = curService.listAllReportsByAccount(); - assertThat(grouped, org.hamcrest.Matchers.hasKey(ACCOUNT_ID)); + assertThat(grouped, hasKey(ACCOUNT_ID)); - io.quarkus.arc.ManagedContext rc = io.quarkus.arc.Arc.container().requestContext(); + ManagedContext rc = Arc.container().requestContext(); boolean wasActive = rc.isActive(); if (!wasActive) { rc.activate(); } try { - io.github.hectorvent.floci.core.common.RequestContext ctx = - io.quarkus.arc.Arc.container() - .instance(io.github.hectorvent.floci.core.common.RequestContext.class).get(); + RequestContext ctx = Arc.container().instance(RequestContext.class).get(); ctx.setAccountId(ACCOUNT_ID); - for (io.github.hectorvent.floci.services.cur.model.ReportDefinition def + for (ReportDefinition def : grouped.get(ACCOUNT_ID)) { engine.emitForCurrentMonth(def.getReportName(), def.getS3Bucket(), def.getS3Prefix(), def.getS3Region(), ACCOUNT_ID); diff --git a/src/test/java/io/github/hectorvent/floci/services/docdb/DocDbLegacyMigrationRaceTest.java b/src/test/java/io/github/hectorvent/floci/services/docdb/DocDbLegacyMigrationRaceTest.java index 58fb114cf0..a9f72cffcd 100644 --- a/src/test/java/io/github/hectorvent/floci/services/docdb/DocDbLegacyMigrationRaceTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/docdb/DocDbLegacyMigrationRaceTest.java @@ -4,6 +4,7 @@ import io.github.hectorvent.floci.config.EmulatorConfig; import io.github.hectorvent.floci.core.common.AwsException; import io.github.hectorvent.floci.core.common.RegionResolver; import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend; +import io.github.hectorvent.floci.core.storage.InMemoryStorage; import io.github.hectorvent.floci.core.storage.StorageBackend; import io.github.hectorvent.floci.core.storage.StorageFactory; import io.github.hectorvent.floci.services.docdb.container.DocDbContainerManager; @@ -15,6 +16,7 @@ import io.github.hectorvent.floci.services.rds.RdsService; import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; @@ -150,7 +152,7 @@ class DocDbLegacyMigrationRaceTest { // Staged rather than raced: the listing is held at its first scan while the move runs to // completion, which is the interleaving that loses or doubles the record. PausingStorageBackend pausing = - new PausingStorageBackend<>(new io.github.hectorvent.floci.core.storage.InMemoryStorage<>()); + new PausingStorageBackend<>(new InMemoryStorage<>()); serviceOver(pausing); String id = "listed-across-the-move"; DocDbCluster legacy = new DocDbCluster(); @@ -158,7 +160,7 @@ class DocDbLegacyMigrationRaceTest { legacy.setStatus("available"); clusterStore.put(id, legacy); - AtomicReference> listed = new AtomicReference<>(); + AtomicReference> listed = new AtomicReference<>(); AtomicReference unexpected = new AtomicReference<>(); // The second scan: the first runs before the move, so holding the second is what puts the // move between them — the interleaving in which a record can be lost or counted twice. @@ -181,7 +183,7 @@ class DocDbLegacyMigrationRaceTest { lister.join(TimeUnit.SECONDS.toMillis(10)); assertNull(unexpected.get(), () -> "unexpected failure: " + unexpected.get()); - assertEquals(java.util.List.of(id), listed.get(), + assertEquals(List.of(id), listed.get(), "the cluster should be listed exactly once across the move"); } @@ -191,7 +193,7 @@ class DocDbLegacyMigrationRaceTest { // and the cluster delete runs to completion first. Sharing one monitor is what stops the // held write from landing afterwards. PausingStorageBackend pausing = - new PausingStorageBackend<>(new io.github.hectorvent.floci.core.storage.InMemoryStorage<>()); + new PausingStorageBackend<>(new InMemoryStorage<>()); serviceOver(pausing); String clusterId = "co-delete-staged"; String instanceId = "co-delete-staged-instance"; @@ -247,7 +249,7 @@ class DocDbLegacyMigrationRaceTest { CountDownLatch start = new CountDownLatch(1); AtomicReference unexpected = new AtomicReference<>(); - AtomicReference> listed = new AtomicReference<>(); + AtomicReference> listed = new AtomicReference<>(); Thread mover = new Thread(() -> { await(start); @@ -273,7 +275,7 @@ class DocDbLegacyMigrationRaceTest { mover.join(TimeUnit.SECONDS.toMillis(10)); lister.join(TimeUnit.SECONDS.toMillis(10)); assertNull(unexpected.get(), () -> "unexpected failure: " + unexpected.get()); - assertEquals(java.util.List.of(id), listed.get(), + assertEquals(List.of(id), listed.get(), "the cluster should be listed exactly once, attempt " + attempt); } } @@ -342,7 +344,7 @@ class DocDbLegacyMigrationRaceTest { // those two would be undone by that write. Holding the move at its write and letting a // delete run is that interleaving exactly. PausingStorageBackend pausing = - new PausingStorageBackend<>(new io.github.hectorvent.floci.core.storage.InMemoryStorage<>()); + new PausingStorageBackend<>(new InMemoryStorage<>()); serviceOver(pausing); String id = "moved-while-deleted"; DocDbCluster legacy = new DocDbCluster(); diff --git a/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IpamServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IpamServiceTest.java index 68056e2132..aef9bdbe8e 100644 --- a/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IpamServiceTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IpamServiceTest.java @@ -5,6 +5,7 @@ import io.github.hectorvent.floci.core.common.AwsException; import io.github.hectorvent.floci.core.common.RequestContext; import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend; import io.github.hectorvent.floci.core.storage.InMemoryStorage; +import io.github.hectorvent.floci.services.ec2.model.AsnAssociation; import io.github.hectorvent.floci.services.ec2.model.Ipam; import io.github.hectorvent.floci.services.ec2.model.IpamPool; import io.github.hectorvent.floci.services.ec2.model.IpamPoolAllocation; @@ -196,7 +197,7 @@ class Ec2IpamServiceTest { void associateIpamByoasnPersistsAcrossServiceInstances() { EmulatorConfig config = mock(EmulatorConfig.class); when(config.defaultAccountId()).thenReturn("000000000000"); - InMemoryStorage backend = new InMemoryStorage<>(); + InMemoryStorage backend = new InMemoryStorage<>(); Ec2IpamService firstService = new Ec2IpamService(config, new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(), backend); firstService.associateIpamByoasn("us-west-2", "65001", "192.168.0.0/16"); diff --git a/src/test/java/io/github/hectorvent/floci/services/ecs/container/EcsContainerManagerSecurityGroupTest.java b/src/test/java/io/github/hectorvent/floci/services/ecs/container/EcsContainerManagerSecurityGroupTest.java index 8b33ba31ed..99fe650e0b 100644 --- a/src/test/java/io/github/hectorvent/floci/services/ecs/container/EcsContainerManagerSecurityGroupTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/ecs/container/EcsContainerManagerSecurityGroupTest.java @@ -21,6 +21,8 @@ import io.github.hectorvent.floci.services.ecr.registry.EcrRegistryManager; import io.github.hectorvent.floci.services.ecs.model.AwsVpcConfiguration; import io.github.hectorvent.floci.services.ecs.model.ContainerDefinition; import io.github.hectorvent.floci.services.ecs.model.EcsTask; +import io.github.hectorvent.floci.services.ecs.model.FirelensConfiguration; +import io.github.hectorvent.floci.services.ecs.model.LogConfiguration; import io.github.hectorvent.floci.services.ecs.model.NetworkConfiguration; import io.github.hectorvent.floci.services.ecs.model.NetworkMode; import io.github.hectorvent.floci.services.ecs.model.PortMapping; @@ -221,12 +223,12 @@ class EcsContainerManagerSecurityGroupTest { ContainerDefinition router = new ContainerDefinition(); router.setName("log_router"); router.setImage("amazon/aws-for-fluent-bit:stable"); - router.setFirelensConfiguration(new io.github.hectorvent.floci.services.ecs.model.FirelensConfiguration( + router.setFirelensConfiguration(new FirelensConfiguration( "fluentbit", Map.of())); ContainerDefinition app = new ContainerDefinition(); app.setName("app"); app.setImage("app:latest"); - app.setLogConfiguration(new io.github.hectorvent.floci.services.ecs.model.LogConfiguration( + app.setLogConfiguration(new LogConfiguration( "awsfirelens", Map.of("Name", "cloudwatch"), null)); TaskDefinition taskDef = new TaskDefinition(); diff --git a/src/test/java/io/github/hectorvent/floci/services/eks/EksIrsaDockerIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/eks/EksIrsaDockerIntegrationTest.java index 91c3de741f..569630c453 100644 --- a/src/test/java/io/github/hectorvent/floci/services/eks/EksIrsaDockerIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/eks/EksIrsaDockerIntegrationTest.java @@ -3,6 +3,8 @@ package io.github.hectorvent.floci.services.eks; import com.github.dockerjava.api.DockerClient; import io.github.hectorvent.floci.core.common.docker.ContainerExec; import io.github.hectorvent.floci.services.eks.model.Cluster; +import io.github.hectorvent.floci.services.eks.model.ClusterIdentity; +import io.github.hectorvent.floci.services.eks.model.OidcIdentity; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; @@ -123,8 +125,8 @@ class EksIrsaDockerIntegrationTest { cluster.setRoleArn("arn:aws:iam::" + ACCOUNT + ":role/eks-service-role"); String issuer = oidcService.newIssuerUrl("us-east-1"); - cluster.setIdentity(new io.github.hectorvent.floci.services.eks.model.ClusterIdentity( - new io.github.hectorvent.floci.services.eks.model.OidcIdentity(issuer))); + cluster.setIdentity(new ClusterIdentity( + new OidcIdentity(issuer))); oidcService.ensureKeyForAccount(ACCOUNT, clusterName, issuer); eksClusterManager.startCluster(cluster); diff --git a/src/test/java/io/github/hectorvent/floci/services/firehose/FirehoseDataFormatConversionTest.java b/src/test/java/io/github/hectorvent/floci/services/firehose/FirehoseDataFormatConversionTest.java index a6cf8fd15f..36187216c8 100644 --- a/src/test/java/io/github/hectorvent/floci/services/firehose/FirehoseDataFormatConversionTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/firehose/FirehoseDataFormatConversionTest.java @@ -1,5 +1,7 @@ package io.github.hectorvent.floci.services.firehose; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import io.github.hectorvent.floci.config.EmulatorConfig; import io.github.hectorvent.floci.core.common.AwsException; import io.github.hectorvent.floci.core.common.RegionResolver; @@ -21,6 +23,7 @@ import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescript import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.S3Destination; import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.SchemaConfiguration; import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.Serializer; +import io.github.hectorvent.floci.services.firehose.model.Record; import io.github.hectorvent.floci.services.kinesis.KinesisService; import io.github.hectorvent.floci.services.s3.S3Service; import io.github.hectorvent.floci.testing.MutableClock; @@ -29,6 +32,7 @@ import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -375,11 +379,10 @@ class FirehoseDataFormatConversionTest { DeliveryStreamDescription.Destination destination = service.describeDeliveryStream("stream").getDestinations().get(0); - com.fasterxml.jackson.databind.ObjectMapper mapper = - new com.fasterxml.jackson.databind.ObjectMapper(); + ObjectMapper mapper = new ObjectMapper(); for (Object rendered : List.of(destination.getExtendedS3DestinationDescription(), destination.getS3DestinationDescription())) { - com.fasterxml.jackson.databind.JsonNode json = mapper.valueToTree(rendered); + JsonNode json = mapper.valueToTree(rendered); json.fieldNames().forEachRemaining(name -> assertTrue(Character.isUpperCase(name.charAt(0)), "unexpected non-AWS member rendered: " + name + " in " + json)); } @@ -559,7 +562,7 @@ class FirehoseDataFormatConversionTest { void conversionOfATransformingStreamConvertsWhatTheTransformReturned() { Mockito.when(lambdaTransformer.transform(any(), anyString(), any(), any())) .thenReturn(new FirehoseLambdaTransformer.Outcome( - List.of("{\"ticker\": \"BBB\"}".getBytes(java.nio.charset.StandardCharsets.UTF_8)), + List.of("{\"ticker\": \"BBB\"}".getBytes(StandardCharsets.UTF_8)), 0, 0, null)); Mockito.when(parquetConverter.deliver(any(), anyString(), any(), any())) .thenReturn(new FirehoseParquetConverter.Outcome(1, 0, "data/key.parquet", null)); @@ -573,7 +576,7 @@ class FirehoseDataFormatConversionTest { Mockito.verify(parquetConverter).deliver(any(), Mockito.eq("results"), converted.capture(), any()); assertEquals(1, converted.getValue().size()); assertEquals("{\"ticker\": \"BBB\"}", - new String(converted.getValue().get(0), java.nio.charset.StandardCharsets.UTF_8)); + new String(converted.getValue().get(0), StandardCharsets.UTF_8)); } @Test @@ -601,10 +604,9 @@ class FirehoseDataFormatConversionTest { return processing; } - private static io.github.hectorvent.floci.services.firehose.model.Record record(String json) { - io.github.hectorvent.floci.services.firehose.model.Record record = - new io.github.hectorvent.floci.services.firehose.model.Record(); - record.setData(json.getBytes(java.nio.charset.StandardCharsets.UTF_8)); + private static Record record(String json) { + Record record = new Record(); + record.setData(json.getBytes(StandardCharsets.UTF_8)); return record; } diff --git a/src/test/java/io/github/hectorvent/floci/services/fis/FisModelSerializationTest.java b/src/test/java/io/github/hectorvent/floci/services/fis/FisModelSerializationTest.java index 28ac4087b0..ba426c7082 100644 --- a/src/test/java/io/github/hectorvent/floci/services/fis/FisModelSerializationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/fis/FisModelSerializationTest.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import io.github.hectorvent.floci.services.fis.model.Experiment; import io.github.hectorvent.floci.services.fis.model.ExperimentTemplate; +import io.github.hectorvent.floci.services.fis.model.ExperimentTemplateTarget; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -54,7 +55,7 @@ class FisModelSerializationTest { assertEquals(mapper.writeValueAsString(expected), mapper.writeValueAsString(actual)); assertInstanceOf( - io.github.hectorvent.floci.services.fis.model.ExperimentTemplateTarget.class, + ExperimentTemplateTarget.class, model.getTargets().get("instances")); assertFalse(actual.has("logConfiguration")); assertFalse(actual.has("experimentReportConfiguration")); diff --git a/src/test/java/io/github/hectorvent/floci/services/glue/GlueJsonHandlerTest.java b/src/test/java/io/github/hectorvent/floci/services/glue/GlueJsonHandlerTest.java index d41450e62b..0ef1539b18 100644 --- a/src/test/java/io/github/hectorvent/floci/services/glue/GlueJsonHandlerTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/glue/GlueJsonHandlerTest.java @@ -5,11 +5,13 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import io.github.hectorvent.floci.core.common.AwsException; import io.github.hectorvent.floci.core.common.RegionResolver; import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend; import io.github.hectorvent.floci.core.storage.InMemoryStorage; import io.github.hectorvent.floci.core.storage.StorageFactory; +import io.github.hectorvent.floci.services.glue.model.Table; import io.github.hectorvent.floci.services.glue.schemaregistry.GlueSchemaRegistryService; import io.github.hectorvent.floci.services.kms.KmsService; import io.github.hectorvent.floci.services.resourcegroupstagging.ResourceGroupsTaggingService; @@ -38,7 +40,7 @@ class GlueJsonHandlerTest { @BeforeEach void setUp() { mapper = new ObjectMapper(); - mapper.registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule()); + mapper.registerModule(new JavaTimeModule()); RegionResolver regionResolver = new RegionResolver(REGION, ACCOUNT_ID); StorageFactory storageFactory = new InMemoryStorageFactory(); GlueSchemaRegistryService schemaRegistryService = @@ -621,7 +623,7 @@ class GlueJsonHandlerTest { Map page = body(handler.handle("SearchTables", filtered, REGION)); List tables = (List) page.get("TableList"); assertEquals(1, tables.size()); - assertEquals("beta", ((io.github.hectorvent.floci.services.glue.model.Table) tables.get(0)).getName()); + assertEquals("beta", ((Table) tables.get(0)).getName()); } private static final class InMemoryStorageFactory extends StorageFactory { diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/IamConcurrencyTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/IamConcurrencyTest.java index 5029dccc46..5fe4c9ccfd 100644 --- a/src/test/java/io/github/hectorvent/floci/services/iam/IamConcurrencyTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/iam/IamConcurrencyTest.java @@ -10,6 +10,7 @@ import org.junit.jupiter.api.TestFactory; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; @@ -56,7 +57,7 @@ class IamConcurrencyTest { List scenarios = List.of( new Scenario("role.tags", iam -> { iam.createRole("r", "/", "{}", null, 3600, null); - return i -> iam.tagRole("r", java.util.Map.of("k" + i, "v" + i)); + return i -> iam.tagRole("r", Map.of("k" + i, "v" + i)); }, iam -> iam.getRole("r").getTags().size()), new Scenario("role.inlinePolicies", iam -> { @@ -72,7 +73,7 @@ class IamConcurrencyTest { new Scenario("user.tags", iam -> { iam.createUser("u", "/"); - return i -> iam.tagUser("u", java.util.Map.of("k" + i, "v" + i)); + return i -> iam.tagUser("u", Map.of("k" + i, "v" + i)); }, iam -> iam.getUser("u").getTags().size()), new Scenario("user.inlinePolicies", iam -> { @@ -111,7 +112,7 @@ class IamConcurrencyTest { new Scenario("policy.tags", iam -> { IamPolicy p = iam.createPolicy("pol", "/", null, "{}", null); - return i -> iam.tagPolicy(p.getArn(), java.util.Map.of("k" + i, "v" + i)); + return i -> iam.tagPolicy(p.getArn(), Map.of("k" + i, "v" + i)); }, iam -> iam.getPolicy(onlyPolicyArn(iam)).getTags().size()) ); @@ -227,7 +228,7 @@ class IamConcurrencyTest { try { start.await(); iam.addRoleToInstanceProfile("prof", "role" + idx); - } catch (io.github.hectorvent.floci.core.common.AwsException expected) { + } catch (AwsException expected) { // LimitExceeded once one role is in } catch (Throwable t) { unexpected.add(t); @@ -272,9 +273,9 @@ class IamConcurrencyTest { try { start.await(10, TimeUnit.SECONDS); iam.createOpenIDConnectProvider("https://oidc.example.com/id/RACE", - List.of(clientId), List.of("thumb"), java.util.Map.of()); + List.of(clientId), List.of("thumb"), Map.of()); winners.add(clientId); - } catch (io.github.hectorvent.floci.core.common.AwsException e) { + } catch (AwsException e) { if (!"EntityAlreadyExists".equals(e.getErrorCode())) { unexpected.add(e.getErrorCode()); } @@ -323,7 +324,7 @@ class IamConcurrencyTest { start.await(10, TimeUnit.SECONDS); iam.createAccountAlias(alias); winners.add(alias); - } catch (io.github.hectorvent.floci.core.common.AwsException e) { + } catch (AwsException e) { if (!"EntityAlreadyExists".equals(e.getErrorCode())) { unexpected.add(e.getErrorCode()); } @@ -375,7 +376,7 @@ class IamConcurrencyTest { start.await(10, TimeUnit.SECONDS); iam.changePassword("racer", "Passw0rd$start", candidate); winners.add(candidate); - } catch (io.github.hectorvent.floci.core.common.AwsException e) { + } catch (AwsException e) { if (!"InvalidParameterValue".equals(e.getErrorCode())) { unexpected.add(e.getErrorCode()); } diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/LambdaExecutionRoleIamEnforcementIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/LambdaExecutionRoleIamEnforcementIntegrationTest.java index 425e62fea4..67c5e72fae 100644 --- a/src/test/java/io/github/hectorvent/floci/services/iam/LambdaExecutionRoleIamEnforcementIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/iam/LambdaExecutionRoleIamEnforcementIntegrationTest.java @@ -1,6 +1,7 @@ package io.github.hectorvent.floci.services.iam; import io.github.hectorvent.floci.services.iam.model.SessionCreds; +import io.github.hectorvent.floci.services.lambda.LambdaService; import io.github.hectorvent.floci.services.lambda.launcher.LambdaExecutionRoleCredentials; import io.github.hectorvent.floci.services.lambda.model.LambdaFunction; import io.github.hectorvent.floci.testing.IamEnforcementProfile; @@ -9,12 +10,17 @@ import io.quarkus.test.junit.TestProfile; import jakarta.inject.Inject; import org.junit.jupiter.api.Test; +import java.io.ByteArrayOutputStream; +import java.util.Base64; import java.util.Map; import java.util.UUID; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; +import static org.junit.jupiter.api.Assertions.assertEquals; @QuarkusTest @TestProfile(IamEnforcementProfile.class) @@ -30,7 +36,7 @@ class LambdaExecutionRoleIamEnforcementIntegrationTest { LambdaExecutionRoleCredentials executionRoleCredentials; @Inject - io.github.hectorvent.floci.services.lambda.LambdaService lambdaService; + LambdaService lambdaService; @Test void executionRoleDeniesS3ButCanGetCallerIdentity() { @@ -107,12 +113,12 @@ class LambdaExecutionRoleIamEnforcementIntegrationTest { // The gap this guards: publishVersion builds the snapshot field by field and currently // leaves accountId null, so the account has to come off the ARN. Asserting the account // resolves (rather than that the field is null) keeps this passing either way. - org.junit.jupiter.api.Assertions.assertEquals( + assertEquals( ACCOUNT_ID, LambdaExecutionRoleCredentials.sessionAccountId(version)); SessionCreds credentials = executionRoleCredentials.forFunction(version).orElseThrow(); try { - org.junit.jupiter.api.Assertions.assertEquals( + assertEquals( "arn:aws:sts::" + ACCOUNT_ID + ":assumed-role/" + roleName + "/" + functionName, iamService.resolveCallerArn(credentials.accessKeyId()).orElseThrow()); } finally { @@ -127,13 +133,13 @@ class LambdaExecutionRoleIamEnforcementIntegrationTest { } private static String handlerZipBase64() throws Exception { - java.io.ByteArrayOutputStream bytes = new java.io.ByteArrayOutputStream(); - try (java.util.zip.ZipOutputStream zip = new java.util.zip.ZipOutputStream(bytes)) { - zip.putNextEntry(new java.util.zip.ZipEntry("index.js")); + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + try (ZipOutputStream zip = new ZipOutputStream(bytes)) { + zip.putNextEntry(new ZipEntry("index.js")); zip.write("exports.handler = async () => ({});\n".getBytes()); zip.closeEntry(); } - return java.util.Base64.getEncoder().encodeToString(bytes.toByteArray()); + return Base64.getEncoder().encodeToString(bytes.toByteArray()); } private static String auth(String accessKeyId, String service) { diff --git a/src/test/java/io/github/hectorvent/floci/services/iot/IotServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/iot/IotServiceTest.java index 4409ea66c4..4de2870d6c 100644 --- a/src/test/java/io/github/hectorvent/floci/services/iot/IotServiceTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/iot/IotServiceTest.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import io.github.hectorvent.floci.config.EmulatorConfig; +import io.github.hectorvent.floci.config.FlociCertificateAuthority; import io.github.hectorvent.floci.core.common.AwsException; import io.github.hectorvent.floci.core.common.RegionResolver; import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend; @@ -16,6 +17,7 @@ import io.github.hectorvent.floci.services.dynamodb.backend.DynamoDbOperations.S import io.github.hectorvent.floci.services.dynamodb.backend.DynamoDbTableAccess; import io.github.hectorvent.floci.services.firehose.FirehoseService; import io.github.hectorvent.floci.services.firehose.model.Record; +import io.github.hectorvent.floci.services.iam.IamPolicyEvaluator; import io.github.hectorvent.floci.services.iot.model.IotPolicy; import io.github.hectorvent.floci.services.iot.model.IotShadow; import io.github.hectorvent.floci.services.iot.model.IotTopicRule; @@ -148,8 +150,8 @@ class IotServiceTest { lambda, firehose, logs, - inlineMock(io.github.hectorvent.floci.config.FlociCertificateAuthority.class), - new io.github.hectorvent.floci.services.iam.IamPolicyEvaluator(mapper)); + inlineMock(FlociCertificateAuthority.class), + new IamPolicyEvaluator(mapper)); } private IotTopicRule createRule(String name, String payloadJson) throws Exception { diff --git a/tools/checkstyle/suppressions.xml b/tools/checkstyle/suppressions.xml index 7a6a35ec8c..3c73e85adb 100644 --- a/tools/checkstyle/suppressions.xml +++ b/tools/checkstyle/suppressions.xml @@ -83,7 +83,6 @@ - @@ -117,7 +116,6 @@ - @@ -149,7 +147,6 @@ - @@ -174,7 +171,6 @@ - @@ -183,7 +179,6 @@ - @@ -197,7 +192,6 @@ - @@ -217,10 +211,8 @@ - - @@ -229,14 +221,12 @@ - - @@ -244,12 +234,10 @@ - - @@ -265,7 +253,6 @@ -