| 1 |
|
package net.technearts; |
| 2 |
|
|
| 3 |
|
import java.io.File; |
| 4 |
|
import java.io.IOException; |
| 5 |
|
import java.net.URI; |
| 6 |
|
import java.net.URISyntaxException; |
| 7 |
|
import java.net.URL; |
| 8 |
|
|
| 9 |
|
import org.junit.Test; |
| 10 |
|
|
| 11 |
|
import net.technearts.ExcelFile; |
| 12 |
|
|
| 13 |
|
import static org.junit.Assert.assertEquals; |
| 14 |
|
import static org.junit.Assert.assertTrue; |
| 15 |
|
import static org.junit.Assert.fail; |
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| |
|
| 88.9% |
Uncovered Elements: 5 (45) |
Complexity: 12 |
Complexity Density: 0.3 |
|
| 20 |
|
public class ExcelFileTest { |
| 21 |
|
|
| |
|
| 93.8% |
Uncovered Elements: 1 (16) |
Complexity: 4 |
Complexity Density: 0.25 |
1PASS
|
|
| 22 |
1 |
@Test... |
| 23 |
|
public void testExcelFile() { |
| 24 |
|
|
| 25 |
1 |
try (ExcelFile xls = |
| 26 |
|
new ExcelFile(new File(this.getClass().getResource("/Pasta1.xlsx").toURI()))) { |
| 27 |
1 |
xls.write("Plan1", 0, 0, "A"); |
| 28 |
1 |
xls.write("Plan1", 0, 1, "B"); |
| 29 |
1 |
xls.write("Plan1", 0, 2, "C"); |
| 30 |
1 |
xls.write("Plan1", 1, 0, 1); |
| 31 |
1 |
xls.write("Plan1", 1, 1, 2); |
| 32 |
1 |
xls.write("Plan1", 1, 2, 3); |
| 33 |
1 |
assertEquals(xls.read("Plan1", 0, 0, ExcelFileTest::stringTest), "A"); |
| 34 |
1 |
assertEquals(xls.read("Plan1", 0, 1, ExcelFileTest::stringTest), "B"); |
| 35 |
1 |
assertEquals(xls.read("Plan1", 0, 2, ExcelFileTest::stringTest), "C"); |
| 36 |
1 |
assertEquals(xls.read("Plan1", 1, 0, Double::valueOf, ExcelFileTest::doubleTest), 1.0d, |
| 37 |
|
0.001d); |
| 38 |
1 |
assertEquals(xls.read("Plan1", 1, 1, Double::valueOf, ExcelFileTest::doubleTest), 2.0d, |
| 39 |
|
0.001d); |
| 40 |
1 |
assertEquals(xls.read("Plan1", 1, 2, Double::valueOf, ExcelFileTest::doubleTest), 3.0d, |
| 41 |
|
0.001d); |
| 42 |
|
} catch (URISyntaxException | IOException e) { |
| 43 |
0 |
fail(e.getMessage()); |
| 44 |
|
} |
| 45 |
1 |
assertTrue(true); |
| 46 |
|
} |
| 47 |
|
|
| |
|
| 90.5% |
Uncovered Elements: 2 (21) |
Complexity: 5 |
Complexity Density: 0.24 |
1PASS
|
|
| 48 |
1 |
@Test... |
| 49 |
|
public void testExcelSheet() { |
| 50 |
1 |
URL url = this.getClass().getResource("/Pasta1.xlsx"); |
| 51 |
1 |
try { |
| 52 |
1 |
URI uri = url.toURI(); |
| 53 |
1 |
try (ExcelFile xls = new ExcelFile(new File(uri))) { |
| 54 |
1 |
ExcelFile.ExcelSheet sheet = xls.sheet("Plan2"); |
| 55 |
1 |
sheet.write(0, 0, "A"); |
| 56 |
1 |
sheet.write(0, 1, "B"); |
| 57 |
1 |
sheet.write(0, 2, "C"); |
| 58 |
1 |
sheet.write(1, 0, 1); |
| 59 |
1 |
sheet.write(1, 1, 2); |
| 60 |
1 |
sheet.write(1, 2, 3); |
| 61 |
1 |
assertEquals(sheet.read(0, 0, ExcelFileTest::stringTest), "A"); |
| 62 |
1 |
assertEquals(sheet.read(0, 1, ExcelFileTest::stringTest), "B"); |
| 63 |
1 |
assertEquals(sheet.read(0, 2, ExcelFileTest::stringTest), "C"); |
| 64 |
1 |
assertEquals(sheet.read(1, 0, Double::valueOf, ExcelFileTest::doubleTest), 1.0d, 0.001d); |
| 65 |
1 |
assertEquals(sheet.read(1, 1, Double::valueOf, ExcelFileTest::doubleTest), 2.0d, 0.001d); |
| 66 |
1 |
assertEquals(sheet.read(1, 2, Double::valueOf, ExcelFileTest::doubleTest), 3.0d, 0.001d); |
| 67 |
|
} catch (IOException e) { |
| 68 |
0 |
fail(e.getMessage()); |
| 69 |
|
} |
| 70 |
|
} catch (URISyntaxException e1) { |
| 71 |
|
|
| 72 |
0 |
e1.printStackTrace(); |
| 73 |
|
} |
| 74 |
1 |
assertTrue(true); |
| 75 |
|
} |
| 76 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 77 |
6 |
static Double doubleTest(Double a) {... |
| 78 |
6 |
return a; |
| 79 |
|
} |
| 80 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 81 |
6 |
static String stringTest(String a) {... |
| 82 |
6 |
return a; |
| 83 |
|
} |
| 84 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 85 |
0 |
static boolean booleanTest(boolean a) {... |
| 86 |
0 |
return a; |
| 87 |
|
} |
| 88 |
|
} |