-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Odd-Even Merge operation mode #1445
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2afff66
Add ODD_EVEN_MERGE sort type
Skillkiller 4d621f8
Add process method to merge odd and even PDF pages
Skillkiller 574abb9
Add test cases for Odd-Even merge method
Skillkiller 1d05e6b
Add Odd-Even Merge mode in PDF Organizer webpage
Skillkiller 263b491
Add ODD_EVEN_MERGE documentation to RearrangePagesRequest
Skillkiller ef66aef
Add english translation for pdfOrganiser.mode.10
Skillkiller 921fd97
Merge branch 'main' into odd-even-merge
Frooodle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
82 changes: 82 additions & 0 deletions
82
src/test/java/stirling/software/SPDF/controller/api/RearrangePagesPDFControllerTest.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,82 @@ | ||
package stirling.software.SPDF.controller.api; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvSource; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class RearrangePagesPDFControllerTest { | ||
|
||
/** | ||
* Tests the behavior of the oddEvenMerge method when there are no pages in the document. | ||
*/ | ||
@Test | ||
void oddEvenMerge_noPages() { | ||
RearrangePagesPDFController sut = new RearrangePagesPDFController(); | ||
int totalNumberOfPages = 0; | ||
|
||
List<Integer> newPageOrder = sut.oddEvenMerge(totalNumberOfPages); | ||
|
||
assertNotNull(newPageOrder, "Returning null instead of page order list"); | ||
assertEquals(List.of(), newPageOrder, "Page order doesn't match"); | ||
} | ||
|
||
/** | ||
* Tests the behavior of the oddEvenMerge method when there are odd total pages in the document. | ||
*/ | ||
@Test | ||
void oddEvenMerge_oddTotalPageNumber() { | ||
RearrangePagesPDFController sut = new RearrangePagesPDFController(); | ||
int totalNumberOfPages = 5; | ||
|
||
List<Integer> newPageOrder = sut.oddEvenMerge(totalNumberOfPages); | ||
|
||
assertNotNull(newPageOrder, "Returning null instead of page order list"); | ||
assertEquals(Arrays.asList(0,3,1,4,2), newPageOrder, "Page order doesn't match"); | ||
} | ||
|
||
/** | ||
* Tests the behavior of the oddEvenMerge method when there are even total pages in the document. | ||
*/ | ||
@Test | ||
void oddEvenMerge_evenTotalPageNumber() { | ||
RearrangePagesPDFController sut = new RearrangePagesPDFController(); | ||
int totalNumberOfPages = 6; | ||
|
||
List<Integer> newPageOrder = sut.oddEvenMerge(totalNumberOfPages); | ||
|
||
assertNotNull(newPageOrder, "Returning null instead of page order list"); | ||
assertEquals(Arrays.asList(0,3,1,4,2,5), newPageOrder, "Page order doesn't match"); | ||
} | ||
|
||
/** | ||
* Tests the behavior of the oddEvenMerge method with multiple test cases of multiple pages. | ||
* @param totalNumberOfPages The total number of pages in the document. | ||
* @param expectedPageOrder The expected order of the pages after rearranging. | ||
*/ | ||
@ParameterizedTest | ||
@CsvSource({ | ||
"1, '0'", | ||
"2, '0,1'", | ||
"3, '0,2,1'", | ||
"4, '0,2,1,3'", | ||
"5, '0,3,1,4,2'", | ||
"6, '0,3,1,4,2,5'", | ||
"10, '0,5,1,6,2,7,3,8,4,9'", | ||
"50, '0,25,1,26,2,27,3,28,4,29,5,30,6,31,7,32,8,33,9,34,10,35," + | ||
"11,36,12,37,13,38,14,39,15,40,16,41,17,42,18,43,19,44,20,45,21,46," + | ||
"22,47,23,48,24,49'" | ||
}) | ||
void oddEvenMerge_multi_test(int totalNumberOfPages, String expectedPageOrder) { | ||
RearrangePagesPDFController sut = new RearrangePagesPDFController(); | ||
|
||
List<Integer> newPageOrder = sut.oddEvenMerge(totalNumberOfPages); | ||
|
||
assertNotNull(newPageOrder, "Returning null instead of page order list"); | ||
assertEquals(Arrays.stream(expectedPageOrder.split(",")).map(Integer::parseInt).toList(), newPageOrder, "Page order doesn't match"); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add to GB file not US for the base
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added also to the
messages_en_GB.properties