use of software.amazon.awssdk.services.glue.model.GetSchemaVersionRequest in project aws-glue-schema-registry by awslabs.
the class AWSSchemaRegistryClientTest method testWaitForSchemaEvolutionCheckToComplete_resultsAvailableResponse_returnsResponseWithSchemaId.
@Test
public void testWaitForSchemaEvolutionCheckToComplete_resultsAvailableResponse_returnsResponseWithSchemaId() throws NoSuchMethodException {
GetSchemaVersionRequest getSchemaVersionRequest = GetSchemaVersionRequest.builder().schemaVersionId(SCHEMA_ID_FOR_TESTING.toString()).build();
GetSchemaVersionResponse getSchemaVersionResponse = GetSchemaVersionResponse.builder().schemaVersionId(SCHEMA_ID_FOR_TESTING.toString()).schemaDefinition(userSchemaDefinition).status(AWSSchemaRegistryConstants.SchemaVersionStatus.AVAILABLE.toString()).build();
when(mockGlueClient.getSchemaVersion(getSchemaVersionRequest)).thenReturn(getSchemaVersionResponse);
Method waitForSchemaEvolutionCheckToCompleteMethod = AWSSchemaRegistryClient.class.getDeclaredMethod("waitForSchemaEvolutionCheckToComplete", GetSchemaVersionRequest.class);
waitForSchemaEvolutionCheckToCompleteMethod.setAccessible(true);
GetSchemaVersionResponse resultResponse = (GetSchemaVersionResponse) assertDoesNotThrow(() -> waitForSchemaEvolutionCheckToCompleteMethod.invoke(awsSchemaRegistryClient, getSchemaVersionRequest));
assertEquals(SCHEMA_ID_FOR_TESTING.toString(), resultResponse.schemaVersionId());
}
use of software.amazon.awssdk.services.glue.model.GetSchemaVersionRequest in project aws-glue-schema-registry by awslabs.
the class UserAgentRequestInterceptorTest method test_UserAgentInterceptor_ReturnsSdkRequestWithUserAgent.
@ParameterizedTest
@MethodSource("getClientConfigTestCases")
void test_UserAgentInterceptor_ReturnsSdkRequestWithUserAgent(GlueSchemaRegistryConfiguration config, String expectedName) {
AwsCredentialsProvider mockAwsCredentialsProvider = mock(AwsCredentialsProvider.class);
AWSSchemaRegistryClient awsSchemaRegistryClient = new AWSSchemaRegistryClient(mockAwsCredentialsProvider, config);
AWSSchemaRegistryClient.UserAgentRequestInterceptor userAgentRequestInterceptor = awsSchemaRegistryClient.new UserAgentRequestInterceptor();
Context.ModifyRequest modifyRequest = mock(Context.ModifyRequest.class);
GetSchemaVersionRequest glueRequest = GetSchemaVersionRequest.builder().build();
doReturn(glueRequest).when(modifyRequest).request();
SdkRequest sdkHttpRequest = userAgentRequestInterceptor.modifyRequest(modifyRequest, null);
assertNotNull(sdkHttpRequest);
assertTrue(sdkHttpRequest.overrideConfiguration().isPresent());
ApiName actualApiName = sdkHttpRequest.overrideConfiguration().get().apiNames().get(0);
assertEquals(MavenPackaging.VERSION, actualApiName.version());
assertEquals(expectedName, actualApiName.name());
}
use of software.amazon.awssdk.services.glue.model.GetSchemaVersionRequest in project aws-glue-schema-registry by awslabs.
the class AWSSchemaRegistryClientTest method testRegisterSchemaVersion_validParameters_returnsResponseWithSchemaVersionId.
@Test
public void testRegisterSchemaVersion_validParameters_returnsResponseWithSchemaVersionId() throws NoSuchFieldException, IllegalAccessException {
awsSchemaRegistryClient = configureAWSSchemaRegistryClientWithSerdeConfig(awsSchemaRegistryClient, glueSchemaRegistryConfiguration);
String schemaName = configs.get(AWSSchemaRegistryConstants.SCHEMA_NAME).toString();
String registryName = configs.get(AWSSchemaRegistryConstants.REGISTRY_NAME).toString();
String dataFormatName = DataFormat.AVRO.name();
Long schemaVersionNumber = 1L;
SchemaId requestSchemaId = SchemaId.builder().schemaName(schemaName).registryName(registryName).build();
RegisterSchemaVersionRequest registerSchemaVersionRequest = RegisterSchemaVersionRequest.builder().schemaDefinition(userSchemaDefinition).schemaId(requestSchemaId).build();
RegisterSchemaVersionResponse registerSchemaVersionResponse = RegisterSchemaVersionResponse.builder().schemaVersionId(SCHEMA_ID_FOR_TESTING.toString()).versionNumber(schemaVersionNumber).status(AWSSchemaRegistryConstants.SchemaVersionStatus.AVAILABLE.toString()).build();
GetSchemaVersionRequest getSchemaVersionRequest = GetSchemaVersionRequest.builder().schemaVersionId(SCHEMA_ID_FOR_TESTING.toString()).build();
when(mockGlueClient.registerSchemaVersion(registerSchemaVersionRequest)).thenReturn(registerSchemaVersionResponse);
assertEquals(SCHEMA_ID_FOR_TESTING.toString(), awsSchemaRegistryClient.registerSchemaVersion(userSchemaDefinition, schemaName, dataFormatName).schemaVersionId());
verify(mockGlueClient, times(0)).getSchemaVersion(getSchemaVersionRequest);
}
use of software.amazon.awssdk.services.glue.model.GetSchemaVersionRequest in project aws-glue-schema-registry by awslabs.
the class AWSSchemaRegistryClientTest method testGetSchemaVersionResponse_setSchemaVersionId_returnsResponseSchemaVersionId.
@Test
public void testGetSchemaVersionResponse_setSchemaVersionId_returnsResponseSchemaVersionId() {
GetSchemaVersionResponse getSchemaVersionResponse = GetSchemaVersionResponse.builder().schemaVersionId(SCHEMA_ID_FOR_TESTING.toString()).build();
GetSchemaVersionRequest getSchemaVersionRequest = GetSchemaVersionRequest.builder().schemaVersionId(SCHEMA_ID_FOR_TESTING.toString()).build();
when(mockGlueClient.getSchemaVersion(getSchemaVersionRequest)).thenReturn(getSchemaVersionResponse);
assertEquals(SCHEMA_ID_FOR_TESTING.toString(), awsSchemaRegistryClient.getSchemaVersionResponse(SCHEMA_ID_FOR_TESTING.toString()).schemaVersionId());
}
use of software.amazon.awssdk.services.glue.model.GetSchemaVersionRequest in project aws-glue-schema-registry by awslabs.
the class AWSSchemaRegistryClientTest method testGetSchemaVersionResponse_clientExceptionResponse_returnsAWSSchemaRegistryException.
@Test
public void testGetSchemaVersionResponse_clientExceptionResponse_returnsAWSSchemaRegistryException() {
GetSchemaVersionRequest getSchemaVersionRequest = GetSchemaVersionRequest.builder().schemaVersionId(SCHEMA_ID_FOR_TESTING.toString()).build();
when(mockGlueClient.getSchemaVersion(getSchemaVersionRequest)).thenThrow(EntityNotFoundException.class);
try {
awsSchemaRegistryClient.getSchemaVersionResponse(SCHEMA_ID_FOR_TESTING.toString());
} catch (Exception e) {
assertEquals(EntityNotFoundException.class, e.getCause().getClass());
assertEquals(AWSSchemaRegistryException.class, e.getClass());
String expectedErrorMessage = "Failed to get schema version Id = " + SCHEMA_ID_FOR_TESTING;
assertEquals(expectedErrorMessage, e.getMessage());
}
}
Aggregations