Skip to content

Commit

Permalink
update deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ozlerhakan committed Sep 25, 2023
1 parent 97b0ccf commit 188bc7f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
12 changes: 9 additions & 3 deletions src/test/java/com/poiji/deserialize/FromExcelSheetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public void shouldMapXLSSheet() throws IOException {
assertThat(result, notNullValue());
CellFormatModel cellFormatModel = result.get(1);
assertThat(cellFormatModel.getAge(), is(40));
workbook.close();
}

@Test
Expand All @@ -51,21 +52,23 @@ public void shouldMapXLSXSheet() throws IOException {
assertThat(result, notNullValue());
CellFormatModel cellFormatModel = result.get(1);
assertThat(cellFormatModel.getAge(), is(40));
workbook.close();
}


@Test
public void shouldMapXLSXSheetWithOptions() throws IOException {

File file = new File("src/test/resources/employees_format.xlsx");
FileInputStream fileInputStream = new FileInputStream(file);
Workbook workbook = new XSSFWorkbook(fileInputStream);
Sheet sheet = workbook.getSheetAt(0);
List<CellFormatModel> result = Poiji.fromExcel(sheet, CellFormatModel.class, PoijiOptions.PoijiOptionsBuilder.settings().build());
List<CellFormatModel> result = Poiji.fromExcel(sheet, CellFormatModel.class,
PoijiOptions.PoijiOptionsBuilder.settings().build());

assertThat(result, notNullValue());
CellFormatModel cellFormatModel = result.get(1);
assertThat(cellFormatModel.getAge(), is(40));
workbook.close();
}

@Test
Expand All @@ -76,7 +79,9 @@ public void shouldMapXLSXSheetWithOptionsConsumer() throws IOException {
Workbook workbook = new XSSFWorkbook(fileInputStream);
Sheet sheet = workbook.getSheetAt(0);

Poiji.fromExcel(sheet, CellFormatModel.class, PoijiOptions.PoijiOptionsBuilder.settings().build(), this::printout);
Poiji.fromExcel(sheet, CellFormatModel.class, PoijiOptions.PoijiOptionsBuilder.settings().build(),
this::printout);
workbook.close();
}

private void printout(CellFormatModel instance) {
Expand All @@ -91,5 +96,6 @@ public void shouldMapXLSXSheetError() throws IOException {
Workbook workbook = new SXSSFWorkbook(xssfWorkbook);
Sheet sheet = workbook.getSheetAt(0);
Poiji.fromExcel(sheet, CellFormatModel.class);
workbook.close();
}
}
8 changes: 4 additions & 4 deletions src/test/java/com/poiji/deserialize/RawValueFormulaTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.poiji.deserialize;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

import com.poiji.bind.Poiji;
import com.poiji.deserialize.model.RowModelFormula;
Expand All @@ -27,9 +27,9 @@ public RawValueFormulaTest(String path) {

@Parameterized.Parameters(name = "{index}: ({0})={1}")
public static Iterable<Object[]> queries() {
return Arrays.asList(new Object[][]{
{"src/test/resources/raw_value_formula.xls"},
{"src/test/resources/raw_value_formula.xlsx"},
return Arrays.asList(new Object[][] {
{ "src/test/resources/raw_value_formula.xls" },
{ "src/test/resources/raw_value_formula.xlsx" },
});
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/poiji/deserialize/RawValueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.List;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

/**
* Created by hakan on 02/08/2018
Expand All @@ -28,9 +28,9 @@ public RawValueTest(String path) {

@Parameterized.Parameters(name = "{index}: ({0})={1}")
public static Iterable<Object[]> queries() {
return Arrays.asList(new Object[][]{
{"src/test/resources/raw_value.xls"},
{"src/test/resources/raw_value.xlsx"},
return Arrays.asList(new Object[][] {
{ "src/test/resources/raw_value.xls" },
{ "src/test/resources/raw_value.xlsx" },
});
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/poiji/util/FilesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

public class FilesTest {

Expand All @@ -26,8 +26,8 @@ public void getInstance() throws Exception {
@Test
public void getExtension() throws Exception {

assertThat(files.getExtension("cars.xl"),is(".xl"));
assertThat(files.getExtension("cars.xls"),is(".xls"));
assertThat(files.getExtension("cars.xlsx"),is(".xlsx"));
assertThat(files.getExtension("cars.xl"), is(".xl"));
assertThat(files.getExtension("cars.xls"), is(".xls"));
assertThat(files.getExtension("cars.xlsx"), is(".xlsx"));
}
}
Binary file added src/test/resources/dates-news.xlsx
Binary file not shown.

0 comments on commit 188bc7f

Please sign in to comment.