DATAREDIS-955 - Polishing.
Eliminate warnings. Formatting. Remove test without assertions. Original pull request: #452.
This commit is contained in:
@@ -786,7 +786,7 @@ public class MappingRedisConverterUnitTests {
|
||||
public void writesDateValuesCorrectly() {
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(1978, 10, 25);
|
||||
cal.set(1978, Calendar.NOVEMBER, 25);
|
||||
|
||||
rand.birthdate = cal.getTime();
|
||||
|
||||
@@ -797,7 +797,7 @@ public class MappingRedisConverterUnitTests {
|
||||
public void readsDateValuesCorrectly() {
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(1978, 10, 25);
|
||||
cal.set(1978, Calendar.NOVEMBER, 25);
|
||||
|
||||
Date date = cal.getTime();
|
||||
|
||||
@@ -1258,24 +1258,6 @@ public class MappingRedisConverterUnitTests {
|
||||
assertThat(target.species.get(0).name, is("trolloc"));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-492
|
||||
public void writeHandlesArraysProperly() {
|
||||
|
||||
this.converter = new MappingRedisConverter(null, null, resolverMock);
|
||||
this.converter
|
||||
.setCustomConversions(new RedisCustomConversions(Collections.singletonList(new ListToByteConverter())));
|
||||
this.converter.afterPropertiesSet();
|
||||
|
||||
Map<String, Object> innerMap = new LinkedHashMap<>();
|
||||
innerMap.put("address", "tyrionl@netflix.com");
|
||||
innerMap.put("when", new String[] { "pipeline.failed" });
|
||||
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("email", Collections.singletonList(innerMap));
|
||||
|
||||
RedisData target = write(map);
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-492
|
||||
public void writeHandlesArraysOfSimpleTypeProperly() {
|
||||
|
||||
@@ -1411,7 +1393,7 @@ public class MappingRedisConverterUnitTests {
|
||||
|
||||
TypeWithObjectValueTypes sample = new TypeWithObjectValueTypes();
|
||||
sample.map.put("string", "bar");
|
||||
sample.map.put("long", new Long(1L));
|
||||
sample.map.put("long", 1L);
|
||||
sample.map.put("date", new Date());
|
||||
|
||||
Bucket bucket = write(sample).getBucket();
|
||||
@@ -1428,7 +1410,7 @@ public class MappingRedisConverterUnitTests {
|
||||
|
||||
TypeWithObjectValueTypes sample = new TypeWithObjectValueTypes();
|
||||
sample.map.put("string", "bar");
|
||||
sample.map.put("long", new Long(1L));
|
||||
sample.map.put("long", 1L);
|
||||
sample.map.put("date", new Date());
|
||||
|
||||
RedisData rd = write(sample);
|
||||
@@ -1444,7 +1426,7 @@ public class MappingRedisConverterUnitTests {
|
||||
|
||||
TypeWithObjectValueTypes sample = new TypeWithObjectValueTypes();
|
||||
sample.list.add("string");
|
||||
sample.list.add(new Long(1L));
|
||||
sample.list.add(1L);
|
||||
sample.list.add(new Date());
|
||||
|
||||
Bucket bucket = write(sample).getBucket();
|
||||
@@ -1461,7 +1443,7 @@ public class MappingRedisConverterUnitTests {
|
||||
|
||||
TypeWithObjectValueTypes sample = new TypeWithObjectValueTypes();
|
||||
sample.list.add("string");
|
||||
sample.list.add(new Long(1L));
|
||||
sample.list.add(1L);
|
||||
sample.list.add(new Date());
|
||||
|
||||
RedisData rd = write(sample);
|
||||
@@ -1873,6 +1855,7 @@ public class MappingRedisConverterUnitTests {
|
||||
source.put("values.[1]", "o-2");
|
||||
|
||||
Outer outer = read(Outer.class, source);
|
||||
|
||||
assertThat(outer.values, is(equalTo(Arrays.asList("o-1", "o-2"))));
|
||||
assertThat(outer.inners.get(0).values, is(equalTo(Arrays.asList("i-1", "i-2"))));
|
||||
}
|
||||
@@ -1885,6 +1868,7 @@ public class MappingRedisConverterUnitTests {
|
||||
source.put("inners.[0].values.[1]", "i-2");
|
||||
|
||||
Outer outer = read(Outer.class, source);
|
||||
|
||||
assertThat(outer.values, is(nullValue()));
|
||||
assertThat(outer.inners.get(0).values, is(equalTo(Arrays.asList("i-1", "i-2"))));
|
||||
}
|
||||
@@ -1943,34 +1927,6 @@ public class MappingRedisConverterUnitTests {
|
||||
}
|
||||
}
|
||||
|
||||
@WritingConverter
|
||||
static class ListToByteConverter implements Converter<List, byte[]> {
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
private final Jackson2JsonRedisSerializer<List> serializer;
|
||||
|
||||
ListToByteConverter() {
|
||||
|
||||
mapper = new ObjectMapper();
|
||||
mapper.setVisibility(mapper.getSerializationConfig().getDefaultVisibilityChecker()
|
||||
.withFieldVisibility(Visibility.ANY).withGetterVisibility(Visibility.NONE)
|
||||
.withSetterVisibility(Visibility.NONE).withCreatorVisibility(Visibility.NONE));
|
||||
|
||||
serializer = new Jackson2JsonRedisSerializer<>(List.class);
|
||||
serializer.setObjectMapper(mapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] convert(List source) {
|
||||
|
||||
if (source == null || source.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return serializer.serialize(source);
|
||||
}
|
||||
}
|
||||
|
||||
@ReadingConverter
|
||||
static class MapToSpeciesConverter implements Converter<Map<String, byte[]>, Species> {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user