diff --git a/src/test/java/io/github/hectorvent/floci/services/appsync/AppSyncServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/appsync/AppSyncServiceTest.java index 2d3c59fc3f..a665df7d7b 100644 --- a/src/test/java/io/github/hectorvent/floci/services/appsync/AppSyncServiceTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/appsync/AppSyncServiceTest.java @@ -1,13 +1,11 @@ package io.github.hectorvent.floci.services.appsync; -import com.fasterxml.jackson.core.type.TypeReference; 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; import io.github.hectorvent.floci.core.common.RequestContext; import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend; -import io.github.hectorvent.floci.core.storage.StorageFactory; import io.github.hectorvent.floci.services.appsync.graphql.SchemaCreationWorker; import io.github.hectorvent.floci.services.appsync.graphql.SchemaRegistry; import io.github.hectorvent.floci.services.appsync.graphql.auth.LambdaAuthorizerCache; @@ -18,6 +16,7 @@ import io.github.hectorvent.floci.services.appsync.model.DomainName; import io.github.hectorvent.floci.services.appsync.model.FunctionConfiguration; import io.github.hectorvent.floci.services.appsync.model.GraphqlApi; import io.github.hectorvent.floci.services.appsync.model.SchemaCreationStatus; +import io.github.hectorvent.floci.testing.InMemoryStorageFactory; import jakarta.enterprise.inject.Instance; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -412,19 +411,11 @@ class AppSyncServiceTest { @SuppressWarnings("unchecked") private AppSyncService newService(Clock clock, String baseUrl, AccountAwareStorageBackend apiStore) { - StorageFactory storageFactory = new StorageFactory(null, null) { - @Override - public AccountAwareStorageBackend create(String serviceName, String fileName, - TypeReference> typeReference) { - if ("appsync-apis.json".equals(fileName)) { - return (AccountAwareStorageBackend) apiStore; - } - if ("appsync-apikeys.json".equals(fileName) && apiKeyStoreOverride != null) { - return (AccountAwareStorageBackend) apiKeyStoreOverride; - } - return AccountAwareStorageBackend.inMemory("000000000000"); - } - }; + InMemoryStorageFactory storageFactory = new InMemoryStorageFactory("000000000000") + .withStore("appsync-apis.json", apiStore); + if (apiKeyStoreOverride != null) { + storageFactory.withStore("appsync-apikeys.json", apiKeyStoreOverride); + } Instance requestContext = mock(Instance.class); schemaRegistry = mock(SchemaRegistry.class); lambdaAuthorizerCache = new LambdaAuthorizerCache(); diff --git a/src/test/java/io/github/hectorvent/floci/services/configservice/AwsConfigServiceAggregationAuthorizationTest.java b/src/test/java/io/github/hectorvent/floci/services/configservice/AwsConfigServiceAggregationAuthorizationTest.java index 9c435cfd27..52e1004b9f 100644 --- a/src/test/java/io/github/hectorvent/floci/services/configservice/AwsConfigServiceAggregationAuthorizationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/configservice/AwsConfigServiceAggregationAuthorizationTest.java @@ -1,15 +1,11 @@ package io.github.hectorvent.floci.services.configservice; -import com.fasterxml.jackson.core.type.TypeReference; import io.github.hectorvent.floci.core.common.AwsArnUtils; 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.StorageBackend; -import io.github.hectorvent.floci.core.storage.StorageFactory; -import io.github.hectorvent.floci.core.storage.WriteProfile; import io.github.hectorvent.floci.services.configservice.model.AggregationAuthorization; import io.github.hectorvent.floci.services.configservice.model.ConformancePack; +import io.github.hectorvent.floci.testing.InMemoryStorageFactory; import io.github.hectorvent.floci.testing.ParkingStore; import org.junit.jupiter.api.Test; @@ -237,17 +233,7 @@ class AwsConfigServiceAggregationAuthorizationTest { void aPackDeleteWaitsForAnUpdateAlreadyInProgress() throws Exception { ParkingStore> packs = new ParkingStore<>(); AwsConfigService service = new AwsConfigService(new RegionResolver(REGION, ACCOUNT), - new StorageFactory(null, null) { - @Override - @SuppressWarnings("unchecked") - public AccountAwareStorageBackend create(String serviceName, String fileName, - TypeReference> typeReference, WriteProfile profile) { - return fileName.equals("config-conformance-packs.json") - ? new AccountAwareStorageBackend<>((StorageBackend) (Object) packs, - null, ACCOUNT) - : AccountAwareStorageBackend.inMemory(ACCOUNT); - } - }); + new InMemoryStorageFactory(ACCOUNT).withStore("config-conformance-packs.json", packs)); service.initializeStorage(); String arn = service.putConformancePack(REGION, "pack", "s3://bucket/v1.yaml", null) .conformancePackArn(); diff --git a/src/test/java/io/github/hectorvent/floci/services/configservice/AwsConfigServiceTaggingTest.java b/src/test/java/io/github/hectorvent/floci/services/configservice/AwsConfigServiceTaggingTest.java index 7d266c32fa..662e3c15de 100644 --- a/src/test/java/io/github/hectorvent/floci/services/configservice/AwsConfigServiceTaggingTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/configservice/AwsConfigServiceTaggingTest.java @@ -1,15 +1,12 @@ package io.github.hectorvent.floci.services.configservice; -import com.fasterxml.jackson.core.type.TypeReference; 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.core.storage.WriteProfile; import io.github.hectorvent.floci.services.configservice.model.ConfigRule; import io.github.hectorvent.floci.services.configservice.model.ConfigRuleSource; +import io.github.hectorvent.floci.testing.InMemoryStorageFactory; import io.github.hectorvent.floci.testing.ParkingStore; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; @@ -230,17 +227,7 @@ class AwsConfigServiceTaggingTest { private static AwsConfigService serviceWithTagStore(StorageBackend> tagStore) { AwsConfigService service = new AwsConfigService(new RegionResolver(REGION, ACCOUNT), - new StorageFactory(null, null) { - @Override - @SuppressWarnings("unchecked") - public AccountAwareStorageBackend create(String serviceName, String fileName, - TypeReference> typeReference, WriteProfile profile) { - return fileName.equals("config-tags.json") - ? new AccountAwareStorageBackend<>((StorageBackend) (Object) tagStore, - null, ACCOUNT) - : AccountAwareStorageBackend.inMemory(ACCOUNT); - } - }); + new InMemoryStorageFactory(ACCOUNT).withStore("config-tags.json", tagStore)); service.initializeStorage(); return service; }