20
20
21
21
package com .arangodb .springframework .repository ;
22
22
23
+ import com .arangodb .model .AqlQueryOptions ;
23
24
import com .arangodb .springframework .AbstractArangoTest ;
24
25
import com .arangodb .springframework .annotation .Document ;
25
26
import org .junit .Test ;
26
27
import org .springframework .beans .factory .annotation .Autowired ;
27
28
import org .springframework .data .annotation .Id ;
28
29
30
+ import java .util .List ;
31
+ import java .util .Optional ;
32
+
29
33
import static org .assertj .core .api .Assertions .assertThat ;
30
34
31
35
/**
@@ -50,6 +54,19 @@ public void save() {
50
54
assertThat (d3 .country ).isEqualTo ("country1" );
51
55
assertThat (d3 .name ).isEqualTo ("name3" );
52
56
}
57
+
58
+ @ Test
59
+ public void forceOneShardAttributeValue () {
60
+ ShardedUser d = shardedRepository .save (new ShardedUser (null , "foo" , "bar" ));
61
+ Optional <ShardedUser > res = shardedRepository .findByName ("foo" , new AqlQueryOptions ()
62
+ .forceOneShardAttributeValue ("bar" )
63
+ ).stream ().findFirst ();
64
+ assertThat (res ).isPresent ();
65
+ assertThat (res .get ().key ).isEqualTo (d .key );
66
+ assertThat (res .get ().name ).isEqualTo (d .name );
67
+ assertThat (res .get ().country ).isEqualTo (d .country );
68
+ }
69
+
53
70
}
54
71
55
72
@ Document (shardKeys = "country" , numberOfShards = 10 )
@@ -68,4 +85,5 @@ public ShardedUser(String key, String name, String country) {
68
85
}
69
86
70
87
interface ShardedRepository extends ArangoRepository <ShardedUser , String > {
88
+ List <ShardedUser > findByName (String name , AqlQueryOptions options );
71
89
}
0 commit comments