Skip to content

Commit

Permalink
test(core): cover findTitleColumn
Browse files Browse the repository at this point in the history
Is not covered

Refs: #304
  • Loading branch information
aerfus committed Feb 18, 2024
1 parent 6094667 commit 211e976
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/test/java/com/poiji/bind/mapping/HSSFUnmarshallerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.poiji.bind.mapping;

import com.poiji.annotation.ExcelCellName;
import com.poiji.deserialize.model.InventoryData;
import com.poiji.option.PoijiOptions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.lang.reflect.Field;
import java.util.List;

import static org.junit.Assert.assertNull;

@RunWith(Parameterized.class)
public class HSSFUnmarshallerTest {

private final ExcelCellName annotation;

public HSSFUnmarshallerTest(String fieldName) throws NoSuchFieldException {
Field author = InventoryData.class.getDeclaredField(fieldName);
annotation = author.getAnnotation(ExcelCellName.class);
}

@Parameterized.Parameters(name = "{index}: ({0})={1}")
public static Iterable<Object[]> queries() {
return List.of(new Object[][]{
{
"id"
},
{
"author"
},
});
}

@Test
public void shouldFindTitleColumn() {
HSSFUnmarshallerFile hssfUnmarshallerFile = new HSSFUnmarshallerFile(null, PoijiOptions.PoijiOptionsBuilder.settings().build());

Integer titleColumn = hssfUnmarshallerFile.findTitleColumn(annotation);

assertNull(titleColumn);
}
}
45 changes: 45 additions & 0 deletions src/test/java/com/poiji/bind/mapping/PoijiHandlerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.poiji.bind.mapping;

import com.poiji.annotation.ExcelCellName;
import com.poiji.deserialize.model.InventoryData;
import com.poiji.option.PoijiOptions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.lang.reflect.Field;
import java.util.List;

import static org.junit.Assert.*;

@RunWith(Parameterized.class)
public class PoijiHandlerTest {

private final ExcelCellName annotation;

public PoijiHandlerTest(String fieldName) throws NoSuchFieldException {
Field author = InventoryData.class.getDeclaredField(fieldName);
annotation = author.getAnnotation(ExcelCellName.class);
}

@Parameterized.Parameters(name = "{index}: ({0})={1}")
public static Iterable<Object[]> queries() {
return List.of(new Object[][]{
{
"id"
},
{
"author"
},
});
}

@Test
public void shouldFindTitleColumn() {
PoijiHandler<InventoryData> poijiHandler = new PoijiHandler<>(InventoryData.class, PoijiOptions.PoijiOptionsBuilder.settings().build(), o -> {});

Integer titleColumn = poijiHandler.findTitleColumn(annotation);

assertNull(titleColumn);
}
}

0 comments on commit 211e976

Please sign in to comment.