From 29c4420bf7ff008e357e71502d33689c8174a4fc Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Mon, 27 Feb 2017 14:23:17 +0100 Subject: [PATCH] parsing date improved (when data is no available) --- .../appointment/parse/SubjectParser.java | 3 ++ .../smash/appointment/parse/AllTests.java | 1 + .../appointment/parse/SubjectParserTest.java | 30 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 appointment-import/src/test/java/smash/appointment/parse/SubjectParserTest.java diff --git a/appointment-import/src/main/java/smash/appointment/parse/SubjectParser.java b/appointment-import/src/main/java/smash/appointment/parse/SubjectParser.java index d3fe996c..3a0ac4a8 100644 --- a/appointment-import/src/main/java/smash/appointment/parse/SubjectParser.java +++ b/appointment-import/src/main/java/smash/appointment/parse/SubjectParser.java @@ -142,6 +142,9 @@ public abstract class SubjectParser { } protected String getDate(Cell cell) { + if (cell == null) { + return ""; + } String result = null; if (cell.getCellTypeEnum().equals(CellType.STRING)) { result = getString(cell); diff --git a/appointment-import/src/test/java/smash/appointment/parse/AllTests.java b/appointment-import/src/test/java/smash/appointment/parse/AllTests.java index d51943e6..5aaea5c9 100644 --- a/appointment-import/src/test/java/smash/appointment/parse/AllTests.java +++ b/appointment-import/src/test/java/smash/appointment/parse/AllTests.java @@ -11,6 +11,7 @@ import org.junit.runners.Suite.SuiteClasses; RedcapParserTest.class, // SubjectDaoTest.class, // + SubjectParserTest.class, // XlsxCalendarProcessorTest.class, // }) public class AllTests { diff --git a/appointment-import/src/test/java/smash/appointment/parse/SubjectParserTest.java b/appointment-import/src/test/java/smash/appointment/parse/SubjectParserTest.java new file mode 100644 index 00000000..fffb1641 --- /dev/null +++ b/appointment-import/src/test/java/smash/appointment/parse/SubjectParserTest.java @@ -0,0 +1,30 @@ +package smash.appointment.parse; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; + +public class SubjectParserTest { + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testParseDate() { + SubjectParser parser = new PrcControlParser(); + assertEquals("", parser.getDate(null)); + } + +} -- GitLab