Skip to content

Commit 88eb770

Browse files
committed
fixed deserialization of multiple documents to user data
1 parent f3edee2 commit 88eb770

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ workflows:
551551
only:
552552
- main
553553
- test:
554-
name: test-native-ssl=<<matrix.ssl>>
554+
name: test-native-ssl=<<matrix.ssl>>-(<<graalvm-version>>)
555555
matrix:
556556
parameters:
557557
native:
@@ -571,7 +571,7 @@ workflows:
571571
only:
572572
- main
573573
- test-shaded:
574-
name: test-native-shaded-ssl=<<matrix.ssl>>
574+
name: test-native-shaded-ssl=<<matrix.ssl>>-(<<graalvm-version>>)
575575
matrix:
576576
parameters:
577577
native:

core/src/main/java/com/arangodb/internal/serde/InternalSerdeImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,13 @@ public <T> T deserializeUserData(byte[] content, Class<T> clazz) {
167167
}
168168

169169
@Override
170+
@SuppressWarnings("unchecked")
170171
public <T> T deserializeUserData(byte[] content, JavaType clazz) {
171172
try {
172173
if (SerdeUtils.isManagedClass(clazz.getRawClass())) {
173174
return mapper.readerFor(clazz).readValue(content);
174175
} else {
175-
return deserializeUserData(content, clazz);
176+
return deserializeUserData(content, (Class<? extends T>) clazz.getRawClass());
176177
}
177178
} catch (IOException e) {
178179
throw ArangoDBException.of(e);

test-functional/src/test/java/com/arangodb/ArangoCollectionTest.java

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,34 @@ void getDocuments(ArangoCollection collection) {
754754
}
755755
}
756756

757+
@ParameterizedTest
758+
@MethodSource("cols")
759+
void getDocumentsUserData(ArangoCollection collection) {
760+
Cat a = new Cat();
761+
a.setKey(UUID.randomUUID().toString());
762+
a.setName("a");
763+
764+
Cat b = new Cat();
765+
b.setKey(UUID.randomUUID().toString());
766+
b.setName("b");
767+
768+
final List<Cat> values = Arrays.asList(a, b);
769+
collection.insertDocuments(values);
770+
final MultiDocumentEntity<Cat> documents = collection.getDocuments(Arrays.asList(a.getKey(), b.getKey()),
771+
Cat.class);
772+
assertThat(documents).isNotNull();
773+
assertThat(documents.getDocuments())
774+
.hasSize(2)
775+
.anySatisfy(d -> {
776+
assertThat(d.getKey()).isEqualTo(a.getKey());
777+
assertThat(d.getName()).isEqualTo(a.getName());
778+
})
779+
.anySatisfy(d -> {
780+
assertThat(d.getKey()).isEqualTo(b.getKey());
781+
assertThat(d.getName()).isEqualTo(b.getName());
782+
});
783+
}
784+
757785
@ParameterizedTest
758786
@MethodSource("cols")
759787
void getDocumentsWithCustomShardingKey(ArangoCollection c) {
@@ -2413,6 +2441,33 @@ void insertDocuments(ArangoCollection collection) {
24132441
assertThat(docs.getErrors()).isEmpty();
24142442
}
24152443

2444+
@ParameterizedTest
2445+
@MethodSource("cols")
2446+
void insertDocumentsReturnNewUserData(ArangoCollection collection) {
2447+
Cat a = new Cat();
2448+
a.setKey(UUID.randomUUID().toString());
2449+
a.setName("a");
2450+
2451+
Cat b = new Cat();
2452+
b.setKey(UUID.randomUUID().toString());
2453+
b.setName("b");
2454+
2455+
final List<Cat> values = Arrays.asList(a, b);
2456+
MultiDocumentEntity<DocumentCreateEntity<Cat>> res =
2457+
collection.insertDocuments(values, new DocumentCreateOptions().returnNew(true), Cat.class);
2458+
assertThat(res).isNotNull();
2459+
assertThat(res.getDocuments())
2460+
.hasSize(2)
2461+
.anySatisfy(d -> {
2462+
assertThat(d.getKey()).isEqualTo(a.getKey());
2463+
assertThat(d.getNew().getName()).isEqualTo(a.getName());
2464+
})
2465+
.anySatisfy(d -> {
2466+
assertThat(d.getKey()).isEqualTo(b.getKey());
2467+
assertThat(d.getNew().getName()).isEqualTo(b.getName());
2468+
});
2469+
}
2470+
24162471
@ParameterizedTest
24172472
@MethodSource("cols")
24182473
void insertDocumentsOverwriteModeUpdate(ArangoCollection collection) {

0 commit comments

Comments
 (0)