This repository was archived by the owner on Jan 31, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
main/java/com/algolia/search/saas/places
test/java/com/algolia/search/saas/places Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -127,4 +127,14 @@ protected JSONObject search(@NonNull PlacesQuery params) throws AlgoliaException
127
127
throw new RuntimeException (e ); // should never happen
128
128
}
129
129
}
130
+
131
+ /**
132
+ * Get a place by its objectID.
133
+ * @param objectID the record's identifier.
134
+ * @return the corresponding record.
135
+ * @throws AlgoliaException when the given objectID does not exist.
136
+ */
137
+ public JSONObject getByObjectID (@ NonNull String objectID ) throws AlgoliaException {
138
+ return getRequest ("/1/places/" + objectID , false );
139
+ }
130
140
}
Original file line number Diff line number Diff line change 35
35
import org .mockito .internal .util .reflection .Whitebox ;
36
36
import org .robolectric .util .concurrent .RoboExecutorService ;
37
37
38
+ import static org .junit .Assert .assertEquals ;
38
39
import static org .junit .Assert .assertNotNull ;
39
40
import static org .junit .Assert .assertTrue ;
40
41
import static org .junit .Assert .fail ;
41
42
42
43
@ SuppressLint ("DefaultLocale" )
43
44
public class PlacesClientTest extends RobolectricTestCase {
45
+ public static final String OBJECT_ID_RUE_RIVOLI = "95057362_123324299" ;
44
46
PlacesClient places ;
45
47
46
48
@ Override
@@ -80,4 +82,16 @@ public void searchAsync() throws Exception {
80
82
}
81
83
});
82
84
}
85
+
86
+ @ Test
87
+ public void getByObjectIDValid () throws Exception {
88
+ final JSONObject rivoli = places .getByObjectID (OBJECT_ID_RUE_RIVOLI );
89
+ assertNotNull (rivoli );
90
+ assertEquals (OBJECT_ID_RUE_RIVOLI , rivoli .getString ("objectID" ));
91
+ }
92
+
93
+ @ Test (expected = AlgoliaException .class )
94
+ public void getByObjectIDInvalid () throws Exception {
95
+ places .getByObjectID ("4242424242" );
96
+ }
83
97
}
You can’t perform that action at this time.
0 commit comments