1 /* 2 * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"). 5 * You may not use this file except in compliance with the License. 6 * A copy of the License is located at 7 * 8 * http://aws.amazon.com/apache2.0 9 * 10 * or in the "license" file accompanying this file. This file is distributed 11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 * express or implied. See the License for the specific language governing 13 * permissions and limitations under the License. 14 */ 15 16 package software.amazon.awssdk.enhanced.dynamodb.converters.attribute; 17 18 import static org.assertj.core.api.Assertions.assertThatThrownBy; 19 20 import org.assertj.core.api.ThrowableAssert; 21 import software.amazon.awssdk.enhanced.dynamodb.AttributeConverter; 22 import software.amazon.awssdk.enhanced.dynamodb.internal.converter.attribute.EnhancedAttributeValue; 23 import software.amazon.awssdk.services.dynamodb.model.AttributeValue; 24 25 26 public final class ConverterTestUtils { ConverterTestUtils()27 private ConverterTestUtils() {} 28 transformFrom(AttributeConverter<T> converter, T value)29 public static <T> AttributeValue transformFrom(AttributeConverter<T> converter, T value) { 30 return converter.transformFrom(value); 31 } 32 transformTo(AttributeConverter<T> converter, AttributeValue value)33 public static <T> T transformTo(AttributeConverter<T> converter, AttributeValue value) { 34 return converter.transformTo(value); 35 } 36 transformTo(AttributeConverter<T> converter, EnhancedAttributeValue value)37 public static <T> T transformTo(AttributeConverter<T> converter, EnhancedAttributeValue value) { 38 return converter.transformTo(value.toAttributeValue()); 39 } 40 assertFails(ThrowableAssert.ThrowingCallable shouldRaiseThrowable)41 public static void assertFails(ThrowableAssert.ThrowingCallable shouldRaiseThrowable) { 42 assertThatThrownBy(shouldRaiseThrowable).isInstanceOf(IllegalArgumentException.class); 43 } 44 } 45