Skip to content

Commit

Permalink
Merge pull request #441 from softwaremagico/439-pdf-tables-must-be-mo…
Browse files Browse the repository at this point in the history
…re-readable

Changed table border color
  • Loading branch information
softwaremagico committed May 18, 2024
2 parents dfbaa2c + cc5be61 commit 4c98ad0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public PdfPCell getCell(String text, int border, int colspan, int align, Color c
final PdfPCell cell = new PdfPCell(p);
cell.setColspan(colspan);
cell.setBorderWidth(border);
cell.setBorderColor(Color.LIGHT_GRAY);
cell.setHorizontalAlignment(align);
cell.setBackgroundColor(color);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
Expand All @@ -30,25 +30,34 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.Locale;

@SpringBootTest
@Test(groups = {"scoreListPdf"})
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class ListTests extends BasicDataTest {
private static final String PDF_PATH_OUTPUT = System.getProperty("java.io.tmpdir") + File.separator;
private static final String PDF_PATH_OUTPUT = System.getProperty("java.io.tmpdir") + File.separator + "PdfTests" + File.separator;

@Autowired
private PdfController pdfController;

@Autowired
private RankingController rankingController;

@BeforeClass
public void prepareFolder() throws IOException {
Files.createDirectories(Paths.get(PDF_PATH_OUTPUT));
}

@BeforeClass
public void prepareData() {
populateData();
Expand Down Expand Up @@ -92,4 +101,9 @@ public void generateFightSummaryPdf() {
Assert.assertEquals(pdfController.generateFightsSummaryList(Locale.getDefault(), tournament)
.createFile(PDF_PATH_OUTPUT + "FightSummaryList.pdf"), 2); // No clue why are 2 pages and not 1.
}

@AfterClass
public void removeFolder() {
Assert.assertTrue(deleteDirectory(new File(PDF_PATH_OUTPUT)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -186,4 +187,14 @@ protected void populateData() {
group = createGroup(tournament, teams);
fights = createFights(tournament, teams, group);
}

protected boolean deleteDirectory(File directoryToBeDeleted) {
File[] allContents = directoryToBeDeleted.listFiles();
if (allContents != null) {
for (File file : allContents) {
deleteDirectory(file);
}
}
return directoryToBeDeleted.delete();
}
}

0 comments on commit 4c98ad0

Please sign in to comment.