Skip to content
Snippets Groups Projects
Commit 34342a1b authored by Piotr Gawron's avatar Piotr Gawron
Browse files

complex types parsing added

parent 7224b5c4
No related branches found
No related tags found
1 merge request!1Appointments dev
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 }, //
......
......@@ -55,6 +55,7 @@ public class CellParser {
}
private AppointmentTypeCollection extractType(String query) {
String simplifiedQuery = Utils.simplifyString(query);
AppointmentTypeCollection result = null;
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment