Skip to content

Commit b914339

Browse files
authored
Merge pull request #25 from RestComm/feat/bs-131
New naming convention for query methods in RestEndpoints
2 parents 9cbb727 + 217a68f commit b914339

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/main/java/org/restcomm/sdk/endpoints/RestEndpoints.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
/**
99
* @author [email protected] (Oleg Agafonov)
10+
* @author [email protected] (Henrique Rosa)
1011
*/
1112
public class RestEndpoints<T> extends Endpoints {
1213

@@ -18,31 +19,31 @@ public RestEndpoints(String url, HttpClient httpClient, Class<T> type) {
1819
}
1920

2021
public List<T> getAll() {
21-
return getAll(null);
22+
return find(null);
2223
}
2324

24-
public List<T> getAll(Object query) {
25-
return httpClient.get(url, query, TypeFactory
26-
.defaultInstance().constructCollectionType(List.class, type));
25+
public T get(String id) {
26+
return httpClient.get(url + "/" + id, type);
2727
}
2828

29-
public T get(Object query) {
29+
public List<T> find(Object query) {
30+
return httpClient.get(url, query, TypeFactory.defaultInstance().constructCollectionType(List.class, type));
31+
}
32+
33+
public T findOne(Object query) {
3034
return httpClient.get(url, query, TypeFactory.defaultInstance().constructType(type));
3135
}
3236

3337
public T create(T entity) {
3438
return httpClient.post(url, entity, type);
3539
}
3640

37-
public T get(String id) {
38-
return httpClient.get(url + "/" + id, type);
39-
}
40-
4141
public T update(T entity) {
4242
return httpClient.put(url, entity, type);
4343
}
4444

4545
public void delete(String id) {
4646
httpClient.delete(url + "/" + id, type);
4747
}
48+
4849
}

src/test/java/org/restcomm/sdk/endpoints/CallsEndpointTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void testGetCallPage() throws IOException {
4444
.willReturn(okJson(response)));
4545

4646
// when
47-
final CallPage callPage = callsEndpoint.get(Collections.emptyMap());
47+
final CallPage callPage = callsEndpoint.findOne(Collections.emptyMap());
4848

4949
// then
5050
assertNotNull(callPage);

0 commit comments

Comments
 (0)