DynamodbAttributeValueTransformer { public static AttributeValue toAttributeValueV2(final com.amazonaws.services.lambda.runtime.events.models.dynamodb.AttributeValue value) { if (Objects.nonNull(value.getS())) { return AttributeValue.builder() .s(value.getS()) .build(); } else if (Objects.nonNull(value.getSS())) { return AttributeValue.builder() .ss(value.getSS()) .build(); } else if (Objects.nonNull(value.getN())) { return AttributeValue.builder() .n(value.getN()) .build(); } else if (Objects.nonNull(value.getNS())) { return AttributeValue.builder() .ns(value.getNS()) .build(); } else if (Objects.nonNull(value.getB())) { return AttributeValue.builder() .b(SdkBytes.fromByteBuffer(value.getB())) .build(); } else if (Objects.nonNull(value.getBS())) { return AttributeValue.builder() .bs(value.getBS().stream() .map(SdkBytes::fromByteBuffer) .collect(Collectors.toList())) .build(); } else if (Objects.nonNull(value.getBOOL())) { return AttributeValue.builder() .bool(value.getBOOL()) .build(); } else if (Objects.nonNull(value.getL())) { return AttributeValue.builder() .l(value.getL().stream() .map(DynamodbAttributeValueTransformer::toAttributeValueV2) .collect(Collectors.toList())) .build(); } else if (Objects.nonNull(value.getM())) { return AttributeValue.builder() .m(toAttributeValueMapV2(value.getM())) .build(); } else if (Objects.nonNull(value.getNULL())) { return AttributeValue.builder() .nul(value.getNULL()) .build(); } else { throw new IllegalArgumentException( String.format("Unsupported attributeValue type: %s", value)); } }  static AttributeValue toAttributeValueV2(final com.amazonaws.services.lambda.runtime.events.models.dynamodb.AttributeValue value);  }
@Test public void testToAttributeValueV2_N() { software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueN = DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueN_event); Assertions.assertEquals(attributeValueN_v2, convertedAttributeValueN); }
@Test public void testToAttributeValueV2_IllegalArgumentWhenNull() { Assertions.assertThrows(IllegalArgumentException.class, () -> DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue()) ); }
@Test public void testToAttributeValueV2_IllegalArgumentWhenNull_N() { Assertions.assertThrows(IllegalArgumentException.class, () -> DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withN(null)) ); }
@Test public void testToAttributeValueV2_IllegalArgumentWhenNull_S() { Assertions.assertThrows(IllegalArgumentException.class, () -> DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withS(null)) ); }
@Test public void testToAttributeValueV2_IllegalArgumentWhenNull_B() { Assertions.assertThrows(IllegalArgumentException.class, () -> DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withB(null)) ); }
@Test public void testToAttributeValueV2_IllegalArgumentWhenNull_BOOL() { Assertions.assertThrows(IllegalArgumentException.class, () -> DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withBOOL(null)) ); }
@Test public void testToAttributeValueV2_IllegalArgumentWhenNull_NUL() { Assertions.assertThrows(IllegalArgumentException.class, () -> DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withNULL(null)) ); }
@Test public void testToAttributeValueV2_IllegalArgumentWhenNull_M() { Assertions.assertThrows(IllegalArgumentException.class, () -> DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withM(null)) ); }
@Test public void testToAttributeValueV2_DoesNotThrowWhenEmpty_NS() { Assertions.assertDoesNotThrow(() -> DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withNS()) ); Assertions.assertDoesNotThrow(() -> DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withNS(Collections.emptyList())) ); }
@Test public void testToAttributeValueV2_DoesNotThrowWhenEmpty_SS() { Assertions.assertDoesNotThrow(() -> DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withSS()) ); Assertions.assertDoesNotThrow(() -> DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withSS(Collections.emptyList())) ); }
@Test public void testToAttributeValueV2_DoesNotThrowWhenEmpty_BS() { Assertions.assertDoesNotThrow(() -> DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withBS()) ); Assertions.assertDoesNotThrow(() -> DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withBS(Collections.emptyList())) ); }
@Test public void testToAttributeValueV2_NS() { software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueNS = DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueNS_event); Assertions.assertEquals(attributeValueNS_v2, convertedAttributeValueNS); }
@Test public void testToAttributeValueV2_DoesNotThrowWhenEmpty_L() { Assertions.assertDoesNotThrow(() -> DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withL()) ); Assertions.assertDoesNotThrow(() -> DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withL(Collections.emptyList())) ); }
@Test public void testToAttributeValueV2_EmptyV2ObjectWhenEmpty_NS() { software.amazon.awssdk.services.dynamodb.model.AttributeValue expectedAttributeValue_v2 = software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().build(); Assertions.assertEquals(expectedAttributeValue_v2, DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withNS())); Assertions.assertEquals(expectedAttributeValue_v2, DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withNS(Collections.emptyList()))); }
@Test public void testToAttributeValueV2_EmptyV2ObjectWhenEmpty_SS() { software.amazon.awssdk.services.dynamodb.model.AttributeValue expectedAttributeValue_v2 = software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().build(); Assertions.assertEquals(expectedAttributeValue_v2, DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withSS())); Assertions.assertEquals(expectedAttributeValue_v2, DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withSS(Collections.emptyList()))); }
@Test public void testToAttributeValueV2_EmptyV2ObjectWhenEmpty_BS() { software.amazon.awssdk.services.dynamodb.model.AttributeValue expectedAttributeValue_v2 = software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().build(); Assertions.assertEquals(expectedAttributeValue_v2, DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withBS())); Assertions.assertEquals(expectedAttributeValue_v2, DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withBS(Collections.emptyList()))); }
@Test public void testToAttributeValueV2_EmptyV2ObjectWhenEmpty_L() { software.amazon.awssdk.services.dynamodb.model.AttributeValue expectedAttributeValue_v2 = software.amazon.awssdk.services.dynamodb.model.AttributeValue.builder().build(); Assertions.assertEquals(expectedAttributeValue_v2, DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withL())); Assertions.assertEquals(expectedAttributeValue_v2, DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withL(Collections.emptyList()))); }
@Test public void testToAttributeValueV2_S() { software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueS = DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueS_event); Assertions.assertEquals(attributeValueS_v2, convertedAttributeValueS); }
@Test public void testToAttributeValueV2_SS() { software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueSS = DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueSS_event); Assertions.assertEquals(attributeValueSS_v2, convertedAttributeValueSS); }
@Test public void testToAttributeValueV2_B() { software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueB = DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueB_event); Assertions.assertEquals(attributeValueB_v2, convertedAttributeValueB); }
@Test public void testToAttributeValueV2_BS() { software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueBS = DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueBS_event); Assertions.assertEquals(attributeValueBS_v2, convertedAttributeValueBS); }
@Test public void testToAttributeValueV2_BOOL() { software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueBOOL = DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueBOOL_event); Assertions.assertEquals(attributeValueBOOL_v2, convertedAttributeValueBOOL); }
@Test public void testToAttributeValueV2_NUL() { software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueNUL = DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueNUL_event); Assertions.assertEquals(attributeValueNUL_v2, convertedAttributeValueNUL); }
@Test public void testToAttributeValueV2_M() { software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueM = DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueM_event); Assertions.assertEquals(attributeValueM_v2, convertedAttributeValueM); }
@Test public void testToAttributeValueV2_L() { software.amazon.awssdk.services.dynamodb.model.AttributeValue convertedAttributeValueL = DynamodbAttributeValueTransformer.toAttributeValueV2(attributeValueL_event); Assertions.assertEquals(attributeValueL_v2, convertedAttributeValueL); }