Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
strategy:
matrix:
java-version:
- "25"
- "21"
- "17"
- "11"
- "8"
distribution:
- "temurin"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_publish-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: "8"
java-version: "11"
distribution: "adopt"
server-id: central
server-username: MAVEN_USERNAME
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/_test-code-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
java-version:
- "25"
- "11"
- "8"
distribution:
- "temurin"

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ jobs:
strategy:
matrix:
java-version:
- "21"
- "25"
- "11"
- "8"
distribution:
- "temurin"

Expand Down
48 changes: 16 additions & 32 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
<version>${org.projectlombok.lombok-mapstruct-binding.version}</version>
</path>
</annotationProcessorPaths>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
Expand All @@ -102,7 +102,7 @@
<linkXRef>false</linkXRef>
<printFailingErrors>true</printFailingErrors>
<failurePriority>3</failurePriority>
<targetJdk>1.8</targetJdk>
<targetJdk>11</targetJdk>
</configuration>
</plugin>
<plugin>
Expand All @@ -129,8 +129,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -290,8 +290,8 @@
</dependency>
<dependency>
<artifactId>jackson-databind</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
<version>${com.fasterxml.jackson.version}</version>
<groupId>tools.jackson.core</groupId>
<version>${tools.jackson.core.databind.version}</version>
</dependency>
<dependency>
<artifactId>jackson-datatype-jsr310</artifactId>
Expand Down Expand Up @@ -366,21 +366,8 @@
<artifactId>junit-pioneer</artifactId>
<groupId>org.junit-pioneer</groupId>
<scope>test</scope>
<!-- version 2.0 is not compatible with java 8 -->
<version>${org.junit.pioneer.version}</version>
</dependency>
<dependency>
<artifactId>mockito-junit-jupiter</artifactId>
<groupId>org.mockito</groupId>
<scope>test</scope>
<version>${org.mockito.junit.jupiter.version}</version>
</dependency>
<dependency>
<artifactId>mockito-inline</artifactId>
<groupId>org.mockito</groupId>
<scope>test</scope>
<version>${org.mockito.inline.version}</version>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
Expand All @@ -394,8 +381,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<version>${wiremock.version}</version>
<scope>test</scope>
</dependency>
Expand All @@ -418,18 +405,18 @@
<!-- MINDEE VERSION GOES HERE -->
<revision>5.0.0-alpha1</revision>

<com.fasterxml.jackson.version>2.15.4</com.fasterxml.jackson.version>
<com.fasterxml.jackson.datatype.version>2.15.4</com.fasterxml.jackson.datatype.version>
<tools.jackson.core.databind.version>3.1.1</tools.jackson.core.databind.version>
<com.fasterxml.jackson.datatype.version>2.21.2</com.fasterxml.jackson.datatype.version>
<com.squareup.okhttp3.version>4.12.0</com.squareup.okhttp3.version>
<info.picocli.version>4.7.6</info.picocli.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<org.apache.commons.math3.version>3.6.1</org.apache.commons.math3.version>
<org.apache.httpcomponents.client5.httpclient5.version>5.4.4</org.apache.httpcomponents.client5.httpclient5.version>
<commons-codec.version>1.20.0</commons-codec.version>
<org.apache.maven.clean.version>3.1.0</org.apache.maven.clean.version>
<org.apache.maven.compiler.version>3.12.1</org.apache.maven.compiler.version>
<org.apache.maven.failsafe.version>3.3.1</org.apache.maven.failsafe.version>
<org.apache.maven.failsafe.version>3.5.5</org.apache.maven.failsafe.version>
<org.apache.maven.gpg.version>1.5</org.apache.maven.gpg.version>
<org.apache.maven.install.version>2.5.2</org.apache.maven.install.version>
<org.apache.maven.javadoc.version>3.2.0</org.apache.maven.javadoc.version>
Expand All @@ -441,17 +428,14 @@
<org.apache.pdfbox.version>3.0.5</org.apache.pdfbox.version>
<org.junit.jupiter.version>5.8.2</org.junit.jupiter.version>
<org.junit.pioneer.version>1.9.1</org.junit.pioneer.version>
<org.junit.platform.version>1.8.2</org.junit.platform.version>
<org.junit.platform.version>1.9.2</org.junit.platform.version>
<org.hamcrest.version>2.2</org.hamcrest.version>
<org.mapstruct.version>1.5.3.Final</org.mapstruct.version>
<org.mockito.inline.version>4.11.0</org.mockito.inline.version>
<org.mockito.junit.jupiter.version>4.11.0</org.mockito.junit.jupiter.version>
<org.projectlombok.lombok-mapstruct-binding.version>0.2.0</org.projectlombok.lombok-mapstruct-binding.version>
<org.projectlombok.version>1.18.38</org.projectlombok.version>
<org.slf4j.version>2.0.17</org.slf4j.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<surefire.addOpens></surefire.addOpens>
<wiremock.version>2.35.2</wiremock.version>
<wiremock.version>3.13.2</wiremock.version>
</properties>

</project>
3 changes: 3 additions & 0 deletions src/main/java/com/mindee/v1/http/MindeeApiV1.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public abstract <DocT extends Inference> PredictResponse<DocT> predictPost(
RequestParameters requestParameters
) throws IOException;

/**
* Execute a workflow.
*/
public abstract <DocT extends Inference> WorkflowResponse<DocT> executeWorkflowPost(
Class<DocT> documentClass,
String workflowId,
Expand Down
48 changes: 0 additions & 48 deletions src/main/java/com/mindee/v2/MindeeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.mindee.v2.parsing.ErrorResponse;
import com.mindee.v2.parsing.JobResponse;
import com.mindee.v2.product.extraction.ExtractionResponse;
import com.mindee.v2.product.extraction.params.ExtractionParameters;
import java.io.IOException;

/**
Expand All @@ -34,26 +33,6 @@ public MindeeClient(MindeeApiV2 mindeeApi) {
this.mindeeApi = mindeeApi;
}

/**
* @deprecated use `enqueue` instead.
*/
public JobResponse enqueueInference(
LocalInputSource inputSource,
ExtractionParameters params
) throws IOException {
return enqueue(inputSource, params);
}

/**
* @deprecated use `enqueue` instead.
*/
public JobResponse enqueueInference(
URLInputSource inputSource,
ExtractionParameters params
) throws IOException {
return enqueue(inputSource, params);
}

/**
* Enqueue a document in the asynchronous queue.
*
Expand Down Expand Up @@ -88,13 +67,6 @@ public JobResponse getJob(String jobId) {
return mindeeApi.reqGetJob(jobId);
}

/**
* @deprecated use `getResult` instead.
*/
public ExtractionResponse getInference(String inferenceId) {
return getResult(ExtractionResponse.class, inferenceId);
}

/**
* Get the result of an inference that was previously enqueued.
* The inference will only be available after it has finished processing.
Expand All @@ -109,26 +81,6 @@ public <TResponse extends CommonResponse> TResponse getResult(
return mindeeApi.reqGetResult(responseClass, inferenceId);
}

/**
* @deprecated use `enqueueAndGetResult` instead.
*/
public ExtractionResponse enqueueAndGetInference(
LocalInputSource inputSource,
ExtractionParameters options
) throws IOException, InterruptedException {
return enqueueAndGetResult(ExtractionResponse.class, inputSource, options);
}

/**
* @deprecated use `enqueueAndGetResult` instead.
*/
public ExtractionResponse enqueueAndGetInference(
URLInputSource inputSource,
ExtractionParameters options
) throws IOException, InterruptedException {
return enqueueAndGetResult(ExtractionResponse.class, inputSource, options);
}

/**
* Send a local file to an async queue, poll, and parse when complete.
*
Expand Down
5 changes: 0 additions & 5 deletions src/test/java/com/mindee/TestingUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ public static String getV1ResourcePathString(String filePath) {
return getV1ResourcePath(filePath).toString();
}

public static String readFileAsString(Path path) throws IOException {
byte[] encoded = Files.readAllBytes(path);
return new String(encoded);
}

public static void assertStringEqualsFile(String expected, String filePath) throws IOException {
String[] actualLines = expected.split(System.lineSeparator());
List<String> expectedLines = Files.readAllLines(Paths.get(filePath));
Expand Down
62 changes: 45 additions & 17 deletions src/test/java/com/mindee/input/URLInputSourceTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.mindee.input;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

import java.io.File;
import java.io.IOException;
Expand All @@ -11,6 +10,7 @@
import java.nio.file.Paths;
import lombok.Setter;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.Test;

public class URLInputSourceTest {

Expand All @@ -31,7 +31,7 @@ public void tearDown() {
void fetchFile_shouldSaveFileLocally() throws IOException {
urlInputSource.fetchFile();

File savedFile = new File(urlInputSource.getLocalFilename());
var savedFile = new File(urlInputSource.getLocalFilename());
assertTrue(savedFile.exists(), "The file should be saved locally");

Files.deleteIfExists(savedFile.toPath());
Expand All @@ -47,7 +47,7 @@ void fetchFile_shouldThrowIOException_onFailedFetch() {

@Test
void fetchFile_shouldHandleRedirects() throws IOException {
urlInputSource.setMockResponseCode(HttpURLConnection.HTTP_MOVED_TEMP);
urlInputSource.setMockResponseCode(HttpURLConnection.HTTP_OK);
urlInputSource.setMockRedirectUrl("https://example.com/redirectedfile.pdf");

urlInputSource.setMockResponseCode(HttpURLConnection.HTTP_OK);
Expand Down Expand Up @@ -84,7 +84,7 @@ void toLocalInputSource_shouldCreateLocalInputSource() throws IOException {
urlInputSource.cleanup();
}

class TestableURLInputSource extends URLInputSource {
static class TestableURLInputSource extends URLInputSource {

@Setter
private int mockResponseCode = HttpURLConnection.HTTP_OK;
Expand All @@ -98,23 +98,51 @@ public TestableURLInputSource(String url) {

@Override
protected HttpURLConnection createConnection(String urlString) throws IOException {
HttpURLConnection mockConnection = mock(HttpURLConnection.class);

when(mockConnection.getResponseCode()).thenReturn(mockResponseCode);
java.net.URL url = new java.net.URL(urlString);
boolean wasRedirected = isRedirected;

Path path = Paths.get("src/test/resources/file_types/pdf/multipage.pdf");
if (isRedirected) {
when(mockConnection.getHeaderField("Location")).thenReturn(null);
when(mockConnection.getInputStream()).thenReturn(Files.newInputStream(path));
} else {
when(mockConnection.getHeaderField("Location")).thenReturn(mockRedirectUrl);
when(mockConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_MOVED_TEMP);
if (!isRedirected && mockRedirectUrl != null) {
isRedirected = true;
return mockConnection;
}

when(mockConnection.getInputStream()).thenReturn(Files.newInputStream(path));
return mockConnection;
return new HttpURLConnection(url) {
@Override
public void disconnect() {
}

@Override
public boolean usingProxy() {
return false;
}

@Override
public void connect() {
}

@Override
public int getResponseCode() {
if (mockRedirectUrl != null && !wasRedirected) {
return HttpURLConnection.HTTP_MOVED_TEMP;
}
return mockResponseCode;
}

@Override
public String getHeaderField(String name) {
if ("Location".equalsIgnoreCase(name)) {
if (mockRedirectUrl != null && !wasRedirected) {
return mockRedirectUrl;
}
}
return null;
}

@Override
public java.io.InputStream getInputStream() throws IOException {
Path path = Paths.get("src/test/resources/file_types/pdf/multipage.pdf");
return Files.newInputStream(path);
}
};
}
}
}
Loading
Loading