com.amazonaws.util.ImmutableMapParameter Java Examples
The following examples show how to use
com.amazonaws.util.ImmutableMapParameter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScanITCase.java From aws-dynamodb-encryption-java with Apache License 2.0 | 6 votes |
/** * Tests scanning the table with AND/OR logic operator. */ @Test public void testScanWithConditionalOperator() { DynamoDBMapper mapper = TestDynamoDBMapperFactory.createDynamoDBMapper(dynamo); DynamoDBScanExpression scanExpression = new DynamoDBScanExpression() .withLimit(SCAN_LIMIT) .withScanFilter(ImmutableMapParameter.of( "value", new Condition().withComparisonOperator(ComparisonOperator.NOT_NULL), "non-existent-field", new Condition().withComparisonOperator(ComparisonOperator.NOT_NULL) )) .withConditionalOperator(ConditionalOperator.AND); List<SimpleClass> andConditionResult = mapper.scan(SimpleClass.class, scanExpression); assertTrue(andConditionResult.isEmpty()); List<SimpleClass> orConditionResult = mapper.scan(SimpleClass.class, scanExpression.withConditionalOperator(ConditionalOperator.OR)); assertFalse(orConditionResult.isEmpty()); }
Example #2
Source File: V1ItemFactory.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
@Override protected Map<String, AttributeValue> asItem(TinyBean b) { ImmutableMapParameter.Builder<String, AttributeValue> builder = ImmutableMapParameter.builder(); builder.put("stringAttr", av(b.getStringAttr())); return builder.build(); }
Example #3
Source File: V1ItemFactory.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
@Override protected Map<String, AttributeValue> asItem(HugeBean b) { ImmutableMapParameter.Builder<String, AttributeValue> builder = ImmutableMapParameter.builder(); builder.put("hashKey", av(b.getHashKey())); builder.put("stringAttr", av(b.getStringAttr())); builder.put("binaryAttr", av(b.getBinaryAttr())); List<AttributeValue> listAttr = b.getListAttr().stream().map(this::av).collect(Collectors.toList()); builder.put("listAttr", av(listAttr)); Map<String, AttributeValue> mapAttr1 = b.getMapAttr1().entrySet().stream().collect( Collectors.toMap(Map.Entry::getKey, e -> av(e.getValue()))); builder.put("mapAttr1", av(mapAttr1)); Map<String, AttributeValue> mapAttr2 = b.getMapAttr2().entrySet().stream().collect( Collectors.toMap(Map.Entry::getKey, e -> av(e.getValue().stream().map(this::av).collect(Collectors.toList())))); builder.put("mapAttr2", av(mapAttr2)); Map<String, AttributeValue> mapAttr3 = b.getMapAttr3().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> { List<Map<String, List<SdkBytes>>> value = e.getValue(); AttributeValue valueAv = av(value.stream().map(m -> av(m.entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, ee -> av(ee.getValue().stream().map(this::av).collect(Collectors.toList())))))) .collect(Collectors.toList())); return valueAv; })); builder.put("mapAttr3", av(mapAttr3)); return builder.build(); }
Example #4
Source File: V2ItemFactory.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
protected Map<String, AttributeValue> asItem(HugeBean b) { ImmutableMapParameter.Builder<String, AttributeValue> builder = ImmutableMapParameter.builder(); builder.put("hashKey", av(b.getHashKey())); builder.put("stringAttr", av(b.getStringAttr())); builder.put("binaryAttr", av(b.getBinaryAttr())); List<AttributeValue> listAttr = b.getListAttr().stream().map(this::av).collect(Collectors.toList()); builder.put("listAttr", av(listAttr)); Map<String, AttributeValue> mapAttr1 = b.getMapAttr1().entrySet().stream().collect( Collectors.toMap(Map.Entry::getKey, e -> av(e.getValue()))); builder.put("mapAttr1", av(mapAttr1)); Map<String, AttributeValue> mapAttr2 = b.getMapAttr2().entrySet().stream().collect( Collectors.toMap(Map.Entry::getKey, e -> av(e.getValue().stream().map(this::av).collect(Collectors.toList())))); builder.put("mapAttr2", av(mapAttr2)); Map<String, AttributeValue> mapAttr3 = b.getMapAttr3().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> { List<Map<String, List<SdkBytes>>> value = e.getValue(); AttributeValue valueAv = av(value.stream().map(m -> av(m.entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, ee -> av(ee.getValue().stream().map(this::av).collect(Collectors.toList())))))) .collect(Collectors.toList())); return valueAv; })); builder.put("mapAttr3", av(mapAttr3)); return builder.build(); }
Example #5
Source File: AbstractItemFactory.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
final Map<String, T> small() { return ImmutableMapParameter.<String, T>builder() .put("stringAttr", av(randomS())) .put("binaryAttr", av(randomB())) .put("listAttr", av(Arrays.asList( av(randomS()), av(randomB()), av(randomS()) ))) .build(); }
Example #6
Source File: SQSResourcesIntegrationTest.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
/** * Tests sending of message with message attributes. Asserts that the * message received has the attributes. Also changes the visibility of the * messages and tries to retrieve them. Performs delete action on the * message to the delete it from the queue. */ @Test @Ignore public void testSendReceiveMessageAttributes() throws InterruptedException { SendMessageResult sendMessageResult = queue .sendMessage(new SendMessageRequest().withMessageBody( TEST_MESSAGE_ATTRIBUTES).withMessageAttributes( ImmutableMapParameter.of( "testAttribute", new MessageAttributeValue().withDataType( "String").withStringValue( "testAttributeValue")))); List<Message> messages = waitForMessagesFromQueue(new ReceiveMessageRequest() .withMessageAttributeNames("testAttribute")); assertNotNull(messages); assertEquals(1, messages.size()); Message message = messages.get(0); assertMessage(TEST_MESSAGE_ATTRIBUTES, sendMessageResult.getMessageId(), sendMessageResult.getMD5OfMessageBody(), message); Map<String, MessageAttributeValue> messageAttributes = message .getMessageAttributes(); assertNotNull(messageAttributes); assertTrue(messageAttributes.containsKey("testAttribute")); assertEquals(messageAttributes.get("testAttribute").getStringValue(), "testAttributeValue"); message.changeVisibility(10); messages = waitForMessagesFromQueue(null); message.delete(); }
Example #7
Source File: SQSResourcesIntegrationTest.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
/** * Tests sending messages using batch operation and retrieve them. Also * tests setting the queue attributes and retrieving them. */ @Test @Ignore public void testQueueSubResourceAndAttributes() throws InterruptedException { /** * Trying to get the message which is deleted. Here there is no service * call made, a new sub resource is created with the given handle. So, * this wont be returning null. */ Message message = queue.getMessage("invalid-recepient-handle"); assertNotNull(message); try { message.getAttributes(); fail("An unsupported operation exception must be thrown as load operation is no supported on message attribute"); } catch (UnsupportedOperationException use) { } SendMessageBatchResult sendMessageBatchResult = queue .sendMessages(new SendMessageBatchRequest() .withEntries(new SendMessageBatchRequestEntry("msg1", TEST_MESSAGE))); SendMessageBatchResultEntry sendMessageBatchResultEntry = sendMessageBatchResult .getSuccessful().get(0); List<Message> messages = waitForMessagesFromQueue(null); assertNotNull(messages); assertEquals(1, messages.size()); message = messages.get(0); assertMessage(TEST_MESSAGE, sendMessageBatchResultEntry.getMessageId(), sendMessageBatchResultEntry.getMD5OfMessageBody(), message); queue.setAttributes(ImmutableMapParameter.of("MaximumMessageSize", "2048")); assertTrue(queue.getAttributes().containsKey("MaximumMessageSize")); }
Example #8
Source File: ItemFactory.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
public final HugeBean hugeBean() { HugeBean b = new HugeBean(); b.setHashKey(randomS()); b.setStringAttr(randomS()); b.setBinaryAttr(randomBytes()); b.setListAttr(IntStream.range(0, 32).mapToObj(i -> randomS()).collect(Collectors.toList())); Map<String, SdkBytes> mapAttr1 = new HashMap<>(); mapAttr1.put("key1", randomBytes()); mapAttr1.put("key2", randomBytes()); mapAttr1.put("key3", randomBytes()); b.setMapAttr1(mapAttr1); Map<String, List<SdkBytes>> mapAttr2 = new HashMap<>(); mapAttr2.put("key1", Arrays.asList(randomBytes())); mapAttr2.put("key2", IntStream.range(0, 2).mapToObj(i -> randomBytes()).collect(Collectors.toList())); mapAttr2.put("key3", IntStream.range(0, 4).mapToObj(i -> randomBytes()).collect(Collectors.toList())); mapAttr2.put("key4", IntStream.range(0, 8).mapToObj(i -> randomBytes()).collect(Collectors.toList())); mapAttr2.put("key5", IntStream.range(0, 16).mapToObj(i -> randomBytes()).collect(Collectors.toList())); b.setMapAttr2(mapAttr2); ImmutableMapParameter.Builder<String, List<Map<String, List<SdkBytes>>>> mapAttr3Builder = ImmutableMapParameter.builder(); List<Map<String, List<SdkBytes>>> value = Arrays.asList( ImmutableMapParameter.<String, List<SdkBytes>>builder() .put("key1", IntStream.range(0, 2).mapToObj(i -> randomBytes()).collect(Collectors.toList())) .build(), ImmutableMapParameter.<String, List<SdkBytes>>builder() .put("key2", IntStream.range(0, 4).mapToObj(i -> randomBytes()).collect(Collectors.toList())) .build(), ImmutableMapParameter.<String, List<SdkBytes>>builder() .put("key3", IntStream.range(0, 8).mapToObj(i -> randomBytes()).collect(Collectors.toList())) .build() ); mapAttr3Builder.put("key1", value) .put("key2", value) .build(); b.setMapAttr3(mapAttr3Builder.build()); return b; }
Example #9
Source File: AbstractItemFactory.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
final Map<String, T> tiny() { return ImmutableMapParameter.<String, T>builder() .put("stringAttr", av(randomS())) .build(); }
Example #10
Source File: AbstractItemFactory.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
final Map<String, T> huge() { return ImmutableMapParameter.<String, T>builder() .put("hashKey", av(randomS())) .put("stringAttr", av(randomS())) .put("binaryAttr", av(randomB())) .put("listAttr", av( Arrays.asList( av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomB()), av(Collections.singletonList(av(randomS()))), av(ImmutableMapParameter.of( "attrOne", av(randomS()) )), av(Arrays.asList( av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(randomB()), (av(randomS())), av(ImmutableMapParameter.of( "attrOne", av(randomS()) )) )) ) )) .put("mapAttr", av( ImmutableMapParameter.<String, T>builder() .put("attrOne", av(randomS())) .put("attrTwo", av(randomB())) .put("attrThree", av( Arrays.asList( av(randomS()), av(randomS()), av(randomS()), av(randomS()), av(ImmutableMapParameter.<String, T>builder() .put("attrOne", av(randomS())) .put("attrTwo", av(randomB())) .put("attrThree", av(Arrays.asList( av(randomS()), av(randomS()), av(randomS()), av(randomS()) )) ) .build()) )) ) .build())) .build(); }
Example #11
Source File: V1ItemFactory.java From aws-sdk-java-v2 with Apache License 2.0 | 3 votes |
@Override protected Map<String, AttributeValue> asItem(SmallBean b) { ImmutableMapParameter.Builder<String, AttributeValue> builder = ImmutableMapParameter.builder(); builder.put("stringAttr", av(b.getStringAttr())); builder.put("binaryAttr", av(b.getBinaryAttr())); List<AttributeValue> listAttr = b.getListAttr().stream().map(this::av).collect(Collectors.toList()); builder.put("listAttr", av(listAttr)); return builder.build(); }
Example #12
Source File: V2ItemFactory.java From aws-sdk-java-v2 with Apache License 2.0 | 3 votes |
protected Map<String, AttributeValue> asItem(TinyBean b) { ImmutableMapParameter.Builder<String, AttributeValue> builder = ImmutableMapParameter.builder(); builder.put("stringAttr", av(b.getStringAttr())); return builder.build(); }
Example #13
Source File: V2ItemFactory.java From aws-sdk-java-v2 with Apache License 2.0 | 3 votes |
protected Map<String, AttributeValue> asItem(SmallBean b) { ImmutableMapParameter.Builder<String, AttributeValue> builder = ImmutableMapParameter.builder(); builder.put("stringAttr", av(b.getStringAttr())); builder.put("binaryAttr", av(b.getBinaryAttr())); List<AttributeValue> listAttr = b.getListAttr().stream().map(this::av).collect(Collectors.toList()); builder.put("listAttr", av(listAttr)); return builder.build(); }