Skip to content

Commit 90d7752

Browse files
rework function syntaxes
1 parent c4dc4d4 commit 90d7752

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

docs/code_samples/default_v2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class SimpleMindeeClient {
2323
InferenceParameters options = InferenceParameters.builder(modelId).build();
2424

2525
// Parse the file
26-
InferenceResponse response = mindeeClient.enqueueAndParse(
26+
InferenceResponse response = mindeeClient.enqueueAndGetInference(
2727
inputSource,
2828
options
2929
);

src/main/java/com/mindee/MindeeClientV2.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public JobResponse enqueue(
4545
/**
4646
* Poll queue for a previously enqueued document.
4747
*/
48-
public JobResponse pollQueue(String jobId) {
48+
public JobResponse getJob(String jobId) {
4949
if (jobId == null || jobId.trim().isEmpty()) {
5050
throw new IllegalArgumentException("jobId must not be null or blank.");
5151
}
@@ -55,7 +55,7 @@ public JobResponse pollQueue(String jobId) {
5555
/**
5656
* Retrieve results for a previously enqueued document.
5757
*/
58-
public InferenceResponse parseQueued(String inferenceId) {
58+
public InferenceResponse getInference(String inferenceId) {
5959
if (inferenceId == null || inferenceId.trim().isEmpty()) {
6060
throw new IllegalArgumentException("jobId must not be null or blank.");
6161
}
@@ -71,7 +71,7 @@ public InferenceResponse parseQueued(String inferenceId) {
7171
* @throws IOException Throws if the file can't be accessed.
7272
* @throws InterruptedException Throws if the thread is interrupted.
7373
*/
74-
public InferenceResponse enqueueAndParse(
74+
public InferenceResponse enqueueAndGetInference(
7575
LocalInputSource inputSource,
7676
InferenceParameters options) throws IOException, InterruptedException {
7777

@@ -85,12 +85,12 @@ public InferenceResponse enqueueAndParse(
8585
int max = options.getPollingOptions().getMaxRetries();
8686
while (attempts < max) {
8787
Thread.sleep((long) (options.getPollingOptions().getIntervalSec() * 1000));
88-
resp = pollQueue(job.getJob().getId());
88+
resp = getJob(job.getJob().getId());
8989
if (resp.getJob().getStatus().equals("Failed")) {
9090
break;
9191
}
9292
else if (resp.getJob().getStatus().equals("Processed")) {
93-
return parseQueued(resp.getJob().getId());
93+
return getInference(resp.getJob().getId());
9494
}
9595
attempts++;
9696
}

src/test/java/com/mindee/MindeeClientV2IT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void parseFile_emptyMultiPage_mustSucceed() throws IOException, InterruptedExcep
4343
InferenceParameters options =
4444
InferenceParameters.builder(modelId).build();
4545

46-
InferenceResponse response = mindeeClient.enqueueAndParse(source, options);
46+
InferenceResponse response = mindeeClient.enqueueAndGetInference(source, options);
4747

4848
assertNotNull(response);
4949
assertNotNull(response.getInference());
@@ -67,7 +67,7 @@ void parseFile_filledSinglePage_mustSucceed() throws IOException, InterruptedExc
6767
InferenceParameters options =
6868
InferenceParameters.builder(modelId).build();
6969

70-
InferenceResponse response = mindeeClient.enqueueAndParse(source, options);
70+
InferenceResponse response = mindeeClient.enqueueAndGetInference(source, options);
7171

7272
assertNotNull(response);
7373
assertNotNull(response.getInference());
@@ -113,7 +113,7 @@ void invalidModel_mustThrowError() throws IOException {
113113
void invalidJob_mustThrowError() {
114114
MindeeHttpExceptionV2 ex = assertThrows(
115115
MindeeHttpExceptionV2.class,
116-
() -> mindeeClient.parseQueued("not-a-valid-job-ID")
116+
() -> mindeeClient.getInference("not-a-valid-job-ID")
117117
);
118118
assertEquals(404, ex.getStatus());
119119
assertNotNull(ex);

src/test/java/com/mindee/MindeeClientV2Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void document_getQueued_async() throws JsonProcessingException {
7070

7171
MindeeClientV2 mindeeClient = makeClientWithMockedApi(predictable);
7272

73-
CommonResponse response = mindeeClient.pollQueue("dummy-id");
73+
CommonResponse response = mindeeClient.getJob("dummy-id");
7474
assertNotNull(response, "parseQueued() must return a response");
7575
verify(predictable, atMostOnce()).reqGetInference(anyString());
7676
}

0 commit comments

Comments
 (0)