Search in sources :

Example 6 with ScanRequest

use of software.amazon.awssdk.services.dynamodb.model.ScanRequest in project syndesis-qe by syndesisio.

the class DynamoDbUtils method verifyRecordIsPresent.

public boolean verifyRecordIsPresent(Map<String, String> recordValue) {
    boolean tableContainsItem = false;
    ScanRequest scanRequest = ScanRequest.builder().tableName(tableName).build();
    ScanResponse result = dynamoDb.scan(scanRequest);
    for (Map<String, AttributeValue> item : result.items()) {
        if (item.isEmpty()) {
            fail("There is no record in the table");
        }
        int i = item.keySet().size() - 1;
        if (!tableContainsItem) {
            for (String key : item.keySet()) {
                if (item.get(key).s().equals(recordValue.get(key))) {
                    if (i > 0) {
                        i--;
                    } else {
                        tableContainsItem = true;
                        break;
                    }
                } else {
                    break;
                }
            }
        }
    }
    return tableContainsItem;
}
Also used : ScanRequest(software.amazon.awssdk.services.dynamodb.model.ScanRequest) AttributeValue(software.amazon.awssdk.services.dynamodb.model.AttributeValue) ScanResponse(software.amazon.awssdk.services.dynamodb.model.ScanResponse)

Aggregations

ScanRequest (software.amazon.awssdk.services.dynamodb.model.ScanRequest)6 AttributeValue (software.amazon.awssdk.services.dynamodb.model.AttributeValue)5 ScanResponse (software.amazon.awssdk.services.dynamodb.model.ScanResponse)5 Map (java.util.Map)2 Function (java.util.function.Function)2 Flowable (io.reactivex.Flowable)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 SortedSet (java.util.SortedSet)1 TreeSet (java.util.TreeSet)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 UtilityClass (lombok.experimental.UtilityClass)1 Slf4j (lombok.extern.slf4j.Slf4j)1 lombok.val (lombok.val)1 Pair (org.apache.commons.lang3.tuple.Pair)1 AbstractDynamoDbProperties (org.apereo.cas.configuration.model.support.dynamodb.AbstractDynamoDbProperties)1 LoggingUtils (org.apereo.cas.util.LoggingUtils)1