From 34342a1bddc39307643eb349f1ab99cb7f909a4b Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Mon, 27 Feb 2017 15:14:45 +0100 Subject: [PATCH] complex types parsing added --- .../parse/AppointmentTypeCollection.java | 18 +++++++++ .../smash/appointment/parse/CellParser.java | 1 + .../appointment/parse/CellParserTest.java | 40 ++++++++++++++++--- 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/appointment-import/src/main/java/smash/appointment/parse/AppointmentTypeCollection.java b/appointment-import/src/main/java/smash/appointment/parse/AppointmentTypeCollection.java index fd03c05b..dd8edeae 100644 --- a/appointment-import/src/main/java/smash/appointment/parse/AppointmentTypeCollection.java +++ b/appointment-import/src/main/java/smash/appointment/parse/AppointmentTypeCollection.java @@ -1,9 +1,27 @@ package smash.appointment.parse; public enum AppointmentTypeCollection { + LEVEL_A_BV_BG(new AppointmentType[] { AppointmentType.LEVEL_A, AppointmentType.LEVEL_BV, AppointmentType.LEVEL_BG }, // + new String[] { "BV + BG + neuro level A" }), // + LEVEL_A_B(new AppointmentType[] { AppointmentType.LEVEL_A, AppointmentType.LEVEL_B }, // + new String[] { "level B + level A neuro" }), // + + LEVEL_B_BV_SB(new AppointmentType[] { AppointmentType.LEVEL_B, AppointmentType.LEVEL_BV, AppointmentType.LEVEL_SB }, // + new String[] { "level B + BV + SB" }), // + + LEVEL_B_BV_BG(new AppointmentType[] { AppointmentType.LEVEL_B, AppointmentType.LEVEL_BV, AppointmentType.LEVEL_BG }, // + new String[] { "level B + BV + BG" }), // + + LEVEL_B_BG(new AppointmentType[] { AppointmentType.LEVEL_B, AppointmentType.LEVEL_BG }, // + new String[] { "level B + BG" }), // + LEVEL_BV_BG_SB_MPOWER( new AppointmentType[] { AppointmentType.LEVEL_BV, AppointmentType.LEVEL_BG, AppointmentType.LEVEL_SB, AppointmentType.LEVEL_B_M_POWER, }, // new String[] { "evel BV + BG + SB + mPower", "BV + BG + SB + mPower" }), // + + LEVEL_BG_SB_MPOWER( + new AppointmentType[] { AppointmentType.LEVEL_BG, AppointmentType.LEVEL_SB, AppointmentType.LEVEL_B_M_POWER, }, // + new String[] { "BG + SB + mPower" }), // LEVEL_BV_BG_SB(new AppointmentType[] { AppointmentType.LEVEL_BV, AppointmentType.LEVEL_BG, AppointmentType.LEVEL_SB }, // new String[] { "evel BV + BG + SB", "BV + BG + SB" }), // LEVEL_BV_SB(new AppointmentType[] { AppointmentType.LEVEL_BV, AppointmentType.LEVEL_SB }, // diff --git a/appointment-import/src/main/java/smash/appointment/parse/CellParser.java b/appointment-import/src/main/java/smash/appointment/parse/CellParser.java index 01be5b86..3780a800 100644 --- a/appointment-import/src/main/java/smash/appointment/parse/CellParser.java +++ b/appointment-import/src/main/java/smash/appointment/parse/CellParser.java @@ -55,6 +55,7 @@ public class CellParser { } private AppointmentTypeCollection extractType(String query) { + String simplifiedQuery = Utils.simplifyString(query); AppointmentTypeCollection result = null; diff --git a/appointment-import/src/test/java/smash/appointment/parse/CellParserTest.java b/appointment-import/src/test/java/smash/appointment/parse/CellParserTest.java index c4cb6ce9..e86d16d2 100644 --- a/appointment-import/src/test/java/smash/appointment/parse/CellParserTest.java +++ b/appointment-import/src/test/java/smash/appointment/parse/CellParserTest.java @@ -7,7 +7,6 @@ import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Map; import org.apache.log4j.Logger; import org.junit.Before; @@ -47,6 +46,35 @@ public class CellParserTest extends TestBase { new AppointmentType[] { AppointmentType.LEVEL_BV, AppointmentType.LEVEL_BG, AppointmentType.LEVEL_SB, AppointmentType.LEVEL_B_M_POWER })); testCases.add(new CellParseTestCase("sb name level A", null, null, new AppointmentType[] { AppointmentType.LEVEL_A })); testCases.add(new CellParseTestCase("Andrew Dude level A FU V3", andrewDude, null, new AppointmentType[] { AppointmentType.LEVEL_A })); + testCases.add( + new CellParseTestCase( + "Gawron Piotr BV + BG + neuro level A (FU)", piotrGawron, null, + new AppointmentType[] { AppointmentType.LEVEL_A, AppointmentType.LEVEL_BV, AppointmentType.LEVEL_BG })); + + testCases.add( + new CellParseTestCase( + "Gawron Piotr level B © + level A neuro ©", piotrGawron, null, new AppointmentType[] { AppointmentType.LEVEL_A, AppointmentType.LEVEL_B })); + + testCases.add( + new CellParseTestCase( + "Gawron Piotr level B © + BV © + SB ©", piotrGawron, null, + new AppointmentType[] { AppointmentType.LEVEL_B, AppointmentType.LEVEL_BV, AppointmentType.LEVEL_SB })); + + testCases.add( + new CellParseTestCase( + "Gawron Piotr level B + BV + BG", piotrGawron, null, + new AppointmentType[] { AppointmentType.LEVEL_B, AppointmentType.LEVEL_BV, AppointmentType.LEVEL_BG })); + + testCases.add( + new CellParseTestCase("Gawron Piotr level B + BG", piotrGawron, null, new AppointmentType[] { AppointmentType.LEVEL_B, AppointmentType.LEVEL_BG })); + testCases.add( + new CellParseTestCase( + "Gawron Piotr level B © + BV © + SB ©", piotrGawron, null, + new AppointmentType[] { AppointmentType.LEVEL_B, AppointmentType.LEVEL_BV, AppointmentType.LEVEL_SB })); + testCases.add( + new CellParseTestCase( + "Gawron Piotr level BG + SB + M-Power", piotrGawron, null, + new AppointmentType[] { AppointmentType.LEVEL_BG, AppointmentType.LEVEL_SB, AppointmentType.LEVEL_B_M_POWER })); } @Test @@ -86,22 +114,24 @@ public class CellParserTest extends TestBase { assertEquals("Invalid time parsed from query (default value expected): " + testCase.query, defaultTime, appointment.getTime()); } assertEquals("Invalid subject parsed from query: " + testCase.query, testCase.subject, appointment.getSubject()); - assertTrue("Invalid type parsed from query: " + testCase.query, equalTypes(Arrays.asList(testCase.types), appointment.getTypes())); + assertTrue( + "Invalid type parsed from query: " + testCase.query + " expected: " + Arrays.asList(testCase.types) + "; found: " + appointment.getTypes(), + equalTypes(Arrays.asList(testCase.types), appointment.getTypes())); } } private boolean equalTypes(List<AppointmentType> types, List<AppointmentType> types2) { - for (AppointmentType type: types) { + for (AppointmentType type : types) { if (!types2.contains(type)) { return false; } } - for (AppointmentType type: types2) { + for (AppointmentType type : types2) { if (!types.contains(type)) { return false; } } - + return true; } -- GitLab