test(glue): reuse shared InMemoryStorageFactory and GlueRequests in remaining Glue tests (#9061)

Seven Glue service tests each declared a private InMemoryStorageFactory,
and four Glue integration tests built the AWSGlue.<action> request by
hand. They now use io.floci.aws.testing.InMemoryStorageFactory and
GlueRequests.call, which #8568 shared.
This commit is contained in:
Vũ Thế Huy authored and GitHub committed 2026-11-19 21:23:55 -04:00
1 parent 430088b772
commit 42fad08915
11 files changed
+34 -138

No files matched your search

@@ -1,5 +1,6 @@
package io.floci.aws.services.glue;
import io.floci.aws.testing.GlueRequests;
import io.floci.aws.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.response.ValidatableResponse;
@@ -8,15 +9,15 @@ import org.junit.jupiter.api.Test;
import java.util.UUID;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
@QuarkusTest
class GlueCrawlerRunIntegrationTest {
private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
private static final String ROLE = "arn:aws:iam::000000000000:role/my-role";
private static final String ACCOUNT_ID = "000000000000";
private static final String REGION = "us-east-1";
private static final String ROLE = "arn:aws:iam::" + ACCOUNT_ID + ":role/my-role";
@BeforeAll
static void configureRestAssured() {
@@ -24,11 +25,7 @@ class GlueCrawlerRunIntegrationTest {
}
private static ValidatableResponse call(String action, String body) {
return given().contentType(CONTENT_TYPE)
.header("X-Amz-Target", "AWSGlue." + action)
.body(body)
.when().post("/")
.then();
return GlueRequests.call(action, ACCOUNT_ID, REGION, body);
}
@Test
@@ -1,9 +1,7 @@
package io.floci.aws.services.glue;
import com.fasterxml.jackson.core.type.TypeReference;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.core.storage.AccountAwareStorageBackend;
import io.floci.aws.core.storage.InMemoryStorage;
import io.floci.aws.core.storage.StorageFactory;
import io.floci.aws.services.glue.model.Crawler;
@@ -14,6 +12,7 @@ import io.floci.aws.services.glue.model.Schedule;
import io.floci.aws.services.glue.schemaregistry.GlueSchemaRegistryService;
import io.floci.aws.services.kms.KmsService;
import io.floci.aws.services.resourcegroupstagging.ResourceGroupsTaggingService;
import io.floci.aws.testing.InMemoryStorageFactory;
import io.floci.aws.testing.MutableClock;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -49,7 +48,7 @@ class GlueCrawlerRunServiceTest {
@BeforeEach
void setUp() {
RegionResolver regionResolver = new RegionResolver(REGION, ACCOUNT_ID);
StorageFactory storageFactory = new InMemoryStorageFactory();
StorageFactory storageFactory = new InMemoryStorageFactory(ACCOUNT_ID);
glueService = new GlueService(storageFactory, new GlueSchemaRegistryService(storageFactory, regionResolver),
regionResolver, new ResourceGroupsTaggingService(storageFactory),
new KmsService(storageFactory, regionResolver));
@@ -318,17 +317,4 @@ class GlueCrawlerRunServiceTest {
void negativeRunDurationIsRefusedAtConstruction() {
assertThrows(IllegalArgumentException.class, () -> service(-1));
}
private static final class InMemoryStorageFactory extends StorageFactory {
private InMemoryStorageFactory() {
super(null, null);
}
@Override
public <V> AccountAwareStorageBackend<V> create(String serviceName,
String fileName,
TypeReference<Map<String, V>> typeReference) {
return AccountAwareStorageBackend.inMemory(ACCOUNT_ID);
}
}
}
@@ -1,6 +1,7 @@
package io.floci.aws.services.glue;
import io.floci.aws.config.EmulatorConfig;
import io.floci.aws.testing.GlueRequests;
import io.floci.aws.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.response.ValidatableResponse;
@@ -10,7 +11,6 @@ import org.junit.jupiter.api.Test;
import java.util.UUID;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.matchesPattern;
@@ -19,8 +19,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@QuarkusTest
class GlueJobRunIntegrationTest {
private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
private static final String ROLE = "arn:aws:iam::000000000000:role/my-role";
private static final String ACCOUNT_ID = "000000000000";
private static final String REGION = "us-east-1";
private static final String ROLE = "arn:aws:iam::" + ACCOUNT_ID + ":role/my-role";
@Inject
EmulatorConfig config;
@@ -31,11 +32,7 @@ class GlueJobRunIntegrationTest {
}
private static ValidatableResponse call(String action, String body) {
return given().contentType(CONTENT_TYPE)
.header("X-Amz-Target", "AWSGlue." + action)
.body(body)
.when().post("/")
.then();
return GlueRequests.call(action, ACCOUNT_ID, REGION, body);
}
@Test
@@ -1,9 +1,7 @@
package io.floci.aws.services.glue;
import com.fasterxml.jackson.core.type.TypeReference;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.core.storage.AccountAwareStorageBackend;
import io.floci.aws.core.storage.InMemoryStorage;
import io.floci.aws.core.storage.StorageBackend;
import io.floci.aws.core.storage.StorageFactory;
@@ -14,6 +12,7 @@ import io.floci.aws.services.glue.model.JobRun;
import io.floci.aws.services.glue.schemaregistry.GlueSchemaRegistryService;
import io.floci.aws.services.kms.KmsService;
import io.floci.aws.services.resourcegroupstagging.ResourceGroupsTaggingService;
import io.floci.aws.testing.InMemoryStorageFactory;
import io.floci.aws.testing.MutableClock;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -52,7 +51,7 @@ class GlueJobRunServiceTest {
@BeforeEach
void setUp() {
RegionResolver regionResolver = new RegionResolver(REGION, ACCOUNT_ID);
StorageFactory storageFactory = new InMemoryStorageFactory();
StorageFactory storageFactory = new InMemoryStorageFactory(ACCOUNT_ID);
glueService = new GlueService(storageFactory, new GlueSchemaRegistryService(storageFactory, regionResolver),
regionResolver, new ResourceGroupsTaggingService(storageFactory),
new KmsService(storageFactory, regionResolver));
@@ -424,18 +423,6 @@ class GlueJobRunServiceTest {
}
}
private static final class InMemoryStorageFactory extends StorageFactory {
private InMemoryStorageFactory() {
super(null, null);
}
@Override
public <V> AccountAwareStorageBackend<V> create(String serviceName,
String fileName,
TypeReference<Map<String, V>> typeReference) {
return AccountAwareStorageBackend.inMemory(ACCOUNT_ID);
}
}
@Test
void tagsReachAJobWhoseNameContainsAColon() {
@@ -1,16 +1,15 @@
package io.floci.aws.services.glue;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.core.storage.AccountAwareStorageBackend;
import io.floci.aws.core.storage.InMemoryStorage;
import io.floci.aws.core.storage.StorageBackend;
import io.floci.aws.core.storage.StorageFactory;
import io.floci.aws.services.glue.schemaregistry.GlueSchemaRegistryService;
import io.floci.aws.services.kms.KmsService;
import io.floci.aws.services.resourcegroupstagging.ResourceGroupsTaggingService;
import io.floci.aws.testing.InMemoryStorageFactory;
import jakarta.ws.rs.core.Response;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -38,7 +37,7 @@ class GlueJsonHandlerEmptyListTest {
void setUp() {
mapper = new ObjectMapper();
RegionResolver regionResolver = new RegionResolver(REGION, ACCOUNT_ID);
StorageFactory storageFactory = new InMemoryStorageFactory();
StorageFactory storageFactory = new InMemoryStorageFactory(ACCOUNT_ID);
GlueSchemaRegistryService schemaRegistryService =
new GlueSchemaRegistryService(storageFactory, regionResolver);
GlueService glueService = new GlueService(
@@ -77,17 +76,4 @@ class GlueJsonHandlerEmptyListTest {
assertFalse(body.has("NextToken"), action + " response must omit NextToken");
assertEquals(1, body.size(), action + " response must contain only " + listKey);
}
private static final class InMemoryStorageFactory extends StorageFactory {
private InMemoryStorageFactory() {
super(null, null);
}
@Override
public <V> AccountAwareStorageBackend<V> create(String serviceName,
String fileName,
TypeReference<Map<String, V>> typeReference) {
return AccountAwareStorageBackend.inMemory("000000000000");
}
}
}
@@ -8,13 +8,13 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.core.storage.AccountAwareStorageBackend;
import io.floci.aws.core.storage.InMemoryStorage;
import io.floci.aws.core.storage.StorageFactory;
import io.floci.aws.services.glue.model.Table;
import io.floci.aws.services.glue.schemaregistry.GlueSchemaRegistryService;
import io.floci.aws.services.kms.KmsService;
import io.floci.aws.services.resourcegroupstagging.ResourceGroupsTaggingService;
import io.floci.aws.testing.InMemoryStorageFactory;
import jakarta.ws.rs.core.Response;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -42,7 +42,7 @@ class GlueJsonHandlerTest {
mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
RegionResolver regionResolver = new RegionResolver(REGION, ACCOUNT_ID);
StorageFactory storageFactory = new InMemoryStorageFactory();
StorageFactory storageFactory = new InMemoryStorageFactory(ACCOUNT_ID);
GlueSchemaRegistryService schemaRegistryService =
new GlueSchemaRegistryService(storageFactory, regionResolver);
GlueService glueService = new GlueService(
@@ -700,18 +700,6 @@ class GlueJsonHandlerTest {
assertEquals("beta", ((Table) tables.get(0)).getName());
}
private static final class InMemoryStorageFactory extends StorageFactory {
private InMemoryStorageFactory() {
super(null, null);
}
@Override
public <V> AccountAwareStorageBackend<V> create(String serviceName,
String fileName,
TypeReference<Map<String, V>> typeReference) {
return AccountAwareStorageBackend.inMemory("000000000000");
}
}
private ObjectNode connectionInput(String name) {
ObjectNode input = mapper.createObjectNode();
@@ -44,6 +44,7 @@ import io.floci.aws.services.glue.schemaregistry.model.RegistryId;
import io.floci.aws.services.glue.schemaregistry.model.SchemaId;
import io.floci.aws.services.kms.KmsService;
import io.floci.aws.services.resourcegroupstagging.ResourceGroupsTaggingService;
import io.floci.aws.testing.InMemoryStorageFactory;
import io.floci.aws.testing.ParkingStore;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -133,7 +134,7 @@ class GlueServiceTest {
StorageBackend<String, UserDefinedFunction> functions,
StorageBackend<String, Table> tables) {
RegionResolver regionResolver = new RegionResolver(REGION, ACCOUNT_ID);
StorageFactory storageFactory = new InMemoryStorageFactory();
StorageFactory storageFactory = new InMemoryStorageFactory(ACCOUNT_ID);
schemaRegistryService = spy(new GlueSchemaRegistryService(storageFactory, regionResolver));
kmsService = new KmsService(storageFactory, regionResolver);
databaseStore = new InMemoryStorage<>();
@@ -1528,18 +1529,6 @@ class GlueServiceTest {
return statistics;
}
private static final class InMemoryStorageFactory extends StorageFactory {
private InMemoryStorageFactory() {
super(null, null);
}
@Override
public <V> AccountAwareStorageBackend<V> create(String serviceName,
String fileName,
TypeReference<Map<String, V>> typeReference) {
return AccountAwareStorageBackend.inMemory("000000000000");
}
}
private Job createValidJob(String name) {
Job job = new Job();
@@ -1,5 +1,6 @@
package io.floci.aws.services.glue;
import io.floci.aws.testing.GlueRequests;
import io.floci.aws.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.response.ValidatableResponse;
@@ -8,15 +9,15 @@ import org.junit.jupiter.api.Test;
import java.util.UUID;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
@QuarkusTest
class GlueTriggerIntegrationTest {
private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
private static final String ROLE = "arn:aws:iam::000000000000:role/my-role";
private static final String ACCOUNT_ID = "000000000000";
private static final String REGION = "us-east-1";
private static final String ROLE = "arn:aws:iam::" + ACCOUNT_ID + ":role/my-role";
@BeforeAll
static void configureRestAssured() {
@@ -24,11 +25,7 @@ class GlueTriggerIntegrationTest {
}
private static ValidatableResponse call(String action, String body) {
return given().contentType(CONTENT_TYPE)
.header("X-Amz-Target", "AWSGlue." + action)
.body(body)
.when().post("/")
.then();
return GlueRequests.call(action, ACCOUNT_ID, REGION, body);
}
@Test
@@ -1,10 +1,8 @@
package io.floci.aws.services.glue;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.core.storage.AccountAwareStorageBackend;
import io.floci.aws.core.storage.InMemoryStorage;
import io.floci.aws.core.storage.StorageFactory;
import io.floci.aws.services.glue.model.Crawler;
@@ -25,6 +23,7 @@ import io.floci.aws.services.glue.model.TriggerCondition;
import io.floci.aws.services.glue.schemaregistry.GlueSchemaRegistryService;
import io.floci.aws.services.kms.KmsService;
import io.floci.aws.services.resourcegroupstagging.ResourceGroupsTaggingService;
import io.floci.aws.testing.InMemoryStorageFactory;
import io.floci.aws.testing.MutableClock;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -62,7 +61,7 @@ class GlueTriggerServiceTest {
@BeforeEach
void setUp() {
RegionResolver regionResolver = new RegionResolver(REGION, ACCOUNT_ID);
StorageFactory storageFactory = new InMemoryStorageFactory();
StorageFactory storageFactory = new InMemoryStorageFactory(ACCOUNT_ID);
glueService = new GlueService(storageFactory, new GlueSchemaRegistryService(storageFactory, regionResolver),
regionResolver, new ResourceGroupsTaggingService(storageFactory),
new KmsService(storageFactory, regionResolver));
@@ -747,17 +746,4 @@ class GlueTriggerServiceTest {
assertEquals(1, runsOf("load").size());
}
private static final class InMemoryStorageFactory extends StorageFactory {
private InMemoryStorageFactory() {
super(null, null);
}
@Override
public <V> AccountAwareStorageBackend<V> create(String serviceName,
String fileName,
TypeReference<Map<String, V>> typeReference) {
return AccountAwareStorageBackend.inMemory(ACCOUNT_ID);
}
}
}
@@ -1,5 +1,6 @@
package io.floci.aws.services.glue;
import io.floci.aws.testing.GlueRequests;
import io.floci.aws.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.response.ValidatableResponse;
@@ -8,14 +9,14 @@ import org.junit.jupiter.api.Test;
import java.util.UUID;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
@QuarkusTest
class GlueWorkflowIntegrationTest {
private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
private static final String ROLE = "arn:aws:iam::000000000000:role/my-role";
private static final String ACCOUNT_ID = "000000000000";
private static final String REGION = "us-east-1";
private static final String ROLE = "arn:aws:iam::" + ACCOUNT_ID + ":role/my-role";
@BeforeAll
static void configureRestAssured() {
@@ -23,11 +24,7 @@ class GlueWorkflowIntegrationTest {
}
private static ValidatableResponse call(String action, String body) {
return given().contentType(CONTENT_TYPE)
.header("X-Amz-Target", "AWSGlue." + action)
.body(body)
.when().post("/")
.then();
return GlueRequests.call(action, ACCOUNT_ID, REGION, body);
}
@Test
@@ -1,9 +1,7 @@
package io.floci.aws.services.glue;
import com.fasterxml.jackson.core.type.TypeReference;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.core.storage.AccountAwareStorageBackend;
import io.floci.aws.core.storage.InMemoryStorage;
import io.floci.aws.core.storage.StorageFactory;
import io.floci.aws.services.glue.model.Crawler;
@@ -22,6 +20,7 @@ import io.floci.aws.services.glue.model.WorkflowRun;
import io.floci.aws.services.glue.schemaregistry.GlueSchemaRegistryService;
import io.floci.aws.services.kms.KmsService;
import io.floci.aws.services.resourcegroupstagging.ResourceGroupsTaggingService;
import io.floci.aws.testing.InMemoryStorageFactory;
import io.floci.aws.testing.MutableClock;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -59,7 +58,7 @@ class GlueWorkflowServiceTest {
@BeforeEach
void setUp() {
RegionResolver regionResolver = new RegionResolver(REGION, ACCOUNT_ID);
StorageFactory storageFactory = new InMemoryStorageFactory();
StorageFactory storageFactory = new InMemoryStorageFactory(ACCOUNT_ID);
glueService = new GlueService(storageFactory, new GlueSchemaRegistryService(storageFactory, regionResolver),
regionResolver, new ResourceGroupsTaggingService(storageFactory),
new KmsService(storageFactory, regionResolver));
@@ -625,17 +624,4 @@ class GlueWorkflowServiceTest {
.map(node -> (String) node.get("UniqueId"))
.findFirst().orElseThrow();
}
private static final class InMemoryStorageFactory extends StorageFactory {
private InMemoryStorageFactory() {
super(null, null);
}
@Override
public <V> AccountAwareStorageBackend<V> create(String serviceName,
String fileName,
TypeReference<Map<String, V>> typeReference) {
return AccountAwareStorageBackend.inMemory(ACCOUNT_ID);
}
}
}