-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Generate table cells when table height calculation is invoked.
- Loading branch information
Showing
3 changed files
with
68 additions
and
4 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
40 changes: 40 additions & 0 deletions
40
src/test/java/com/github/vkuzel/simplepdflayout/TableTest.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,40 @@ | ||
package com.github.vkuzel.simplepdflayout; | ||
|
||
import com.github.vkuzel.simplepdflayout.calculator.CalculationContext; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
import static java.util.Collections.singletonList; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class TableTest { | ||
|
||
private static final Page ANY_PAGE = Page.a4(); | ||
private static final List<List<String>> ANY_DATA = singletonList(singletonList("Test")); | ||
|
||
@Test | ||
void tableCellsShouldBeAlreadyGeneratedWhenHeightCalculationIsInvoked() { | ||
// given | ||
Table table = new Table(ANY_PAGE).setData(ANY_DATA); | ||
|
||
// when | ||
float height = table.calculateHeight(new CalculationContext()); | ||
|
||
// then | ||
assertTrue(height > 0); | ||
} | ||
|
||
@Test | ||
void tableCannotBeModifiedIfCellsAreGenerated() { | ||
// given | ||
Table table = new Table(ANY_PAGE).setData(ANY_DATA); | ||
|
||
// when ... generates cells | ||
table.calculateContentHeight(new CalculationContext()); | ||
|
||
// then | ||
assertThrows(IllegalStateException.class, () -> table.setData(ANY_DATA)); | ||
} | ||
} |