File tree Expand file tree Collapse file tree
main/java/com/basho/riak/client/api/commands/search
test/java/com/basho/riak/client/api/commands/search Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import com .basho .riak .client .api .AsIsRiakCommand ;
44import com .basho .riak .client .core .operations .YzPutIndexOperation ;
55import com .basho .riak .client .core .query .search .YokozunaIndex ;
6+ import java .util .Objects ;
67
78/**
89 * Command used to store a search index in Riak.
@@ -36,6 +37,24 @@ protected YzPutIndexOperation buildCoreOperation()
3637 return opBuilder .build ();
3738 }
3839
40+ @ Override
41+ public boolean equals (Object other ) {
42+ if (this == other ) {
43+ return true ;
44+ }
45+ if (!(other instanceof StoreIndex )) {
46+ return false ;
47+ }
48+ Builder otherStoreIndex = ((StoreIndex ) other ).cmdBuilder ;
49+ return Objects .equals (cmdBuilder .index , otherStoreIndex .index )
50+ && Objects .equals (cmdBuilder .timeout , otherStoreIndex .timeout );
51+ }
52+
53+ @ Override
54+ public int hashCode () {
55+ return Objects .hash (cmdBuilder .index , cmdBuilder .timeout );
56+ }
57+
3958 /**
4059 * Builder for a StoreIndex command.
4160 */
Original file line number Diff line number Diff line change 1+ package com .basho .riak .client .api .commands .search ;
2+
3+ import com .basho .riak .client .core .query .search .YokozunaIndex ;
4+ import org .junit .Test ;
5+ import static org .hamcrest .CoreMatchers .equalTo ;
6+ import static org .hamcrest .CoreMatchers .is ;
7+ import static org .hamcrest .CoreMatchers .not ;
8+ import static org .hamcrest .MatcherAssert .assertThat ;
9+
10+ public class StoreIndexTest {
11+ @ Test
12+ public void equalsReturnsTrueForEqualIndexAndTimeout () {
13+ YokozunaIndex index1 = new YokozunaIndex ("index" );
14+ YokozunaIndex index2 = new YokozunaIndex ("index" );
15+
16+ StoreIndex storeIndex1 = new StoreIndex .Builder (index1 ).withTimeout (5 ).build ();
17+ StoreIndex storeIndex2 = new StoreIndex .Builder (index2 ).withTimeout (5 ).build ();
18+
19+ assertThat (storeIndex1 , is (equalTo (storeIndex2 )));
20+ assertThat (storeIndex2 , is (equalTo (storeIndex1 )));
21+ }
22+
23+ @ Test
24+ public void equalsReturnsFalseForDifferentIndexAndTimeout () {
25+ YokozunaIndex index1 = new YokozunaIndex ("index1" );
26+ YokozunaIndex index2 = new YokozunaIndex ("index2" );
27+
28+ StoreIndex storeIndex1 = new StoreIndex .Builder (index1 ).withTimeout (5 ).build ();
29+ StoreIndex storeIndex2 = new StoreIndex .Builder (index2 ).withTimeout (8 ).build ();
30+
31+ assertThat (storeIndex1 , is (not (equalTo (storeIndex2 ))));
32+ assertThat (storeIndex2 , is (not (equalTo (storeIndex1 ))));
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments