generated from codeforamerica/form-flow-starter-app
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into jefferson-experiment
- Loading branch information
Showing
5 changed files
with
81 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/test/java/org/ladocuploader/app/utils/SubmissionUtilitiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.ladocuploader.app.utils; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import formflow.library.data.Submission; | ||
import formflow.library.data.UserFile; | ||
import java.time.OffsetDateTime; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
import org.junit.jupiter.api.Test; | ||
import org.ladocuploader.app.testutils.TestUtils; | ||
|
||
class SubmissionUtilitiesTest { | ||
|
||
@Test | ||
public void testFileNameGeneration() { | ||
// Mock objects | ||
Submission submission = new Submission(); | ||
UserFile userFile = new UserFile(); | ||
UUID uuid = UUID.randomUUID(); | ||
userFile.setFileId(uuid); | ||
userFile.setOriginalName("foo.pdf"); | ||
userFile.setDocTypeLabel("test"); | ||
submission.setInputData(Map.of("documentOwner_wildcard_" + uuid, "John Doe")); | ||
submission.setSubmittedAt(TestUtils.makeOffsetDateTime("2024-04-18")); | ||
|
||
int currentFileCount = 1; | ||
int totalFiles = 3; | ||
|
||
// Expected output | ||
|
||
// Call the method to generate the file name | ||
String generatedFileName = SubmissionUtilities.createFileNameForUploadedDocument(submission, userFile, currentFileCount, totalFiles); | ||
|
||
// Assert the output matches the expected result | ||
assertThat(generatedFileName).isEqualTo("John_Doe_test_1_of_3_041820240300.pdf"); | ||
} | ||
} |