From b1a3559db1e029ee9ebe5ddaa5e04d53d75d52e2 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 9 May 2016 14:59:03 +0200 Subject: [PATCH] DATAREDIS-509 - Polishing. Update license headers. Add test for index resolver using an indexed primitive array. Original pull request: #196. --- .../core/convert/ConversionTestEntities.java | 2 +- .../convert/PathIndexResolverUnitTests.java | 28 ++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/springframework/data/redis/core/convert/ConversionTestEntities.java b/src/test/java/org/springframework/data/redis/core/convert/ConversionTestEntities.java index d3903ec9b..9b7f7adb9 100644 --- a/src/test/java/org/springframework/data/redis/core/convert/ConversionTestEntities.java +++ b/src/test/java/org/springframework/data/redis/core/convert/ConversionTestEntities.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/org/springframework/data/redis/core/convert/PathIndexResolverUnitTests.java b/src/test/java/org/springframework/data/redis/core/convert/PathIndexResolverUnitTests.java index 40bb1a826..3d51e3445 100644 --- a/src/test/java/org/springframework/data/redis/core/convert/PathIndexResolverUnitTests.java +++ b/src/test/java/org/springframework/data/redis/core/convert/PathIndexResolverUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-216 the original author or authors. + * Copyright 2015-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,6 +55,7 @@ import org.springframework.data.util.ClassTypeInformation; /** * @author Christoph Strobl + * @author Mark Paluch */ @RunWith(MockitoJUnitRunner.class) public class PathIndexResolverUnitTests { @@ -490,6 +491,26 @@ public class PathIndexResolverUnitTests { new SimpleIndexedPropertyValue(IndexedOnListField.class.getName(), "values", "arya"))); } + /** + * @see DATAREDIS-509 + */ + @Test + public void resolveIndexOnPrimitiveArrayField() { + + IndexedOnPrimitiveArrayField source = new IndexedOnPrimitiveArrayField(); + source.values = new int[] { 1, 2, 3 }; + + Set indexes = indexResolver + .resolveIndexesFor(ClassTypeInformation.from(IndexedOnPrimitiveArrayField.class), source); + + assertThat(indexes.size(), is(3)); + assertThat(indexes, + IsCollectionContaining. hasItems( + new SimpleIndexedPropertyValue(IndexedOnPrimitiveArrayField.class.getName(), "values", 1), + new SimpleIndexedPropertyValue(IndexedOnPrimitiveArrayField.class.getName(), "values", 2), + new SimpleIndexedPropertyValue(IndexedOnPrimitiveArrayField.class.getName(), "values", 3))); + } + private IndexedData resolve(String path, Object value) { Set data = indexResolver.resolveIndex(KEYSPACE_PERSON, path, propertyMock, value); @@ -519,6 +540,11 @@ public class PathIndexResolverUnitTests { @Indexed List values; } + static class IndexedOnPrimitiveArrayField { + + @Indexed int[] values; + } + static class IndexedOnMapField { @Indexed Map values;