-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #481 from beatngu13/feature/refactor
Refactor
- Loading branch information
Showing
11 changed files
with
114 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
set -x | ||
|
||
./mvnw -B gitflow:hotfix-start | ||
./mvnw -B gitflow:hotfix-start -DhotfixBranch="$1" |
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
53 changes: 0 additions & 53 deletions
53
src/test/java/com/github/beatngu13/pdfzoomwizard/TestUtil.java
This file was deleted.
Oops, something went wrong.
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
59 changes: 59 additions & 0 deletions
59
src/test/java/com/github/beatngu13/pdfzoomwizard/core/WizardITUtil.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,59 @@ | ||
package com.github.beatngu13.pdfzoomwizard.core; | ||
|
||
import com.itextpdf.kernel.pdf.PdfDocument; | ||
import com.itextpdf.kernel.pdf.PdfOutline; | ||
import com.itextpdf.kernel.pdf.PdfReader; | ||
import com.itextpdf.kernel.pdf.navigation.PdfDestination; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.UncheckedIOException; | ||
import java.util.List; | ||
import java.util.stream.Stream; | ||
|
||
final class WizardITUtil { | ||
|
||
record Bookmark(String title, String data) { | ||
} | ||
|
||
private WizardITUtil() { | ||
} | ||
|
||
static List<Bookmark> getBookmarks(File pdf) { | ||
return streamOutlines(pdf) | ||
.map(WizardITUtil::toBookmark) | ||
.toList(); | ||
} | ||
|
||
private static Stream<PdfOutline> streamOutlines(File pdf) { | ||
try (PdfDocument doc = new PdfDocument(new PdfReader(pdf))) { | ||
PdfOutline outlines = doc.getOutlines(true); | ||
if (outlines == null) { | ||
return Stream.empty(); | ||
} | ||
return outlines | ||
.getAllChildren() | ||
.stream() | ||
.flatMap(WizardITUtil::streamOutlines); | ||
} catch (IOException e) { | ||
throw new UncheckedIOException(e); | ||
} | ||
} | ||
|
||
private static Stream<PdfOutline> streamOutlines(PdfOutline outline) { | ||
Stream<PdfOutline> allChildren = outline.getAllChildren() | ||
.stream() | ||
.flatMap(WizardITUtil::streamOutlines); | ||
return Stream.concat(Stream.of(outline), allChildren); | ||
} | ||
|
||
private static Bookmark toBookmark(PdfOutline outline) { | ||
String title = outline.getTitle(); | ||
PdfDestination destination = outline.getDestination(); | ||
String data = destination == null | ||
? "No destination" | ||
: destination.getPdfObject().toString(); | ||
return new Bookmark(title, data); | ||
} | ||
|
||
} |
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
7 changes: 6 additions & 1 deletion
7
...zoomwizard/core/WizardIT.WithPdf.zoom_should_be_applied_properly.actual_size.approved.txt
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 |
---|---|---|
@@ -1 +1,6 @@ | ||
[[42 0 R /XYZ 742 null 1 ], [1 0 R /XYZ 731 null 1 ], [3 0 R /XYZ 731 null 1 ], [5 0 R /XYZ 731 null 1 ], [7 0 R /XYZ 731 null 1 ], [11 0 R /XYZ 731 null 1 ]] | ||
Bookmark[title=Working with Bookmarks , data=[42 0 R /XYZ 742 null 1 ]] | ||
Bookmark[title=Creating New Bookmarks , data=[1 0 R /XYZ 731 null 1 ]] | ||
Bookmark[title=Creating a Bookmark Hierarchy , data=[3 0 R /XYZ 731 null 1 ]] | ||
Bookmark[title=Editing Bookmarks , data=[5 0 R /XYZ 731 null 1 ]] | ||
Bookmark[title=Deleting Bookmarks , data=[7 0 R /XYZ 731 null 1 ]] | ||
Bookmark[title=Setting Documents Properties for Bookmarks , data=[11 0 R /XYZ 731 null 1 ]] |
7 changes: 6 additions & 1 deletion
7
...pdfzoomwizard/core/WizardIT.WithPdf.zoom_should_be_applied_properly.fit_page.approved.txt
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 |
---|---|---|
@@ -1 +1,6 @@ | ||
[[42 0 R /Fit ], [1 0 R /Fit ], [3 0 R /Fit ], [5 0 R /Fit ], [7 0 R /Fit ], [11 0 R /Fit ]] | ||
Bookmark[title=Working with Bookmarks , data=[42 0 R /Fit ]] | ||
Bookmark[title=Creating New Bookmarks , data=[1 0 R /Fit ]] | ||
Bookmark[title=Creating a Bookmark Hierarchy , data=[3 0 R /Fit ]] | ||
Bookmark[title=Editing Bookmarks , data=[5 0 R /Fit ]] | ||
Bookmark[title=Deleting Bookmarks , data=[7 0 R /Fit ]] | ||
Bookmark[title=Setting Documents Properties for Bookmarks , data=[11 0 R /Fit ]] |
7 changes: 6 additions & 1 deletion
7
...zoomwizard/core/WizardIT.WithPdf.zoom_should_be_applied_properly.fit_visible.approved.txt
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 |
---|---|---|
@@ -1 +1,6 @@ | ||
[[42 0 R /FitBH 742 ], [1 0 R /FitBH 731 ], [3 0 R /FitBH 731 ], [5 0 R /FitBH 731 ], [7 0 R /FitBH 731 ], [11 0 R /FitBH 731 ]] | ||
Bookmark[title=Working with Bookmarks , data=[42 0 R /FitBH 742 ]] | ||
Bookmark[title=Creating New Bookmarks , data=[1 0 R /FitBH 731 ]] | ||
Bookmark[title=Creating a Bookmark Hierarchy , data=[3 0 R /FitBH 731 ]] | ||
Bookmark[title=Editing Bookmarks , data=[5 0 R /FitBH 731 ]] | ||
Bookmark[title=Deleting Bookmarks , data=[7 0 R /FitBH 731 ]] | ||
Bookmark[title=Setting Documents Properties for Bookmarks , data=[11 0 R /FitBH 731 ]] |
7 changes: 6 additions & 1 deletion
7
...dfzoomwizard/core/WizardIT.WithPdf.zoom_should_be_applied_properly.fit_width.approved.txt
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 |
---|---|---|
@@ -1 +1,6 @@ | ||
[[42 0 R /FitH 742 ], [1 0 R /FitH 731 ], [3 0 R /FitH 731 ], [5 0 R /FitH 731 ], [7 0 R /FitH 731 ], [11 0 R /FitH 731 ]] | ||
Bookmark[title=Working with Bookmarks , data=[42 0 R /FitH 742 ]] | ||
Bookmark[title=Creating New Bookmarks , data=[1 0 R /FitH 731 ]] | ||
Bookmark[title=Creating a Bookmark Hierarchy , data=[3 0 R /FitH 731 ]] | ||
Bookmark[title=Editing Bookmarks , data=[5 0 R /FitH 731 ]] | ||
Bookmark[title=Deleting Bookmarks , data=[7 0 R /FitH 731 ]] | ||
Bookmark[title=Setting Documents Properties for Bookmarks , data=[11 0 R /FitH 731 ]] |
7 changes: 6 additions & 1 deletion
7
...oomwizard/core/WizardIT.WithPdf.zoom_should_be_applied_properly.inherit_zoom.approved.txt
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 |
---|---|---|
@@ -1 +1,6 @@ | ||
[[42 0 R /XYZ 742 null null ], [1 0 R /XYZ 731 null null ], [3 0 R /XYZ 731 null null ], [5 0 R /XYZ 731 null null ], [7 0 R /XYZ 731 null null ], [11 0 R /XYZ 731 null null ]] | ||
Bookmark[title=Working with Bookmarks , data=[42 0 R /XYZ 742 null null ]] | ||
Bookmark[title=Creating New Bookmarks , data=[1 0 R /XYZ 731 null null ]] | ||
Bookmark[title=Creating a Bookmark Hierarchy , data=[3 0 R /XYZ 731 null null ]] | ||
Bookmark[title=Editing Bookmarks , data=[5 0 R /XYZ 731 null null ]] | ||
Bookmark[title=Deleting Bookmarks , data=[7 0 R /XYZ 731 null null ]] | ||
Bookmark[title=Setting Documents Properties for Bookmarks , data=[11 0 R /XYZ 731 null null ]] |