0001: package org.drools.eclipse.editors.completion;
0002:
0003: import org.drools.lang.Location;
0004:
0005: import junit.framework.TestCase;
0006:
0007: /**
0008: * Test to check the location determination when doing code completion inside
0009: * rule condtions.
0010: *
0011: * @author <a href="mailto:kris_verlaenen@hotmail.com">kris verlaenen </a>
0012: *
0013: */
0014: public class CompletionContextTest extends TestCase {
0015:
0016: public void testColumnOperatorPattern() {
0017: assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0018: "( property ").matches());
0019: assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0020: "( property ").matches());
0021: assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0022: "( property ").matches());
0023: assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0024: "( name : property ").matches());
0025: assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0026: "(name:property ").matches());
0027: assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0028: "( name:property ").matches());
0029: assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0030: "( name:property ").matches());
0031: assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0032: "( name : property ").matches());
0033: assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0034: "( property1 == \"value\", property2 ").matches());
0035: assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0036: "( property1 == \"value\", name : property2 ")
0037: .matches());
0038: assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0039: "( property1 == \"value\", name:property2 ").matches());
0040: assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0041: "( property1 == \"value\", name : property2 ")
0042: .matches());
0043: assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0044: "( prop").matches());
0045: assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0046: "(prop").matches());
0047: assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0048: "( prop").matches());
0049: assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0050: "( name:prop").matches());
0051: assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0052: "(name:prop").matches());
0053: assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0054: "( name : prop").matches());
0055: assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0056: "( name : prop").matches());
0057: assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0058: "( property <= ").matches());
0059: assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0060: "( name : property == ").matches());
0061: assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0062: "(property==").matches());
0063: assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0064: "( property contains ").matches());
0065: assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher(
0066: "( property1 == \"value\", property2 >= ").matches());
0067: }
0068:
0069: public void testColumnArgumentPattern() {
0070: assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT
0071: .matcher("( property == ").matches());
0072: assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT
0073: .matcher("( property >= ").matches());
0074: assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT
0075: .matcher("(property== ").matches());
0076: assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT
0077: .matcher("( property == ").matches());
0078: assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT
0079: .matcher("( name : property == ").matches());
0080: assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT
0081: .matcher("(name:property== ").matches());
0082: assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT
0083: .matcher("( name : property == ").matches());
0084: assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT
0085: .matcher("( property1 == \"value\", property2 == ")
0086: .matches());
0087: assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT
0088: .matcher("( property1 == \"value\",property2== ")
0089: .matches());
0090: assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT
0091: .matcher("( property1 == \"value\", property2 == ")
0092: .matches());
0093: assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT
0094: .matcher("( property == otherProp").matches());
0095: assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT
0096: .matcher("(property==otherProp").matches());
0097: }
0098:
0099: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION1() {
0100: String input = "rule MyRule \n" + " when \n" + " ";
0101: Location location = new CompletionContext(input).getLocation();
0102: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
0103: .getType());
0104: }
0105:
0106: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION2() {
0107: String input = "rule MyRule \n" + " when \n"
0108: + " Class( condition == true ) \n" + " ";
0109: Location location = new CompletionContext(input).getLocation();
0110: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
0111: .getType());
0112: }
0113:
0114: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION3() {
0115: String input = "rule MyRule \n"
0116: + " when \n"
0117: + " class: Class( condition == true, condition2 == null ) \n"
0118: + " ";
0119: Location location = new CompletionContext(input).getLocation();
0120: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
0121: .getType());
0122: }
0123:
0124: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION4() {
0125: String input = "rule MyRule \n" + " when \n" + " Cl";
0126: Location location = new CompletionContext(input).getLocation();
0127: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
0128: .getType());
0129: }
0130:
0131: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION5() {
0132: String input = "rule MyRule \n" + " when \n"
0133: + " Class( condition == true ) \n" + " Cl";
0134: Location location = new CompletionContext(input).getLocation();
0135: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
0136: .getType());
0137: }
0138:
0139: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION6() {
0140: String input = "rule MyRule \n" + " when \n" + " class: Cl";
0141: Location location = new CompletionContext(input).getLocation();
0142: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
0143: .getType());
0144: }
0145:
0146: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION7() {
0147: String input = "rule MyRule \n" + " when \n" + " class:Cl";
0148: Location location = new CompletionContext(input).getLocation();
0149: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
0150: .getType());
0151: }
0152:
0153: /** Inside of condition: start */
0154: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START1() {
0155: String input = "rule MyRule \n" + " when \n" + " Class (";
0156: Location location = new CompletionContext(input).getLocation();
0157: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0158: location.getType());
0159: assertEquals("Class", location
0160: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0161: }
0162:
0163: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START2() {
0164: String input = "rule MyRule \n" + " when \n" + " Class ( na";
0165: Location location = new CompletionContext(input).getLocation();
0166: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0167: location.getType());
0168: assertEquals("Class", location
0169: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0170: assertEquals("na", location
0171: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0172: }
0173:
0174: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START3() {
0175: String input = "rule MyRule \n" + " when \n"
0176: + " Class ( name.subProperty['test'].subsu";
0177: Location location = new CompletionContext(input).getLocation();
0178: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0179: location.getType());
0180: assertEquals("Class", location
0181: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0182: assertEquals("name.subProperty['test'].subsu", location
0183: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0184: }
0185:
0186: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START4() {
0187: String input = "rule MyRule \n" + " when \n"
0188: + " Class ( condition == true, ";
0189: Location location = new CompletionContext(input).getLocation();
0190: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0191: location.getType());
0192: assertEquals("Class", location
0193: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0194: }
0195:
0196: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START5() {
0197: String input = "rule MyRule \n" + " when \n"
0198: + " Class ( condition == true, na";
0199: Location location = new CompletionContext(input).getLocation();
0200: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0201: location.getType());
0202: assertEquals("Class", location
0203: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0204: }
0205:
0206: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START6() {
0207: String input = "rule MyRule \n" + " when \n" + " Class ( \n"
0208: + " ";
0209: Location location = new CompletionContext(input).getLocation();
0210: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0211: location.getType());
0212: assertEquals("Class", location
0213: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0214: }
0215:
0216: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START7() {
0217: String input = "rule MyRule \n" + " when \n"
0218: + " Class ( condition == true, \n" + " ";
0219: Location location = new CompletionContext(input).getLocation();
0220: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0221: location.getType());
0222: assertEquals("Class", location
0223: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0224:
0225: }
0226:
0227: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START8() {
0228: String input = "rule MyRule \n" + " when \n"
0229: + " Class ( c: condition, \n" + " ";
0230: Location location = new CompletionContext(input).getLocation();
0231: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0232: location.getType());
0233: assertEquals("Class", location
0234: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0235: }
0236:
0237: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START9a() {
0238: String input = "rule MyRule \n" + " when \n"
0239: + " Class ( name:";
0240: Location location = new CompletionContext(input).getLocation();
0241: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0242: location.getType());
0243: assertEquals("Class", location
0244: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0245: }
0246:
0247: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START9b() {
0248: String input = "rule MyRule \n" + " when \n"
0249: + " Class ( name: ";
0250: Location location = new CompletionContext(input).getLocation();
0251: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0252: location.getType());
0253: assertEquals("Class", location
0254: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0255: }
0256:
0257: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START10() {
0258: String input = "rule MyRule \n" + " when \n"
0259: + " Class ( name:";
0260: Location location = new CompletionContext(input).getLocation();
0261: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0262: location.getType());
0263: assertEquals("Class", location
0264: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0265:
0266: }
0267:
0268: /** Inside of condition: Operator */
0269: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR1() {
0270: String input = "rule MyRule \n" + " when \n"
0271: + " Class ( property ";
0272: Location location = new CompletionContext(input).getLocation();
0273: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
0274: location.getType());
0275: assertEquals("Class", location
0276: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0277: assertEquals("property", location
0278: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0279: }
0280:
0281: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR2() {
0282: String input = "rule MyRule \n" + " when \n"
0283: + " Class(property ";
0284: Location location = new CompletionContext(input).getLocation();
0285: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
0286: location.getType());
0287: assertEquals("Class", location
0288: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0289: assertEquals("property", location
0290: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0291: }
0292:
0293: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR3() {
0294: String input = "rule MyRule \n" + " when \n"
0295: + " Class ( name : property ";
0296: Location location = new CompletionContext(input).getLocation();
0297: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
0298: location.getType());
0299: assertEquals("Class", location
0300: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0301: assertEquals("property", location
0302: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0303: }
0304:
0305: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR4() {
0306: String input = "rule MyRule \n" + " when \n"
0307: + " Class (name:property ";
0308: Location location = new CompletionContext(input).getLocation();
0309: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
0310: location.getType());
0311: assertEquals("Class", location
0312: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0313: assertEquals("property", location
0314: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0315: }
0316:
0317: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR5() {
0318: String input = "rule MyRule \n" + " when \n"
0319: + " Class (name:property ";
0320: Location location = new CompletionContext(input).getLocation();
0321: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
0322: location.getType());
0323: assertEquals("Class", location
0324: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0325: assertEquals("property", location
0326: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0327: }
0328:
0329: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR6() {
0330: String input = "rule MyRule \n" + " when \n"
0331: + " Class ( name1 : property1, name : property ";
0332: Location location = new CompletionContext(input).getLocation();
0333: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
0334: location.getType());
0335: assertEquals("Class", location
0336: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0337: assertEquals("property", location
0338: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0339: }
0340:
0341: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR7() {
0342: String input = "rule MyRule \n"
0343: + " when \n"
0344: + " Class ( name1 : property1 == \"value\", name : property ";
0345: Location location = new CompletionContext(input).getLocation();
0346: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
0347: location.getType());
0348: assertEquals("Class", location
0349: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0350: assertEquals("property", location
0351: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0352: }
0353:
0354: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR8() {
0355: String input = "rule MyRule \n" + " when \n"
0356: + " Class ( name1 : property1 == \"value\",property ";
0357: Location location = new CompletionContext(input).getLocation();
0358: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
0359: location.getType());
0360: assertEquals("Class", location
0361: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0362: assertEquals("property", location
0363: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0364: }
0365:
0366: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR9() {
0367: String input = "rule MyRule \n" + " when \n"
0368: + " Class ( name1 : property1, \n"
0369: + " name : property ";
0370: Location location = new CompletionContext(input).getLocation();
0371: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
0372: location.getType());
0373: assertEquals("Class", location
0374: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0375: assertEquals("property", location
0376: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0377: }
0378:
0379: /** Inside of condition: argument */
0380: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT1() {
0381: String input = "rule MyRule \n" + " when \n"
0382: + " Class ( property == ";
0383: Location location = new CompletionContext(input).getLocation();
0384: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
0385: location.getType());
0386: assertEquals("Class", location
0387: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0388: assertEquals("property", location
0389: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0390: assertEquals("==", location
0391: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
0392: }
0393:
0394: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT2() {
0395: String input = "rule MyRule \n" + " when \n"
0396: + " Class ( property== ";
0397: Location location = new CompletionContext(input).getLocation();
0398: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
0399: location.getType());
0400: assertEquals("Class", location
0401: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0402: assertEquals("property", location
0403: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0404: assertEquals("==", location
0405: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
0406: }
0407:
0408: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT3() {
0409: String input = "rule MyRule \n" + " when \n"
0410: + " Class ( name : property <= ";
0411: Location location = new CompletionContext(input).getLocation();
0412: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
0413: location.getType());
0414: assertEquals("Class", location
0415: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0416: assertEquals("property", location
0417: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0418: assertEquals("<=", location
0419: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
0420: }
0421:
0422: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT4() {
0423: String input = "rule MyRule \n" + " when \n"
0424: + " Class ( name:property != ";
0425: Location location = new CompletionContext(input).getLocation();
0426: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
0427: location.getType());
0428: assertEquals("Class", location
0429: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0430: assertEquals("property", location
0431: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0432: assertEquals("!=", location
0433: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
0434: }
0435:
0436: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT5() {
0437: String input = "rule MyRule \n" + " when \n"
0438: + " Class ( name1 : property1, property2 == ";
0439: Location location = new CompletionContext(input).getLocation();
0440: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
0441: location.getType());
0442: assertEquals("Class", location
0443: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0444: assertEquals("property2", location
0445: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0446: assertEquals("==", location
0447: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
0448: }
0449:
0450: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT6() {
0451: String input = "rule MyRule \n" + " when \n"
0452: + " Class (name:property== ";
0453: Location location = new CompletionContext(input).getLocation();
0454: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
0455: location.getType());
0456: assertEquals("Class", location
0457: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0458: assertEquals("property", location
0459: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0460: assertEquals("==", location
0461: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
0462: }
0463:
0464: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT7() {
0465: String input = "rule MyRule \n" + " when \n"
0466: + " Class ( property == otherPropertyN";
0467: Location location = new CompletionContext(input).getLocation();
0468: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
0469: location.getType());
0470: assertEquals("Class", location
0471: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0472: assertEquals("property", location
0473: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0474: assertEquals("==", location
0475: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
0476: }
0477:
0478: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT8() {
0479: String input = "rule MyRule \n" + " when \n"
0480: + " Class ( property == \"someth";
0481: Location location = new CompletionContext(input).getLocation();
0482: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
0483: location.getType());
0484: assertEquals("Class", location
0485: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0486: assertEquals("property", location
0487: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0488: assertEquals("==", location
0489: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
0490: }
0491:
0492: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT9() {
0493: String input = "rule MyRule \n" + " when \n"
0494: + " Class ( property contains ";
0495: Location location = new CompletionContext(input).getLocation();
0496: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
0497: location.getType());
0498: assertEquals("Class", location
0499: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0500: assertEquals("property", location
0501: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0502: assertEquals("contains", location
0503: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
0504: }
0505:
0506: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT10() {
0507: String input = "rule MyRule \n" + " when \n"
0508: + " Class ( property excludes ";
0509: Location location = new CompletionContext(input).getLocation();
0510: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
0511: location.getType());
0512: assertEquals("Class", location
0513: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0514: assertEquals("property", location
0515: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0516: assertEquals("excludes", location
0517: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
0518: }
0519:
0520: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT11() {
0521: String input = "rule MyRule \n" + " when \n"
0522: + " Class ( property matches \"prop";
0523: Location location = new CompletionContext(input).getLocation();
0524: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
0525: location.getType());
0526: assertEquals("Class", location
0527: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0528: assertEquals("property", location
0529: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0530: assertEquals("matches", location
0531: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
0532: }
0533:
0534: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT12() {
0535: String input = "rule MyRule \n" + " when \n"
0536: + " Class ( property in ";
0537: Location location = new CompletionContext(input).getLocation();
0538: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
0539: location.getType());
0540: assertEquals("Class", location
0541: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0542: assertEquals("property", location
0543: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0544: assertEquals("in", location
0545: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
0546: }
0547:
0548: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END1() {
0549: String input = "rule MyRule \n" + " when \n"
0550: + " Class ( property in ('1', '2') ";
0551: Location location = new CompletionContext(input).getLocation();
0552: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END,
0553: location.getType());
0554: assertEquals("Class", location
0555: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0556: }
0557:
0558: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START11() {
0559: String input = "rule MyRule \n" + " when \n"
0560: + " Class ( property in ('1', '2'), ";
0561: Location location = new CompletionContext(input).getLocation();
0562: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0563: location.getType());
0564: assertEquals("Class", location
0565: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0566: }
0567:
0568: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT13() {
0569: String input = "rule MyRule \n" + " when \n"
0570: + " Class ( property not in ";
0571: Location location = new CompletionContext(input).getLocation();
0572: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
0573: location.getType());
0574: assertEquals("Class", location
0575: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0576: assertEquals("property", location
0577: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0578: assertEquals("in", location
0579: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
0580: }
0581:
0582: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END2() {
0583: String input = "rule MyRule \n" + " when \n"
0584: + " Class ( property not in ('1', '2') ";
0585: Location location = new CompletionContext(input).getLocation();
0586: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END,
0587: location.getType());
0588: assertEquals("Class", location
0589: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0590: }
0591:
0592: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START12() {
0593: String input = "rule MyRule \n" + " when \n"
0594: + " Class ( property not in ('1', '2'), ";
0595: Location location = new CompletionContext(input).getLocation();
0596: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0597: location.getType());
0598: assertEquals("Class", location
0599: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0600: }
0601:
0602: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT14() {
0603: String input = "rule MyRule \n" + " when \n"
0604: + " Class ( property memberOf ";
0605: Location location = new CompletionContext(input).getLocation();
0606: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
0607: location.getType());
0608: assertEquals("Class", location
0609: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0610: assertEquals("property", location
0611: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0612: assertEquals("memberOf", location
0613: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
0614: }
0615:
0616: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END3() {
0617: String input = "rule MyRule \n" + " when \n"
0618: + " Class ( property memberOf collection ";
0619: Location location = new CompletionContext(input).getLocation();
0620: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END,
0621: location.getType());
0622: assertEquals("Class", location
0623: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0624: }
0625:
0626: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START13() {
0627: String input = "rule MyRule \n" + " when \n"
0628: + " Class ( property memberOf collection, ";
0629: Location location = new CompletionContext(input).getLocation();
0630: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0631: location.getType());
0632: assertEquals("Class", location
0633: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0634: }
0635:
0636: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT15() {
0637: String input = "rule MyRule \n" + " when \n"
0638: + " Class ( property not memberOf ";
0639: Location location = new CompletionContext(input).getLocation();
0640: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
0641: location.getType());
0642: assertEquals("Class", location
0643: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0644: assertEquals("property", location
0645: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0646: assertEquals("memberOf", location
0647: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
0648: }
0649:
0650: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END4() {
0651: String input = "rule MyRule \n" + " when \n"
0652: + " Class ( property not memberOf collection ";
0653: Location location = new CompletionContext(input).getLocation();
0654: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END,
0655: location.getType());
0656: assertEquals("Class", location
0657: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0658: }
0659:
0660: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START14() {
0661: String input = "rule MyRule \n" + " when \n"
0662: + " Class ( property not memberOf collection, ";
0663: Location location = new CompletionContext(input).getLocation();
0664: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0665: location.getType());
0666: assertEquals("Class", location
0667: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0668: }
0669:
0670: /** EXISTS */
0671: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS1() {
0672: String input = "rule MyRule \n" + " when \n" + " exists ";
0673: Location location = new CompletionContext(input).getLocation();
0674: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS,
0675: location.getType());
0676: }
0677:
0678: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS2() {
0679: String input = "rule MyRule \n" + " when \n" + " exists ( ";
0680: Location location = new CompletionContext(input).getLocation();
0681: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS,
0682: location.getType());
0683: }
0684:
0685: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS3() {
0686: String input = "rule MyRule \n" + " when \n" + " exists(";
0687: Location location = new CompletionContext(input).getLocation();
0688: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS,
0689: location.getType());
0690: }
0691:
0692: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS4() {
0693: String input = "rule MyRule \n" + " when \n" + " exists Cl";
0694: Location location = new CompletionContext(input).getLocation();
0695: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS,
0696: location.getType());
0697: }
0698:
0699: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS5() {
0700: String input = "rule MyRule \n" + " when \n" + " exists ( Cl";
0701: Location location = new CompletionContext(input).getLocation();
0702: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS,
0703: location.getType());
0704: }
0705:
0706: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS6() {
0707: String input = "rule MyRule \n" + " when \n"
0708: + " exists ( name : Cl";
0709: Location location = new CompletionContext(input).getLocation();
0710: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS,
0711: location.getType());
0712: }
0713:
0714: public void testCheckLHSLocationDeterminationINSIDE_CONDITION_START16() {
0715: String input = "rule MyRule \n" + " when \n"
0716: + " exists Class (";
0717: Location location = new CompletionContext(input).getLocation();
0718: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0719: location.getType());
0720: assertEquals("Class", location
0721: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0722: }
0723:
0724: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION() {
0725: String input = "rule MyRule \n" + " when \n"
0726: + " exists Class ( ) \n" + " ";
0727: Location location = new CompletionContext(input).getLocation();
0728: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
0729: .getType());
0730: }
0731:
0732: /** NOT */
0733: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT1() {
0734: String input = "rule MyRule \n" + " when \n" + " not ";
0735: Location location = new CompletionContext(input).getLocation();
0736: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT,
0737: location.getType());
0738: }
0739:
0740: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT2() {
0741: String input = "rule MyRule \n" + " when \n" + " not Cl";
0742: Location location = new CompletionContext(input).getLocation();
0743: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT,
0744: location.getType());
0745: }
0746:
0747: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS7() {
0748: String input = "rule MyRule \n" + " when \n" + " not exists ";
0749: Location location = new CompletionContext(input).getLocation();
0750: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS,
0751: location.getType());
0752: }
0753:
0754: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS8() {
0755: String input = "rule MyRule \n" + " when \n"
0756: + " not exists Cl";
0757: Location location = new CompletionContext(input).getLocation();
0758: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS,
0759: location.getType());
0760: }
0761:
0762: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START21() {
0763: String input = "rule MyRule \n" + " when \n" + " not Class (";
0764: Location location = new CompletionContext(input).getLocation();
0765: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0766: location.getType());
0767: assertEquals("Class", location
0768: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0769: }
0770:
0771: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START22() {
0772: String input = "rule MyRule \n" + " when \n"
0773: + " not exists Class (";
0774: Location location = new CompletionContext(input).getLocation();
0775: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0776: location.getType());
0777: assertEquals("Class", location
0778: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0779: }
0780:
0781: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START23() {
0782: String input = "rule MyRule \n" + " when \n"
0783: + " not exists name : Class (";
0784: Location location = new CompletionContext(input).getLocation();
0785: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0786: location.getType());
0787: assertEquals("Class", location
0788: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
0789: }
0790:
0791: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION9() {
0792: String input = "rule MyRule \n" + " when \n"
0793: + " not Class () \n" + " ";
0794: Location location = new CompletionContext(input).getLocation();
0795: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
0796: .getType());
0797: }
0798:
0799: /** AND */
0800: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR1() {
0801: String input = "rule MyRule \n" + " when \n"
0802: + " Class ( ) and ";
0803: Location location = new CompletionContext(input).getLocation();
0804: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR,
0805: location.getType());
0806: }
0807:
0808: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR2() {
0809: String input = "rule MyRule \n" + " when \n"
0810: + " Class ( ) && ";
0811: Location location = new CompletionContext(input).getLocation();
0812: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR,
0813: location.getType());
0814: }
0815:
0816: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR3() {
0817: String input = "rule MyRule \n" + " when \n"
0818: + " Class () and ";
0819: Location location = new CompletionContext(input).getLocation();
0820: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR,
0821: location.getType());
0822: }
0823:
0824: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR4() {
0825: String input = "rule MyRule \n" + " when \n"
0826: + " name : Class ( name: property ) and ";
0827: Location location = new CompletionContext(input).getLocation();
0828: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR,
0829: location.getType());
0830: }
0831:
0832: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR5() {
0833: String input = "rule MyRule \n" + " when \n"
0834: + " Class ( name: property ) \n" + " and ";
0835: Location location = new CompletionContext(input).getLocation();
0836: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR,
0837: location.getType());
0838: }
0839:
0840: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR6() {
0841: String input = "rule MyRule \n" + " when \n"
0842: + " Class ( ) and Cl";
0843: Location location = new CompletionContext(input).getLocation();
0844: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR,
0845: location.getType());
0846: }
0847:
0848: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR7() {
0849: String input = "rule MyRule \n" + " when \n"
0850: + " Class ( ) and name : Cl";
0851: Location location = new CompletionContext(input).getLocation();
0852: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR,
0853: location.getType());
0854: }
0855:
0856: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR8() {
0857: String input = "rule MyRule \n" + " when \n"
0858: + " Class ( ) && name : Cl";
0859: Location location = new CompletionContext(input).getLocation();
0860: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR,
0861: location.getType());
0862: }
0863:
0864: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION31() {
0865: String input = "rule MyRule \n" + " when \n"
0866: + " Class ( ) and Class ( ) \n" + " ";
0867: Location location = new CompletionContext(input).getLocation();
0868: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
0869: .getType());
0870: }
0871:
0872: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION32() {
0873: String input = "rule MyRule \n" + " when \n"
0874: + " Class ( ) and not Class ( ) \n" + " ";
0875: Location location = new CompletionContext(input).getLocation();
0876: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
0877: .getType());
0878: }
0879:
0880: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION33() {
0881: String input = "rule MyRule \n" + " when \n"
0882: + " Class ( ) and exists Class ( ) \n" + " ";
0883: Location location = new CompletionContext(input).getLocation();
0884: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
0885: .getType());
0886: }
0887:
0888: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START20() {
0889: String input = "rule MyRule \n" + " when \n"
0890: + " Class ( ) and Class ( ";
0891: Location location = new CompletionContext(input).getLocation();
0892: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
0893: location.getType());
0894: }
0895:
0896: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR21() {
0897: String input = "rule MyRule \n" + " when \n"
0898: + " Class ( ) and Class ( name ";
0899: Location location = new CompletionContext(input).getLocation();
0900: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
0901: location.getType());
0902: assertEquals("name", location
0903: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
0904: }
0905:
0906: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR22() {
0907: String input = "rule MyRule \n" + " when \n"
0908: + " Class ( ) and Class ( name == ";
0909: Location location = new CompletionContext(input).getLocation();
0910: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
0911: location.getType());
0912: }
0913:
0914: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT() {
0915: String input = "rule MyRule \n" + " when \n"
0916: + " exists Class ( ) and not ";
0917: Location location = new CompletionContext(input).getLocation();
0918: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT,
0919: location.getType());
0920: }
0921:
0922: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS() {
0923: String input = "rule MyRule \n" + " when \n"
0924: + " exists Class ( ) and exists ";
0925: Location location = new CompletionContext(input).getLocation();
0926: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS,
0927: location.getType());
0928: }
0929:
0930: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION30() {
0931: String input = "rule MyRule \n" + " when \n"
0932: + " Class ( ) and not Class ( ) \n" + " ";
0933: Location location = new CompletionContext(input).getLocation();
0934: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
0935: .getType());
0936:
0937: /** OR */
0938: }
0939:
0940: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR21() {
0941: String input = "rule MyRule \n" + " when \n"
0942: + " Class ( ) or ";
0943: Location location = new CompletionContext(input).getLocation();
0944: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR,
0945: location.getType());
0946: }
0947:
0948: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR22() {
0949: String input = "rule MyRule \n" + " when \n"
0950: + " Class ( ) || ";
0951: Location location = new CompletionContext(input).getLocation();
0952: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR,
0953: location.getType());
0954: }
0955:
0956: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR23() {
0957: String input = "rule MyRule \n" + " when \n"
0958: + " Class () or ";
0959: Location location = new CompletionContext(input).getLocation();
0960: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR,
0961: location.getType());
0962: }
0963:
0964: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR24() {
0965: String input = "rule MyRule \n" + " when \n"
0966: + " name : Class ( name: property ) or ";
0967: Location location = new CompletionContext(input).getLocation();
0968: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR,
0969: location.getType());
0970: }
0971:
0972: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR25() {
0973: String input = "rule MyRule \n" + " when \n"
0974: + " Class ( name: property ) \n" + " or ";
0975: Location location = new CompletionContext(input).getLocation();
0976: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR,
0977: location.getType());
0978: }
0979:
0980: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR26() {
0981: String input = "rule MyRule \n" + " when \n"
0982: + " Class ( ) or Cl";
0983: Location location = new CompletionContext(input).getLocation();
0984: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR,
0985: location.getType());
0986: }
0987:
0988: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR27() {
0989: String input = "rule MyRule \n" + " when \n"
0990: + " Class ( ) or name : Cl";
0991: Location location = new CompletionContext(input).getLocation();
0992: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR,
0993: location.getType());
0994: }
0995:
0996: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR28() {
0997: String input = "rule MyRule \n" + " when \n"
0998: + " Class ( ) || name : Cl";
0999: Location location = new CompletionContext(input).getLocation();
1000: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR,
1001: location.getType());
1002: }
1003:
1004: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION40() {
1005: String input = "rule MyRule \n" + " when \n"
1006: + " Class ( ) or Class ( ) \n" + " ";
1007: Location location = new CompletionContext(input).getLocation();
1008: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1009: .getType());
1010: }
1011:
1012: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START40() {
1013: String input = "rule MyRule \n" + " when \n"
1014: + " Class ( ) or Class ( ";
1015: Location location = new CompletionContext(input).getLocation();
1016: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
1017: location.getType());
1018: }
1019:
1020: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR() {
1021: String input = "rule MyRule \n" + " when \n"
1022: + " Class ( ) or Class ( name ";
1023: Location location = new CompletionContext(input).getLocation();
1024: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
1025: location.getType());
1026: assertEquals("name", location
1027: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
1028: }
1029:
1030: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT30() {
1031: String input = "rule MyRule \n" + " when \n"
1032: + " Class ( ) or Class ( name == ";
1033: Location location = new CompletionContext(input).getLocation();
1034: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
1035: location.getType());
1036: }
1037:
1038: public void testCheckLHSLocationDetermination_EGIN_OF_CONDITION_NOT() {
1039: String input = "rule MyRule \n" + " when \n"
1040: + " exists Class ( ) or not ";
1041: Location location = new CompletionContext(input).getLocation();
1042: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT,
1043: location.getType());
1044: }
1045:
1046: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS40() {
1047: String input = "rule MyRule \n" + " when \n"
1048: + " exists Class ( ) or exists ";
1049: Location location = new CompletionContext(input).getLocation();
1050: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS,
1051: location.getType());
1052: }
1053:
1054: /** EVAL */
1055: public void testCheckLHSLocationDetermination_INSIDE_EVAL1() {
1056: String input = "rule MyRule \n" + " when \n" + " eval ( ";
1057: Location location = new CompletionContext(input).getLocation();
1058: assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location
1059: .getType());
1060: assertEquals("", location
1061: .getProperty(Location.LOCATION_EVAL_CONTENT));
1062: }
1063:
1064: public void testCheckLHSLocationDetermination_INSIDE_EVAL2() {
1065: String input = "rule MyRule \n" + " when \n" + " eval(";
1066: Location location = new CompletionContext(input).getLocation();
1067: assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location
1068: .getType());
1069: assertEquals("", location
1070: .getProperty(Location.LOCATION_EVAL_CONTENT));
1071: }
1072:
1073: public void testCheckLHSLocationDetermination_INSIDE_EVAL3() {
1074: String input = "rule MyRule \n" + " when \n" + " eval( myCla";
1075: Location location = new CompletionContext(input).getLocation();
1076: assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location
1077: .getType());
1078: assertEquals("myCla", location
1079: .getProperty(Location.LOCATION_EVAL_CONTENT));
1080: }
1081:
1082: public void testCheckLHSLocationDetermination_INSIDE_EVAL4() {
1083: String input = "rule MyRule \n" + " when \n"
1084: + " eval( param.getMetho";
1085: Location location = new CompletionContext(input).getLocation();
1086: assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location
1087: .getType());
1088: assertEquals("param.getMetho", location
1089: .getProperty(Location.LOCATION_EVAL_CONTENT));
1090: }
1091:
1092: public void testCheckLHSLocationDetermination_INSIDE_EVAL5() {
1093: String input = "rule MyRule \n" + " when \n"
1094: + " eval( param.getMethod(";
1095: Location location = new CompletionContext(input).getLocation();
1096: assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location
1097: .getType());
1098: assertEquals("param.getMethod(", location
1099: .getProperty(Location.LOCATION_EVAL_CONTENT));
1100: }
1101:
1102: public void testCheckLHSLocationDetermination_INSIDE_EVAL6() {
1103: String input = "rule MyRule \n" + " when \n"
1104: + " eval( param.getMethod().get";
1105: Location location = new CompletionContext(input).getLocation();
1106: assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location
1107: .getType());
1108: assertEquals("param.getMethod().get", location
1109: .getProperty(Location.LOCATION_EVAL_CONTENT));
1110: }
1111:
1112: public void testCheckLHSLocationDetermination_INSIDE_EVAL7() {
1113: String input = "rule MyRule \n" + " when \n"
1114: + " eval( param.getMethod(\"someStringWith)))\").get";
1115: Location location = new CompletionContext(input).getLocation();
1116: assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location
1117: .getType());
1118: assertEquals("param.getMethod(\"someStringWith)))\").get",
1119: location.getProperty(Location.LOCATION_EVAL_CONTENT));
1120: }
1121:
1122: public void testCheckLHSLocationDetermination_INSIDE_EVAL8() {
1123: String input = "rule MyRule \n" + " when \n"
1124: + " eval( param.getMethod(\"someStringWith(((\").get";
1125: Location location = new CompletionContext(input).getLocation();
1126: assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location
1127: .getType());
1128: assertEquals("param.getMethod(\"someStringWith(((\").get",
1129: location.getProperty(Location.LOCATION_EVAL_CONTENT));
1130: }
1131:
1132: public void testCheckLHSLocationDetermination_INSIDE_EVAL9() {
1133: String input = "rule MyRule \n" + " when \n" + " eval( true )";
1134: Location location = new CompletionContext(input).getLocation();
1135: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1136: .getType());
1137: }
1138:
1139: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION50() {
1140: String input = "rule MyRule \n" + " when \n"
1141: + " eval( param.getProperty(name).isTrue() )";
1142: Location location = new CompletionContext(input).getLocation();
1143: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1144: .getType());
1145: }
1146:
1147: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION51() {
1148: String input = "rule MyRule \n"
1149: + " when \n"
1150: + " eval( param.getProperty(\"someStringWith(((\").isTrue() )";
1151: Location location = new CompletionContext(input).getLocation();
1152: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1153: .getType());
1154: }
1155:
1156: public void testCheckLHSLocationDetermination_INSIDE_EVAL10() {
1157: String input = "rule MyRule \n" + " when \n"
1158: + " eval( param.getProperty((((String) s) )";
1159: Location location = new CompletionContext(input).getLocation();
1160: assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location
1161: .getType());
1162: assertEquals("param.getProperty((((String) s) )", location
1163: .getProperty(Location.LOCATION_EVAL_CONTENT));
1164: }
1165:
1166: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION52() {
1167: String input = "rule MyRule \n" + " when \n"
1168: + " eval( param.getProperty((((String) s))))";
1169: Location location = new CompletionContext(input).getLocation();
1170: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1171: .getType());
1172: }
1173:
1174: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION53() {
1175: String input = "rule MyRule \n" + " when \n"
1176: + " eval( true ) \n" + " ";
1177: Location location = new CompletionContext(input).getLocation();
1178: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1179: .getType());
1180: }
1181:
1182: /** MULTIPLE RESTRICTIONS */
1183: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR12() {
1184: String input = "rule MyRule \n" + " when \n"
1185: + " Class ( property > 0 && ";
1186: Location location = new CompletionContext(input).getLocation();
1187: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
1188: location.getType());
1189: assertEquals("Class", location
1190: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1191: }
1192:
1193: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR13() {
1194: String input = "rule MyRule \n" + " when \n"
1195: + " Class ( name : property1, property2 > 0 && ";
1196: Location location = new CompletionContext(input).getLocation();
1197: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
1198: location.getType());
1199: assertEquals("Class", location
1200: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1201: assertEquals("property2", location
1202: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
1203: }
1204:
1205: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR14() {
1206: String input = "rule MyRule \n" + " when \n"
1207: + " Class ( property1 < 20, property2 > 0 && ";
1208: Location location = new CompletionContext(input).getLocation();
1209: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
1210: location.getType());
1211: assertEquals("Class", location
1212: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1213: assertEquals("property2", location
1214: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
1215: }
1216:
1217: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT20() {
1218: String input = "rule MyRule \n" + " when \n"
1219: + " Class ( property > 0 && < ";
1220: Location location = new CompletionContext(input).getLocation();
1221: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
1222: location.getType());
1223: assertEquals("Class", location
1224: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1225: assertEquals("property", location
1226: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
1227: assertEquals("<", location
1228: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
1229: }
1230:
1231: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END6() {
1232: String input = "rule MyRule \n" + " when \n"
1233: + " Class ( property > 0 && < 10 ";
1234: Location location = new CompletionContext(input).getLocation();
1235: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END,
1236: location.getType());
1237: assertEquals("Class", location
1238: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1239: }
1240:
1241: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START41() {
1242: String input = "rule MyRule \n" + " when \n"
1243: + " Class ( property > 0 && < 10, ";
1244: Location location = new CompletionContext(input).getLocation();
1245: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
1246: location.getType());
1247: assertEquals("Class", location
1248: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1249: }
1250:
1251: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR60() {
1252: String input = "rule MyRule \n" + " when \n"
1253: + " Class ( property > 0 || ";
1254: Location location = new CompletionContext(input).getLocation();
1255: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
1256: location.getType());
1257: assertEquals("Class", location
1258: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1259: assertEquals("property", location
1260: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
1261: }
1262:
1263: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR61() {
1264: String input = "rule MyRule \n" + " when \n"
1265: + " Class ( property > 0 || \n" + " ";
1266: Location location = new CompletionContext(input).getLocation();
1267: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
1268: location.getType());
1269: assertEquals("Class", location
1270: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1271: assertEquals("property", location
1272: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
1273: }
1274:
1275: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR62() {
1276: String input = "rule MyRule \n" + " when \n"
1277: + " Class ( name : property1, property2 > 0 || ";
1278: Location location = new CompletionContext(input).getLocation();
1279: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
1280: location.getType());
1281: assertEquals("Class", location
1282: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1283: assertEquals("property2", location
1284: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
1285: }
1286:
1287: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR63() {
1288: String input = "rule MyRule \n" + " when \n"
1289: + " Class ( property1 < 20, property2 > 0 || ";
1290: Location location = new CompletionContext(input).getLocation();
1291: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
1292: location.getType());
1293: assertEquals("Class", location
1294: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1295: assertEquals("property2", location
1296: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
1297: }
1298:
1299: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END10() {
1300: String input = "rule MyRule \n" + " when \n"
1301: + " Class ( property > 0 ";
1302: Location location = new CompletionContext(input).getLocation();
1303: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END,
1304: location.getType());
1305: }
1306:
1307: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END11() {
1308: String input = "rule MyRule \n" + " when \n"
1309: + " Class ( property > 0 \n" + " ";
1310: Location location = new CompletionContext(input).getLocation();
1311: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END,
1312: location.getType());
1313: }
1314:
1315: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END12() {
1316: String input = "rule MyRule \n" + " when \n"
1317: + " Class ( property > 0 && < 10 ";
1318: Location location = new CompletionContext(input).getLocation();
1319: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END,
1320: location.getType());
1321: }
1322:
1323: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END13() {
1324: String input = "rule MyRule \n" + " when \n"
1325: + " Class ( property > 0 || < 10 ";
1326: Location location = new CompletionContext(input).getLocation();
1327: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END,
1328: location.getType());
1329: }
1330:
1331: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END14() {
1332: String input = "rule MyRule \n" + " when \n"
1333: + " Class ( property == \"test\" || == \"test2\" ";
1334: Location location = new CompletionContext(input).getLocation();
1335: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END,
1336: location.getType());
1337: }
1338:
1339: /** FROM */
1340: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION60() {
1341: String input = "rule MyRule \n" + " when \n"
1342: + " Class ( property > 0 ) ";
1343: Location location = new CompletionContext(input).getLocation();
1344: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1345: .getType());
1346: }
1347:
1348: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION61() {
1349: String input = "rule MyRule \n" + " when \n"
1350: + " Class ( property > 0 ) fr";
1351: Location location = new CompletionContext(input).getLocation();
1352: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1353: .getType());
1354: }
1355:
1356: public void testCheckLHSLocationDetermination_FROM1() {
1357: String input = "rule MyRule \n" + " when \n"
1358: + " Class ( property > 0 ) from ";
1359: Location location = new CompletionContext(input).getLocation();
1360: assertEquals(Location.LOCATION_LHS_FROM, location.getType());
1361: assertEquals("", location
1362: .getProperty(Location.LOCATION_FROM_CONTENT));
1363: }
1364:
1365: public void testCheckLHSLocationDetermination_FROM2() {
1366: String input = "rule MyRule \n" + " when \n"
1367: + " Class ( property > 0 ) from myGlob";
1368: Location location = new CompletionContext(input).getLocation();
1369: assertEquals(Location.LOCATION_LHS_FROM, location.getType());
1370: assertEquals("myGlob", location
1371: .getProperty(Location.LOCATION_FROM_CONTENT));
1372: }
1373:
1374: public void testCheckLHSLocationDetermination_FROM3() {
1375: String input = "rule MyRule \n" + " when \n"
1376: + " Class ( property > 0 ) from myGlobal.get";
1377: Location location = new CompletionContext(input).getLocation();
1378: assertEquals(Location.LOCATION_LHS_FROM, location.getType());
1379: assertEquals("myGlobal.get", location
1380: .getProperty(Location.LOCATION_FROM_CONTENT));
1381: }
1382:
1383: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION75() {
1384: String input = "rule MyRule \n" + " when \n"
1385: + " Class ( property > 0 ) from myGlobal.getList() \n"
1386: + " ";
1387: Location location = new CompletionContext(input).getLocation();
1388: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1389: .getType());
1390: }
1391:
1392: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION71() {
1393: String input = "rule MyRule \n"
1394: + " when \n"
1395: + " Class ( property > 0 ) from getDroolsFunction() \n"
1396: + " ";
1397: Location location = new CompletionContext(input).getLocation();
1398: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1399: .getType());
1400: }
1401:
1402: /** FROM ACCUMULATE */
1403: public void testCheckLHSLocationDetermination_FROM_ACCUMULATE1() {
1404: String input = "rule MyRule \n" + " when \n"
1405: + " Class ( property > 0 ) from accumulate ( ";
1406: Location location = new CompletionContext(input).getLocation();
1407: assertEquals(Location.LOCATION_LHS_FROM_ACCUMULATE, location
1408: .getType());
1409: }
1410:
1411: public void testCheckLHSLocationDetermination_FROM_ACCUMULATE2() {
1412: String input = "rule MyRule \n" + " when \n"
1413: + " Class ( property > 0 ) from accumulate(";
1414: Location location = new CompletionContext(input).getLocation();
1415: assertEquals(Location.LOCATION_LHS_FROM_ACCUMULATE, location
1416: .getType());
1417: }
1418:
1419: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION73() {
1420: String input = "rule MyRule \n" + " when \n"
1421: + " Class ( property > 0 ) from accumulate( \n"
1422: + " $cheese : Cheese( type == $likes ), \n"
1423: + " init( int total = 0; ), \n"
1424: + " action( total += $cheese.getPrice(); ), \n"
1425: + " result( new Integer( total ) ) \n"
1426: + " ) \n" + " ";
1427: Location location = new CompletionContext(input).getLocation();
1428: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1429: .getType());
1430: }
1431:
1432: public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_INIT_INSIDE() {
1433: String input = "rule MyRule \n" + " when \n"
1434: + " Class ( property > 0 ) from accumulate( \n"
1435: + " $cheese : Cheese( type == $likes ), \n"
1436: + " init( ";
1437: Location location = new CompletionContext(input).getLocation();
1438: assertEquals(Location.LOCATION_LHS_FROM_ACCUMULATE_INIT_INSIDE,
1439: location.getType());
1440: assertEquals(
1441: "",
1442: location
1443: .getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT));
1444: }
1445:
1446: public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_ACTION_INSIDE() {
1447: String input = "rule MyRule \n" + " when \n"
1448: + " Class ( property > 0 ) from accumulate( \n"
1449: + " $cheese : Cheese( type == $likes ), \n"
1450: + " init( int total = 0; ), \n" + " action( ";
1451: Location location = new CompletionContext(input).getLocation();
1452: assertEquals(
1453: Location.LOCATION_LHS_FROM_ACCUMULATE_ACTION_INSIDE,
1454: location.getType());
1455: assertEquals(
1456: " int total = 0; ",
1457: location
1458: .getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT));
1459: assertEquals(
1460: "",
1461: location
1462: .getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_ACTION_CONTENT));
1463: }
1464:
1465: public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_RESULT_INSIDE() {
1466: String input = "rule MyRule \n" + " when \n"
1467: + " Class ( property > 0 ) from accumulate( \n"
1468: + " $cheese : Cheese( type == $likes ), \n"
1469: + " init( int total = 0; ), \n"
1470: + " action( total += $cheese.getPrice(); ), \n"
1471: + " result( ";
1472: Location location = new CompletionContext(input).getLocation();
1473: assertEquals(
1474: Location.LOCATION_LHS_FROM_ACCUMULATE_RESULT_INSIDE,
1475: location.getType());
1476: assertEquals(
1477: " int total = 0; ",
1478: location
1479: .getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT));
1480: assertEquals(
1481: " total += $cheese.getPrice(); ",
1482: location
1483: .getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_ACTION_CONTENT));
1484: assertEquals(
1485: "",
1486: location
1487: .getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_RESULT_CONTENT));
1488: }
1489:
1490: public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_INIT_INSIDE2() {
1491: String input = "rule MyRule \n" + " when \n"
1492: + " Class ( property > 0 ) from accumulate( \n"
1493: + " $cheese : Cheese( type == $likes ), \n"
1494: + " init( int total =";
1495: Location location = new CompletionContext(input).getLocation();
1496: assertEquals(Location.LOCATION_LHS_FROM_ACCUMULATE_INIT_INSIDE,
1497: location.getType());
1498: assertEquals(
1499: "int total =",
1500: location
1501: .getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT));
1502: }
1503:
1504: public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_ACTION_INSIDE2() {
1505: String input = "rule MyRule \n" + " when \n"
1506: + " Class ( property > 0 ) from accumulate( \n"
1507: + " $cheese : Cheese( type == $likes ), \n"
1508: + " init( int total = 0; ), \n"
1509: + " action( total += $ch";
1510: Location location = new CompletionContext(input).getLocation();
1511: assertEquals(
1512: Location.LOCATION_LHS_FROM_ACCUMULATE_ACTION_INSIDE,
1513: location.getType());
1514: assertEquals(
1515: " int total = 0; ",
1516: location
1517: .getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT));
1518: assertEquals(
1519: "total += $ch",
1520: location
1521: .getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_ACTION_CONTENT));
1522: }
1523:
1524: public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_RESULT_INSIDE2() {
1525: String input = "rule MyRule \n" + " when \n"
1526: + " Class ( property > 0 ) from accumulate( \n"
1527: + " $cheese : Cheese( type == $likes ), \n"
1528: + " init( int total = 0; ), \n"
1529: + " action( total += $cheese.getPrice(); ), \n"
1530: + " result( new Integer( tot";
1531: Location location = new CompletionContext(input).getLocation();
1532: assertEquals(
1533: Location.LOCATION_LHS_FROM_ACCUMULATE_RESULT_INSIDE,
1534: location.getType());
1535: assertEquals(
1536: " int total = 0; ",
1537: location
1538: .getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT));
1539: assertEquals(
1540: " total += $cheese.getPrice(); ",
1541: location
1542: .getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_ACTION_CONTENT));
1543: assertEquals(
1544: "new Integer( tot",
1545: location
1546: .getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_RESULT_CONTENT));
1547: }
1548:
1549: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START() {
1550: String input = "rule MyRule \n" + " when \n"
1551: + " Class ( property > 0 ) from accumulate( \n"
1552: + " $cheese : Cheese( ";
1553: Location location = new CompletionContext(input).getLocation();
1554: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
1555: location.getType());
1556: assertEquals("Cheese", location
1557: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1558: }
1559:
1560: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR40() {
1561: String input = "rule MyRule \n" + " when \n"
1562: + " Class ( property > 0 ) from accumulate( \n"
1563: + " $cheese : Cheese( type ";
1564: Location location = new CompletionContext(input).getLocation();
1565: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
1566: location.getType());
1567: assertEquals("Cheese", location
1568: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1569: assertEquals("type", location
1570: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
1571: }
1572:
1573: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT() {
1574: String input = "rule MyRule \n" + " when \n"
1575: + " Class ( property > 0 ) from accumulate( \n"
1576: + " $cheese : Cheese( type == ";
1577: Location location = new CompletionContext(input).getLocation();
1578: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
1579: location.getType());
1580: assertEquals("Cheese", location
1581: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1582: assertEquals("type", location
1583: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
1584: }
1585:
1586: /** FROM COLLECT */
1587: public void testCheckLHSLocationDetermination_FROM_COLLECT1() {
1588: String input = "rule MyRule \n" + " when \n"
1589: + " Class ( property > 0 ) from collect ( ";
1590: Location location = new CompletionContext(input).getLocation();
1591: assertEquals(Location.LOCATION_LHS_FROM_COLLECT, location
1592: .getType());
1593: }
1594:
1595: public void testCheckLHSLocationDetermination_FROM_COLLECT2() {
1596: String input = "rule MyRule \n" + " when \n"
1597: + " Class ( property > 0 ) from collect(";
1598: Location location = new CompletionContext(input).getLocation();
1599: assertEquals(Location.LOCATION_LHS_FROM_COLLECT, location
1600: .getType());
1601: }
1602:
1603: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION67() {
1604: String input = "rule MyRule \n" + " when \n"
1605: + " Class ( property > 0 ) from collect ( \n"
1606: + " Cheese( type == $likes )" + " ) \n" + " ";
1607: Location location = new CompletionContext(input).getLocation();
1608: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1609: .getType());
1610: }
1611:
1612: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START31() {
1613: String input = "rule MyRule \n" + " when \n"
1614: + " Class ( property > 0 ) from collect ( \n"
1615: + " Cheese( ";
1616: Location location = new CompletionContext(input).getLocation();
1617: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
1618: location.getType());
1619: assertEquals("Cheese", location
1620: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1621: }
1622:
1623: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR31() {
1624: String input = "rule MyRule \n" + " when \n"
1625: + " Class ( property > 0 ) from collect ( \n"
1626: + " Cheese( type ";
1627: Location location = new CompletionContext(input).getLocation();
1628: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
1629: location.getType());
1630: assertEquals("Cheese", location
1631: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1632: assertEquals("type", location
1633: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
1634: }
1635:
1636: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT21() {
1637: String input = "rule MyRule \n" + " when \n"
1638: + " Class ( property > 0 ) from collect ( \n"
1639: + " Cheese( type == ";
1640: Location location = new CompletionContext(input).getLocation();
1641: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
1642: location.getType());
1643: assertEquals("Cheese", location
1644: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1645: assertEquals("type", location
1646: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
1647: }
1648:
1649: /** NESTED FROM */
1650: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION68() {
1651: String input = "rule MyRule \n"
1652: + " when \n"
1653: + " ArrayList(size > 50) from collect( Person( disabled == \"yes\", income > 100000 ) ";
1654: Location location = new CompletionContext(input).getLocation();
1655: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1656: .getType());
1657: }
1658:
1659: public void testCheckLHSLocationDetermination_FROM5() {
1660: String input = "rule MyRule \n"
1661: + " when \n"
1662: + " ArrayList(size > 50) from collect( Person( disabled == \"yes\", income > 100000 ) from ";
1663: Location location = new CompletionContext(input).getLocation();
1664: assertEquals(Location.LOCATION_LHS_FROM, location.getType());
1665: }
1666:
1667: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION69() {
1668: String input = "rule MyRule \n"
1669: + " when \n"
1670: + " ArrayList(size > 50) from collect( Person( disabled == \"yes\", income > 100000 ) from town.getPersons() )";
1671: Location location = new CompletionContext(input).getLocation();
1672: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1673: .getType());
1674: }
1675:
1676: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION70() {
1677: String input = "rule MyRule \n"
1678: + " when \n"
1679: + " ArrayList(size > 50) from accumulate( Person( disabled == \"yes\", income > 100000 ) ";
1680: Location location = new CompletionContext(input).getLocation();
1681: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1682: .getType());
1683: }
1684:
1685: public void testCheckLHSLocationDetermination_FROM6() {
1686: String input = "rule MyRule \n"
1687: + " when \n"
1688: + " ArrayList(size > 50) from accumulate( Person( disabled == \"yes\", income > 100000 ) from ";
1689: Location location = new CompletionContext(input).getLocation();
1690: assertEquals(Location.LOCATION_LHS_FROM, location.getType());
1691: }
1692:
1693: /** FORALL */
1694: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION81() {
1695: String input = "rule MyRule \n" + " when \n" + " forall ( ";
1696: Location location = new CompletionContext(input).getLocation();
1697: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1698: .getType());
1699: }
1700:
1701: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START32() {
1702: String input = "rule MyRule \n" + " when \n" + " forall ( "
1703: + " Class ( pr";
1704: Location location = new CompletionContext(input).getLocation();
1705: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
1706: location.getType());
1707: assertEquals("Class", location
1708: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1709: assertEquals("pr", location
1710: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
1711: }
1712:
1713: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR32() {
1714: String input = "rule MyRule \n" + " when \n" + " forall ( "
1715: + " Class ( property ";
1716: Location location = new CompletionContext(input).getLocation();
1717: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR,
1718: location.getType());
1719: assertEquals("Class", location
1720: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1721: assertEquals("property", location
1722: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
1723: }
1724:
1725: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT22() {
1726: String input = "rule MyRule \n" + " when \n" + " forall ( "
1727: + " Class ( property == ";
1728: Location location = new CompletionContext(input).getLocation();
1729: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT,
1730: location.getType());
1731: assertEquals("Class", location
1732: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1733: assertEquals("property", location
1734: .getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
1735: assertEquals("==", location
1736: .getProperty(Location.LOCATION_PROPERTY_OPERATOR));
1737: }
1738:
1739: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION76() {
1740: String input = "rule MyRule \n" + " when \n" + " forall ( "
1741: + " Class ( property == \"test\")"
1742: + " C";
1743: Location location = new CompletionContext(input).getLocation();
1744: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1745: .getType());
1746: }
1747:
1748: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION77a() {
1749: String input = "rule MyRule \n"
1750: + " when \n"
1751: + " ArrayList(size > 50) from accumulate( Person( disabled == \"yes\", income > 100000 ) from town.getPersons() ) ";
1752: Location location = new CompletionContext(input).getLocation();
1753: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1754: .getType());
1755: }
1756:
1757: public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION77b() {
1758: String input = "rule MyRule \n"
1759: + " when \n"
1760: + " ArrayList(size > 50) from accumulate( Person( disabled == \"yes\", income > 100000 ) from town.getPersons() )";
1761: Location location = new CompletionContext(input).getLocation();
1762: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1763: .getType());
1764: }
1765:
1766: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START45a() {
1767: String input = "rule MyRule \n" + " when \n"
1768: + " Class ( name :";
1769: Location location = new CompletionContext(input).getLocation();
1770: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
1771: location.getType());
1772: assertEquals("Class", location
1773: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1774: }
1775:
1776: public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START45b() {
1777: String input = "rule MyRule \n" + " when \n"
1778: + " Class ( name : ";
1779: Location location = new CompletionContext(input).getLocation();
1780: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
1781: location.getType());
1782: assertEquals("Class", location
1783: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1784: }
1785:
1786: public void testCheckRHSLocationDetermination_firstLineOfLHS() {
1787: String input = "rule MyRule \n" + " when\n" + " Class ( )\n"
1788: + " then\n" + " ";
1789:
1790: Location location = new CompletionContext(input).getLocation();
1791:
1792: assertEquals(Location.LOCATION_RHS, location.getType());
1793: assertEquals("", location
1794: .getProperty(Location.LOCATION_RHS_CONTENT));
1795: }
1796:
1797: public void testCheckRHSLocationDetermination_startOfNewlINE() {
1798: String input = "rule MyRule \n" + " when\n" + " Class ( )\n"
1799: + " then\n" + " assert(null);\n" + " ";
1800: Location location = new CompletionContext(input).getLocation();
1801: assertEquals(Location.LOCATION_RHS, location.getType());
1802: assertEquals("assert(null);\n ", location
1803: .getProperty(Location.LOCATION_RHS_CONTENT));
1804: }
1805:
1806: public void testCheckRHSLocationDetermination3() {
1807: String input = "rule MyRule \n" + " when\n" + " Class ( )\n"
1808: + " then\n" + " meth";
1809: Location location = new CompletionContext(input).getLocation();
1810: assertEquals(Location.LOCATION_RHS, location.getType());
1811: assertEquals("meth", location
1812: .getProperty(Location.LOCATION_RHS_CONTENT));
1813: }
1814:
1815: public void testCheckRuleHeaderLocationDetermination() {
1816: String input = "rule MyRule ";
1817: Location location = new CompletionContext(input).getLocation();
1818: assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
1819: }
1820:
1821: public void testCheckRuleHeaderLocationDetermination2() {
1822: String input = "rule MyRule \n"
1823: + " salience 12 activation-group \"my";
1824: Location location = new CompletionContext(input).getLocation();
1825: assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
1826: }
1827:
1828: public void FAILINGtestCheckRuleHeaderLocationDetermination3() {
1829: // KRISV: still can't make this work... apparently, ANTLR is trying to recover from
1830: // the error (unkown token) by deleting the token. I don't know why it continues to
1831: // execute actions though, if the EOF is found.
1832: String input = "rule \"Hello World\" ruleflow-group \"hello\" s";
1833: Location location = new CompletionContext(input).getLocation();
1834: assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
1835: }
1836:
1837: public void testCheckRuleHeaderLocationDetermination_dialect1() {
1838: String input = "rule MyRule \n" + " dialect \"java\"";
1839: Location location = new CompletionContext(input).getLocation();
1840: assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
1841: }
1842:
1843: public void testCheckRuleHeaderLocationDetermination_dialect2() {
1844: String input = "rule MyRule \n" + " dialect \"mvel\"";
1845: Location location = new CompletionContext(input).getLocation();
1846: assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
1847: }
1848:
1849: public void testCheckRuleHeaderLocationDetermination_dialect3() {
1850: String input = "rule MyRule \n" + " dialect ";
1851: Location location = new CompletionContext(input).getLocation();
1852: assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
1853: }
1854:
1855: public void testCheckRuleHeaderLocationDetermination_dialect4() {
1856: String input = "rule MyRule \n" + " dialect \"";
1857: Location location = new CompletionContext(input).getLocation();
1858: assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
1859: }
1860:
1861: //TODO: add tests for dialect defined at package header level
1862:
1863: public void testCheckQueryLocationDetermination_RULE_HEADER1() {
1864: String input = "query MyQuery ";
1865: Location location = new CompletionContext(input).getLocation();
1866: assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
1867: }
1868:
1869: public void testCheckQueryLocationDetermination_RULE_HEADER2() {
1870: String input = "query \"MyQuery\" ";
1871: Location location = new CompletionContext(input).getLocation();
1872: assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
1873: }
1874:
1875: public void testCheckQueryLocationDetermination_LHS_BEGIN_OF_CONDITION() {
1876: String input = "query MyQuery() ";
1877: Location location = new CompletionContext(input).getLocation();
1878: assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location
1879: .getType());
1880: }
1881:
1882: public void testCheckQueryLocationDetermination_LHS_INSIDE_CONDITION_START() {
1883: String input = "query MyQuery \n" + " Class (";
1884: Location location = new CompletionContext(input).getLocation();
1885: assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START,
1886: location.getType());
1887: assertEquals("Class", location
1888: .getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
1889: }
1890: }
|