-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix a bug: Caused by: scala.MatchError: Some(xxxx) (of class scala.Some)
- Loading branch information
Showing
8 changed files
with
307 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
src/test/scala/org/embulk/input/dynamodb/DynamodbOperationTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package org.embulk.input.dynamodb | ||
|
||
import com.amazonaws.services.dynamodbv2.model.{ | ||
AttributeDefinition, | ||
AttributeValue, | ||
BillingMode, | ||
CreateTableRequest, | ||
KeySchemaElement, | ||
KeyType, | ||
PutItemRequest, | ||
ScalarAttributeType | ||
} | ||
import org.embulk.config.ConfigSource | ||
import org.embulk.input.dynamodb.testutil.EmbulkTestBase | ||
import org.junit.Test | ||
|
||
import scala.jdk.CollectionConverters._ | ||
|
||
class DynamodbOperationTest extends EmbulkTestBase { | ||
|
||
@Test | ||
def limitTest(): Unit = { | ||
val tableName = "limit_test" | ||
cleanupTable(tableName) | ||
withDynamodb { dynamodb => | ||
dynamodb.createTable( | ||
new CreateTableRequest() | ||
.withTableName(tableName) | ||
.withAttributeDefinitions( | ||
new AttributeDefinition() | ||
.withAttributeName("pk") | ||
.withAttributeType(ScalarAttributeType.S) | ||
) | ||
.withKeySchema( | ||
new KeySchemaElement() | ||
.withAttributeName("pk") | ||
.withKeyType(KeyType.HASH) | ||
) | ||
.withBillingMode(BillingMode.PAY_PER_REQUEST) | ||
) | ||
dynamodb.putItem( | ||
new PutItemRequest() | ||
.withTableName(tableName) | ||
.withItem( | ||
Map | ||
.newBuilder[String, AttributeValue] | ||
.addOne("pk", new AttributeValue().withS("a")) | ||
.result() | ||
.asJava | ||
) | ||
) | ||
dynamodb.putItem( | ||
new PutItemRequest() | ||
.withTableName(tableName) | ||
.withItem( | ||
Map | ||
.newBuilder[String, AttributeValue] | ||
.addOne("pk", new AttributeValue().withS("a")) | ||
.result() | ||
.asJava | ||
) | ||
) | ||
dynamodb.putItem( | ||
new PutItemRequest() | ||
.withTableName(tableName) | ||
.withItem( | ||
Map | ||
.newBuilder[String, AttributeValue] | ||
.addOne("pk", new AttributeValue().withS("a")) | ||
.result() | ||
.asJava | ||
) | ||
) | ||
dynamodb.putItem( | ||
new PutItemRequest() | ||
.withTableName(tableName) | ||
.withItem( | ||
Map | ||
.newBuilder[String, AttributeValue] | ||
.addOne("pk", new AttributeValue().withS("b")) | ||
.result() | ||
.asJava | ||
) | ||
) | ||
dynamodb.putItem( | ||
new PutItemRequest() | ||
.withTableName(tableName) | ||
.withItem( | ||
Map | ||
.newBuilder[String, AttributeValue] | ||
.addOne("pk", new AttributeValue().withS("b")) | ||
.result() | ||
.asJava | ||
) | ||
) | ||
} | ||
|
||
val inScanConfig: ConfigSource = loadConfigSourceFromYamlString(s""" | ||
|type: dynamodb | ||
|table: $tableName | ||
|endpoint: http://$dynamoDBHost:$dynamoDBPort/ | ||
|auth_method: basic | ||
|access_key_id: dummy | ||
|secret_access_key: dummy | ||
|scan: | ||
| limit: 1 | ||
|""".stripMargin) | ||
runInput(inScanConfig, { result => | ||
assert(result.size.equals(1)) | ||
}) | ||
|
||
val inQueryConfig: ConfigSource = loadConfigSourceFromYamlString(s""" | ||
|type: dynamodb | ||
|table: $tableName | ||
|endpoint: http://$dynamoDBHost:$dynamoDBPort/ | ||
|auth_method: basic | ||
|access_key_id: dummy | ||
|secret_access_key: dummy | ||
|query: | ||
| key_condition_expression: "#x = :v" | ||
| expression_attribute_names: | ||
| "#x": pk | ||
| expression_attribute_values: | ||
| ":v": {S: a} | ||
| limit: 1 | ||
|""".stripMargin) | ||
runInput(inQueryConfig, { result => | ||
assert(result.size.equals(1)) | ||
}) | ||
} | ||
} |
Oops, something went wrong.