Skip to content

Commit 9a08b30

Browse files
author
JW Wesson
committed
add tests
1 parent 2d26653 commit 9a08b30

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed

src/main/java/com/textkernel/tx/TxClient.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import com.textkernel.tx.models.api.dataenrichment.skills.response.LookupSkillCodesResponse;
4646
import com.textkernel.tx.models.api.dataenrichment.skills.response.NormalizeSkillsResponse;
4747
import com.textkernel.tx.models.api.formatter.FormatResumeRequest;
48+
import com.textkernel.tx.models.api.formatter.FormatResumeResponse;
4849
import com.textkernel.tx.models.api.geocoding.*;
4950
import com.textkernel.tx.models.api.indexes.*;
5051
import com.textkernel.tx.models.api.jobdescription.GenerateJobRequest;
@@ -289,6 +290,12 @@ public GetAccountInfoResponse getAccountInfo() throws TxException {
289290
return response.getData();
290291
}
291292

293+
/**
294+
* Format a resume into a standardized template that you provide
295+
* @param request The request body
296+
* @return The API response body
297+
* @throws TxException Thrown when an API error occurs
298+
*/
292299
public FormatResumeResponse formatResume(FormatResumeRequest request) throws TxException {
293300
RequestBody body = createJsonBody(request);
294301
Request apiRequest = new Request.Builder()

src/main/java/com/textkernel/tx/models/api/formatter/FormatResumeRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class FormatResumeRequest {
2121
/**
2222
* A base64-encoded string of the DOCX template document file bytes. This should use the standard 'base64'
2323
* encoding as defined in RFC 4648 Section 4 (not the 'base64url' variant).
24-
* <p>Java users can use {@link java.util.Base64#getEncoder()} and then {@link java.util.Base64.Encoder#encodeToString(byte[])}
24+
* <p>Java users can use {@link java.util.Base64.Encoder#encodeToString(byte[])}
2525
* <p>For more information on creating custom templates, see
2626
* <a href="https://developer.textkernel.com/tx-platform/v10/resume-formatter/creating-custom-templates/">here</a>
2727
*/

src/main/java/com/textkernel/tx/models/api/formatter/FormatResumeResponseValue.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
public class FormatResumeResponseValue {
1414
/**
1515
* The formatted resume document (either PDF or DOCX).
16-
* This is a byte[] as a Base64-encoded string. You can use
17-
* {@link java.util.Base64.Decoder#decode(String)} to get a byte[] to save to disk.
16+
* This is a {@code byte[]} as a Base64-encoded string. You can use
17+
* {@link java.util.Base64.Decoder#decode(String)} to get a {@code byte[]} to save to disk.
1818
*/
1919
public String DocumentAsBase64String;
2020
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright © 2023 Textkernel BV. All rights reserved.
2+
// This file is provided for use by, or on behalf of, Textkernel licensees
3+
// within the terms of their license of Textkernel products or Textkernel customers
4+
// within the Terms of Service pertaining to the Textkernel SaaS products.
5+
6+
package com.textkernel.tx.integration;
7+
8+
import com.textkernel.tx.TestBase;
9+
import com.textkernel.tx.models.api.formatter.FormatResumeRequest;
10+
import com.textkernel.tx.models.api.formatter.FormatResumeResponse;
11+
import com.textkernel.tx.models.api.formatter.OutputDocumentFormat;
12+
import org.junit.jupiter.api.Test;
13+
14+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
15+
import static org.junit.jupiter.api.Assertions.assertNotNull;
16+
17+
public class FormatterTests extends TestBase {
18+
@Test
19+
public void testFormatResume() {
20+
assertDoesNotThrow(() -> {
21+
22+
String templateStr = getTestFileAsDocument("template1.docx").getAsBase64();
23+
byte[] templateBytes = java.util.Base64.getDecoder().decode(templateStr);
24+
25+
FormatResumeRequest request = new FormatResumeRequest(TestParsedResume, templateBytes, OutputDocumentFormat.DOCX);
26+
FormatResumeResponse response = Client.formatResume(request);
27+
28+
assertNotNull(response.Value.DocumentAsBase64String);
29+
});
30+
}
31+
}

src/test/resources/template1.docx

28.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)