/machinelearning/5.0.x/drools-eclipse/org.drools.eclipse.test/src/test/java/org/drools/eclipse/editors/completion/CompletionContextTest.java

https://github.com/etirelli/droolsjbpm-contributed-experiments · Java · 1118 lines · 980 code · 119 blank · 19 comment · 0 complexity · a600c773d36dcaee101cf22c49f5d3f5 MD5 · raw file

  1. package org.drools.eclipse.editors.completion;
  2. import java.util.Map;
  3. import junit.framework.TestCase;
  4. import org.drools.lang.Location;
  5. /**
  6. * Test to check the location determination when doing code completion inside
  7. * rule condtions.
  8. *
  9. * @author <a href="mailto:kris_verlaenen@hotmail.com">kris verlaenen </a>
  10. *
  11. */
  12. public class CompletionContextTest extends TestCase {
  13. public void testCheckLHSLocationDetermination_RULE_NAME_1() {
  14. String input =
  15. "rule \"MyRule\" ";
  16. assertEquals("MyRule", new CompletionContext(input).getRuleName());
  17. }
  18. public void testCheckLHSLocationDetermination_RULE_NAME_2() {
  19. String input =
  20. "rule \"MyRule\"";
  21. assertEquals("MyRule", new CompletionContext(input).getRuleName());
  22. }
  23. public void testCheckLHSLocationDetermination_RULE_NAME_3() {
  24. String input =
  25. "rule MyRule ";
  26. assertEquals("MyRule", new CompletionContext(input).getRuleName());
  27. }
  28. public void testCheckLHSLocationDetermination_RULE_NAME_4() {
  29. String input =
  30. "rule MyRule";
  31. assertEquals("MyRule", new CompletionContext(input).getRuleName());
  32. }
  33. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION1() {
  34. String input =
  35. "rule MyRule \n" +
  36. " when \n" +
  37. " ";
  38. Location location = new CompletionContext(input).getLocation();
  39. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
  40. assertNull(location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  41. }
  42. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION2() {
  43. String input =
  44. "rule MyRule \n" +
  45. " when \n" +
  46. " Class( condition == true ) \n" +
  47. " ";
  48. Location location = new CompletionContext(input).getLocation();
  49. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
  50. assertNull(location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  51. }
  52. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION3() {
  53. String input =
  54. "rule MyRule \n" +
  55. " when \n" +
  56. " class: Class( condition == true, condition2 == null ) \n" +
  57. " ";
  58. Location location = new CompletionContext(input).getLocation();
  59. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
  60. assertNull(location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  61. }
  62. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION4() {
  63. String input =
  64. "rule MyRule \n" +
  65. " when \n" +
  66. " Cl";
  67. Location location = new CompletionContext(input).getLocation();
  68. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
  69. }
  70. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION5() {
  71. String input =
  72. "rule MyRule \n" +
  73. " when \n" +
  74. " Class( condition == true ) \n" +
  75. " Cl";
  76. Location location = new CompletionContext(input).getLocation();
  77. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
  78. }
  79. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION6() {
  80. String input =
  81. "rule MyRule \n" +
  82. " when \n" +
  83. " class: Cl";
  84. Location location = new CompletionContext(input).getLocation();
  85. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
  86. }
  87. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION7() {
  88. String input =
  89. "rule MyRule \n" +
  90. " when \n" +
  91. " class:Cl";
  92. Location location = new CompletionContext(input).getLocation();
  93. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
  94. }
  95. /** Inside of condition: start */
  96. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START1() {
  97. String input =
  98. "rule MyRule \n" +
  99. " when \n" +
  100. " Class (";
  101. Location location = new CompletionContext(input).getLocation();
  102. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  103. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  104. }
  105. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START2() {
  106. String input =
  107. "rule MyRule \n" +
  108. " when \n" +
  109. " Class ( na";
  110. Location location = new CompletionContext(input).getLocation();
  111. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  112. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  113. assertEquals("na", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  114. }
  115. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START3() {
  116. String input =
  117. "rule MyRule \n" +
  118. " when \n" +
  119. " Class ( name.subProperty['test'].subsu";
  120. Location location = new CompletionContext(input).getLocation();
  121. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  122. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  123. assertEquals("name.subProperty['test'].subsu", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  124. }
  125. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START4() {
  126. String input =
  127. "rule MyRule \n" +
  128. " when \n" +
  129. " Class ( condition == true, ";
  130. Location location = new CompletionContext(input).getLocation();
  131. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  132. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  133. }
  134. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START5() {
  135. String input =
  136. "rule MyRule \n" +
  137. " when \n" +
  138. " Class ( condition == true, na";
  139. Location location = new CompletionContext(input).getLocation();
  140. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  141. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  142. }
  143. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START6() {
  144. String input =
  145. "rule MyRule \n" +
  146. " when \n" +
  147. " Class ( \n" +
  148. " ";
  149. Location location = new CompletionContext(input).getLocation();
  150. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  151. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  152. }
  153. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START7() {
  154. String input =
  155. "rule MyRule \n" +
  156. " when \n" +
  157. " Class ( condition == true, \n" +
  158. " ";
  159. Location location = new CompletionContext(input).getLocation();
  160. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  161. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  162. }
  163. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START8() {
  164. String input =
  165. "rule MyRule \n" +
  166. " when \n" +
  167. " Class ( c: condition, \n" +
  168. " ";
  169. Location location = new CompletionContext(input).getLocation();
  170. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  171. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  172. }
  173. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START9a() {
  174. String input =
  175. "rule MyRule \n" +
  176. " when \n" +
  177. " Class ( name:";
  178. Location location = new CompletionContext(input).getLocation();
  179. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  180. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  181. }
  182. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START9b() {
  183. String input =
  184. "rule MyRule \n" +
  185. " when \n" +
  186. " Class ( name: ";
  187. Location location = new CompletionContext(input).getLocation();
  188. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  189. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  190. }
  191. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START10() {
  192. String input =
  193. "rule MyRule \n" +
  194. " when \n" +
  195. " Class ( name:";
  196. Location location = new CompletionContext(input).getLocation();
  197. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  198. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  199. }
  200. /** Inside of condition: Operator */
  201. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR1() {
  202. String input =
  203. "rule MyRule \n" +
  204. " when \n" +
  205. " Class ( property ";
  206. Location location = new CompletionContext(input).getLocation();
  207. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
  208. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  209. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  210. }
  211. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR2() {
  212. String input =
  213. "rule MyRule \n" +
  214. " when \n" +
  215. " Class(property ";
  216. Location location = new CompletionContext(input).getLocation();
  217. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
  218. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  219. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  220. }
  221. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR3() {
  222. String input =
  223. "rule MyRule \n" +
  224. " when \n" +
  225. " Class ( name : property ";
  226. Location location = new CompletionContext(input).getLocation();
  227. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
  228. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  229. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  230. }
  231. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR4() {
  232. String input =
  233. "rule MyRule \n" +
  234. " when \n" +
  235. " Class (name:property ";
  236. Location location = new CompletionContext(input).getLocation();
  237. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
  238. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  239. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  240. }
  241. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR5() {
  242. String input =
  243. "rule MyRule \n" +
  244. " when \n" +
  245. " Class (name:property ";
  246. Location location = new CompletionContext(input).getLocation();
  247. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
  248. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  249. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  250. }
  251. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR6() {
  252. String input =
  253. "rule MyRule \n" +
  254. " when \n" +
  255. " Class ( name1 : property1, name : property ";
  256. Location location = new CompletionContext(input).getLocation();
  257. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
  258. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  259. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  260. }
  261. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR7() {
  262. String input =
  263. "rule MyRule \n" +
  264. " when \n" +
  265. " Class ( name1 : property1 == \"value\", name : property ";
  266. Location location = new CompletionContext(input).getLocation();
  267. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
  268. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  269. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  270. }
  271. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR8() {
  272. String input =
  273. "rule MyRule \n" +
  274. " when \n" +
  275. " Class ( name1 : property1 == \"value\",property ";
  276. Location location = new CompletionContext(input).getLocation();
  277. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
  278. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  279. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  280. }
  281. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR9() {
  282. String input =
  283. "rule MyRule \n" +
  284. " when \n" +
  285. " Class ( name1 : property1, \n" +
  286. " name : property ";
  287. Location location = new CompletionContext(input).getLocation();
  288. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
  289. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  290. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  291. }
  292. /** Inside of condition: argument */
  293. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT1() {
  294. String input =
  295. "rule MyRule \n" +
  296. " when \n" +
  297. " Class ( property == ";
  298. Location location = new CompletionContext(input).getLocation();
  299. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  300. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  301. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  302. assertEquals("==", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
  303. }
  304. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT2() {
  305. String input =
  306. "rule MyRule \n" +
  307. " when \n" +
  308. " Class ( property== ";
  309. Location location = new CompletionContext(input).getLocation();
  310. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  311. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  312. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  313. assertEquals("==", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
  314. }
  315. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT3() {
  316. String input =
  317. "rule MyRule \n" +
  318. " when \n" +
  319. " Class ( name : property <= ";
  320. Location location = new CompletionContext(input).getLocation();
  321. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  322. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  323. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  324. assertEquals("<=", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
  325. }
  326. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT4() {
  327. String input =
  328. "rule MyRule \n" +
  329. " when \n" +
  330. " Class ( name:property != ";
  331. Location location = new CompletionContext(input).getLocation();
  332. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  333. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  334. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  335. assertEquals("!=", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
  336. }
  337. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT5() {
  338. String input =
  339. "rule MyRule \n" +
  340. " when \n" +
  341. " Class ( name1 : property1, property2 == ";
  342. Location location = new CompletionContext(input).getLocation();
  343. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  344. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  345. assertEquals("property2", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  346. assertEquals("==", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
  347. }
  348. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT6() {
  349. String input =
  350. "rule MyRule \n" +
  351. " when \n" +
  352. " Class (name:property== ";
  353. Location location = new CompletionContext(input).getLocation();
  354. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  355. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  356. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  357. assertEquals("==", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
  358. }
  359. // TODO
  360. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT7() {
  361. String input =
  362. "rule MyRule \n" +
  363. " when \n" +
  364. " Class ( property == otherPropertyN";
  365. Location location = new CompletionContext(input).getLocation();
  366. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  367. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  368. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  369. assertEquals("==", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
  370. }
  371. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT8() {
  372. String input =
  373. "rule MyRule \n" +
  374. " when \n" +
  375. " Class ( property == \"someth";
  376. Location location = new CompletionContext(input).getLocation();
  377. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  378. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  379. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  380. assertEquals("==", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
  381. }
  382. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT9() {
  383. String input =
  384. "rule MyRule \n" +
  385. " when \n" +
  386. " Class ( property contains ";
  387. Location location = new CompletionContext(input).getLocation();
  388. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  389. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  390. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  391. assertEquals("contains", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
  392. }
  393. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT10() {
  394. String input =
  395. "rule MyRule \n" +
  396. " when \n" +
  397. " Class ( property excludes ";
  398. Location location = new CompletionContext(input).getLocation();
  399. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  400. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  401. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  402. assertEquals("excludes", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
  403. }
  404. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT11() {
  405. String input =
  406. "rule MyRule \n" +
  407. " when \n" +
  408. " Class ( property matches \"prop";
  409. Location location = new CompletionContext(input).getLocation();
  410. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  411. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  412. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  413. assertEquals("matches", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
  414. }
  415. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT12() {
  416. String input =
  417. "rule MyRule \n" +
  418. " when \n" +
  419. " Class ( property in ";
  420. Location location = new CompletionContext(input).getLocation();
  421. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  422. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  423. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  424. assertEquals("in", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
  425. }
  426. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END1() {
  427. String input =
  428. "rule MyRule \n" +
  429. " when \n" +
  430. " Class ( property in ('1', '2') ";
  431. Location location = new CompletionContext(input).getLocation();
  432. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, location.getType());
  433. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  434. }
  435. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START11() {
  436. String input =
  437. "rule MyRule \n" +
  438. " when \n" +
  439. " Class ( property in ('1', '2'), ";
  440. Location location = new CompletionContext(input).getLocation();
  441. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  442. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  443. }
  444. // TODO
  445. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT13() {
  446. String input =
  447. "rule MyRule \n" +
  448. " when \n" +
  449. " Class ( property not in ";
  450. Location location = new CompletionContext(input).getLocation();
  451. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  452. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  453. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  454. assertEquals("not in", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
  455. }
  456. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END2() {
  457. String input =
  458. "rule MyRule \n" +
  459. " when \n" +
  460. " Class ( property not in ('1', '2') ";
  461. Location location = new CompletionContext(input).getLocation();
  462. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, location.getType());
  463. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  464. }
  465. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START12() {
  466. String input =
  467. "rule MyRule \n" +
  468. " when \n" +
  469. " Class ( property not in ('1', '2'), ";
  470. Location location = new CompletionContext(input).getLocation();
  471. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  472. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  473. }
  474. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT14() {
  475. String input =
  476. "rule MyRule \n" +
  477. " when \n" +
  478. " Class ( property memberOf ";
  479. Location location = new CompletionContext(input).getLocation();
  480. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  481. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  482. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  483. assertEquals("memberOf", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
  484. }
  485. // TODO
  486. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END3() {
  487. String input =
  488. "rule MyRule \n" +
  489. " when \n" +
  490. " Class ( property memberOf collection ";
  491. Location location = new CompletionContext(input).getLocation();
  492. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, location.getType());
  493. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  494. }
  495. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START13() {
  496. String input =
  497. "rule MyRule \n" +
  498. " when \n" +
  499. " Class ( property memberOf collection, ";
  500. Location location = new CompletionContext(input).getLocation();
  501. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  502. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  503. }
  504. // TODO
  505. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT15() {
  506. String input =
  507. "rule MyRule \n" +
  508. " when \n" +
  509. " Class ( property not memberOf ";
  510. Location location = new CompletionContext(input).getLocation();
  511. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  512. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  513. assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  514. assertEquals("not memberOf", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
  515. }
  516. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END4() {
  517. String input =
  518. "rule MyRule \n" +
  519. " when \n" +
  520. " Class ( property not memberOf collection ";
  521. Location location = new CompletionContext(input).getLocation();
  522. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, location.getType());
  523. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  524. }
  525. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START14() {
  526. String input =
  527. "rule MyRule \n" +
  528. " when \n" +
  529. " Class ( property not memberOf collection, ";
  530. Location location = new CompletionContext(input).getLocation();
  531. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  532. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  533. }
  534. /** EXISTS */
  535. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS1() {
  536. String input =
  537. "rule MyRule \n" +
  538. " when \n" +
  539. " exists ";
  540. Location location = new CompletionContext(input).getLocation();
  541. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
  542. }
  543. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS2() {
  544. String input =
  545. "rule MyRule \n" +
  546. " when \n" +
  547. " exists ( ";
  548. Location location = new CompletionContext(input).getLocation();
  549. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
  550. }
  551. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS3() {
  552. String input =
  553. "rule MyRule \n" +
  554. " when \n" +
  555. " exists(";
  556. Location location = new CompletionContext(input).getLocation();
  557. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
  558. }
  559. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS4() {
  560. String input =
  561. "rule MyRule \n" +
  562. " when \n" +
  563. " exists Cl";
  564. Location location = new CompletionContext(input).getLocation();
  565. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
  566. }
  567. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS5() {
  568. String input =
  569. "rule MyRule \n" +
  570. " when \n" +
  571. " exists ( Cl";
  572. Location location = new CompletionContext(input).getLocation();
  573. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
  574. }
  575. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS6() {
  576. String input =
  577. "rule MyRule \n" +
  578. " when \n" +
  579. " exists ( name : Cl";
  580. Location location = new CompletionContext(input).getLocation();
  581. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
  582. }
  583. public void testCheckLHSLocationDeterminationINSIDE_CONDITION_START16() {
  584. String input =
  585. "rule MyRule \n" +
  586. " when \n" +
  587. " exists Class (";
  588. Location location = new CompletionContext(input).getLocation();
  589. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  590. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  591. }
  592. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION() {
  593. String input =
  594. "rule MyRule \n" +
  595. " when \n" +
  596. " exists Class ( ) \n" +
  597. " ";
  598. Location location = new CompletionContext(input).getLocation();
  599. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
  600. }
  601. /** NOT */
  602. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT1() {
  603. String input =
  604. "rule MyRule \n" +
  605. " when \n" +
  606. " not ";
  607. Location location = new CompletionContext(input).getLocation();
  608. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT, location.getType());
  609. }
  610. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT2() {
  611. String input =
  612. "rule MyRule \n" +
  613. " when \n" +
  614. " not Cl";
  615. Location location = new CompletionContext(input).getLocation();
  616. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT, location.getType());
  617. }
  618. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS7() {
  619. String input =
  620. "rule MyRule \n" +
  621. " when \n" +
  622. " not exists ";
  623. Location location = new CompletionContext(input).getLocation();
  624. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
  625. }
  626. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS8() {
  627. String input =
  628. "rule MyRule \n" +
  629. " when \n" +
  630. " not exists Cl";
  631. Location location = new CompletionContext(input).getLocation();
  632. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
  633. }
  634. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START21() {
  635. String input =
  636. "rule MyRule \n" +
  637. " when \n" +
  638. " not Class (";
  639. Location location = new CompletionContext(input).getLocation();
  640. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  641. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  642. }
  643. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START22() {
  644. String input =
  645. "rule MyRule \n" +
  646. " when \n" +
  647. " not exists Class (";
  648. Location location = new CompletionContext(input).getLocation();
  649. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  650. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  651. }
  652. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START23() {
  653. String input =
  654. "rule MyRule \n" +
  655. " when \n" +
  656. " not exists name : Class (";
  657. Location location = new CompletionContext(input).getLocation();
  658. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  659. assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
  660. }
  661. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION9() {
  662. String input =
  663. "rule MyRule \n" +
  664. " when \n" +
  665. " not Class () \n" +
  666. " ";
  667. Location location = new CompletionContext(input).getLocation();
  668. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
  669. }
  670. /** AND */
  671. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR1() {
  672. String input =
  673. "rule MyRule \n" +
  674. " when \n" +
  675. " Class ( ) and ";
  676. Location location = new CompletionContext(input).getLocation();
  677. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
  678. }
  679. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR2() {
  680. String input =
  681. "rule MyRule \n" +
  682. " when \n" +
  683. " Class ( ) && ";
  684. Location location = new CompletionContext(input).getLocation();
  685. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
  686. }
  687. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR3() {
  688. String input =
  689. "rule MyRule \n" +
  690. " when \n" +
  691. " Class () and ";
  692. Location location = new CompletionContext(input).getLocation();
  693. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
  694. }
  695. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR4() {
  696. String input =
  697. "rule MyRule \n" +
  698. " when \n" +
  699. " name : Class ( name: property ) and ";
  700. Location location = new CompletionContext(input).getLocation();
  701. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
  702. }
  703. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR5() {
  704. String input =
  705. "rule MyRule \n" +
  706. " when \n" +
  707. " Class ( name: property ) \n" +
  708. " and ";
  709. Location location = new CompletionContext(input).getLocation();
  710. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
  711. }
  712. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR6() {
  713. String input =
  714. "rule MyRule \n" +
  715. " when \n" +
  716. " Class ( ) and Cl";
  717. Location location = new CompletionContext(input).getLocation();
  718. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
  719. }
  720. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR7() {
  721. String input =
  722. "rule MyRule \n" +
  723. " when \n" +
  724. " Class ( ) and name : Cl";
  725. Location location = new CompletionContext(input).getLocation();
  726. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
  727. }
  728. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR8() {
  729. String input =
  730. "rule MyRule \n" +
  731. " when \n" +
  732. " Class ( ) && name : Cl";
  733. Location location = new CompletionContext(input).getLocation();
  734. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
  735. }
  736. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION31() {
  737. String input =
  738. "rule MyRule \n" +
  739. " when \n" +
  740. " Class ( ) and Class ( ) \n" +
  741. " ";
  742. Location location = new CompletionContext(input).getLocation();
  743. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
  744. }
  745. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION32() {
  746. String input =
  747. "rule MyRule \n" +
  748. " when \n" +
  749. " Class ( ) and not Class ( ) \n" +
  750. " ";
  751. Location location = new CompletionContext(input).getLocation();
  752. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
  753. }
  754. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION33() {
  755. String input =
  756. "rule MyRule \n" +
  757. " when \n" +
  758. " Class ( ) and exists Class ( ) \n" +
  759. " ";
  760. Location location = new CompletionContext(input).getLocation();
  761. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
  762. }
  763. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START20() {
  764. String input =
  765. "rule MyRule \n" +
  766. " when \n" +
  767. " Class ( ) and Class ( ";
  768. Location location = new CompletionContext(input).getLocation();
  769. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  770. }
  771. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR21() {
  772. String input =
  773. "rule MyRule \n" +
  774. " when \n" +
  775. " Class ( ) and Class ( name ";
  776. Location location = new CompletionContext(input).getLocation();
  777. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
  778. assertEquals("name", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  779. }
  780. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR22() {
  781. String input =
  782. "rule MyRule \n" +
  783. " when \n" +
  784. " Class ( ) and Class ( name == ";
  785. Location location = new CompletionContext(input).getLocation();
  786. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  787. }
  788. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT() {
  789. String input =
  790. "rule MyRule \n" +
  791. " when \n" +
  792. " exists Class ( ) and not ";
  793. Location location = new CompletionContext(input).getLocation();
  794. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT, location.getType());
  795. }
  796. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS() {
  797. String input =
  798. "rule MyRule \n" +
  799. " when \n" +
  800. " exists Class ( ) and exists ";
  801. Location location = new CompletionContext(input).getLocation();
  802. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
  803. }
  804. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION30() {
  805. String input =
  806. "rule MyRule \n" +
  807. " when \n" +
  808. " Class ( ) and not Class ( ) \n" +
  809. " ";
  810. Location location = new CompletionContext(input).getLocation();
  811. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
  812. /** OR */
  813. }
  814. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR21() {
  815. String input =
  816. "rule MyRule \n" +
  817. " when \n" +
  818. " Class ( ) or ";
  819. Location location = new CompletionContext(input).getLocation();
  820. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
  821. }
  822. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR22() {
  823. String input =
  824. "rule MyRule \n" +
  825. " when \n" +
  826. " Class ( ) || ";
  827. Location location = new CompletionContext(input).getLocation();
  828. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
  829. }
  830. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR23() {
  831. String input =
  832. "rule MyRule \n" +
  833. " when \n" +
  834. " Class () or ";
  835. Location location = new CompletionContext(input).getLocation();
  836. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
  837. }
  838. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR24() {
  839. String input =
  840. "rule MyRule \n" +
  841. " when \n" +
  842. " name : Class ( name: property ) or ";
  843. Location location = new CompletionContext(input).getLocation();
  844. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
  845. }
  846. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR25() {
  847. String input =
  848. "rule MyRule \n" +
  849. " when \n" +
  850. " Class ( name: property ) \n" +
  851. " or ";
  852. Location location = new CompletionContext(input).getLocation();
  853. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
  854. }
  855. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR26() {
  856. String input =
  857. "rule MyRule \n" +
  858. " when \n" +
  859. " Class ( ) or Cl";
  860. Location location = new CompletionContext(input).getLocation();
  861. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
  862. }
  863. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR27() {
  864. String input =
  865. "rule MyRule \n" +
  866. " when \n" +
  867. " Class ( ) or name : Cl";
  868. Location location = new CompletionContext(input).getLocation();
  869. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
  870. }
  871. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR28() {
  872. String input =
  873. "rule MyRule \n" +
  874. " when \n" +
  875. " Class ( ) || name : Cl";
  876. Location location = new CompletionContext(input).getLocation();
  877. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
  878. }
  879. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION40() {
  880. String input =
  881. "rule MyRule \n" +
  882. " when \n" +
  883. " Class ( ) or Class ( ) \n" +
  884. " ";
  885. Location location = new CompletionContext(input).getLocation();
  886. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
  887. }
  888. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START40() {
  889. String input =
  890. "rule MyRule \n" +
  891. " when \n" +
  892. " Class ( ) or Class ( ";
  893. Location location = new CompletionContext(input).getLocation();
  894. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
  895. }
  896. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR() {
  897. String input =
  898. "rule MyRule \n" +
  899. " when \n" +
  900. " Class ( ) or Class ( name ";
  901. Location location = new CompletionContext(input).getLocation();
  902. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
  903. assertEquals("name", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
  904. }
  905. public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT30() {
  906. String input =
  907. "rule MyRule \n" +
  908. " when \n" +
  909. " Class ( ) or Class ( name == ";
  910. Location location = new CompletionContext(input).getLocation();
  911. assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
  912. }
  913. public void testCheckLHSLocationDetermination_EGIN_OF_CONDITION_NOT() {
  914. String input =
  915. "rule MyRule \n" +
  916. " when \n" +
  917. " exists Class ( ) or not ";
  918. Location location = new CompletionContext(input).getLocation();
  919. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT, location.getType());
  920. }
  921. public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS40() {
  922. String input =
  923. "rule MyRule \n" +
  924. " when \n" +
  925. " exists Class ( ) or exists ";
  926. Location location = new CompletionContext(input).getLocation();
  927. assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
  928. }
  929. /** EVAL */
  930. public void testCheckLHSLocationDetermination_INSIDE_EVAL1() {
  931. String input =
  932. "rule MyRule \n" +
  933. " when \n" +
  934. " eval ( ";
  935. Location location = new CompletionContext(input).getLocation();
  936. assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());
  937. assertEquals("", location.getProperty(Location.LOCATION_EVAL_CONTENT));
  938. }
  939. public void testCheckLHSLocationDetermination_INSIDE_EVAL2() {
  940. String input =
  941. "rule MyRule \n" +
  942. " when \n" +
  943. " eval(";
  944. Location location = new CompletionContext(input).getLocation();
  945. assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());
  946. assertEquals("", location.getProperty(Location.LOCATION_EVAL_CONTENT));
  947. }
  948. public void testCheckLHSLocationDetermination_INSIDE_EVAL3() {
  949. String input =
  950. "rule MyRule \n" +
  951. " when \n" +
  952. " eval( myCla";
  953. Location location = new CompletionContext(input).getLocation();
  954. assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());
  955. assertEquals("myCla", location.getProperty(Location.LOCATION_EVAL_CONTENT));
  956. }
  957. public void testCheckLHSLocationDetermination_INSIDE_EVAL4() {
  958. String input =
  959. "rule MyRule \n" +
  960. " when \n" +
  961. " eval( param.getMetho";
  962. Location location = new CompletionContext(input).getLocation();
  963. assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());
  964. assertEquals("param.getMetho", location.getProperty(Location.LOCATION_EVAL_CONTENT));
  965. }
  966. public void testCheckLHSLocationDetermination_INSIDE_EVAL5() {
  967. String input =
  968. "rule MyRule \n" +
  969. " when \n" +
  970. " eval( param.getMethod(";
  971. Location location = new CompletionContext(input).getLocation();
  972. assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());
  973. assertEquals("param.getMethod(", location.getProperty(Location.LOCATION_EVAL_CONTENT));
  974. }
  975. public void testCheckLHSLocationDetermination_INSIDE_EVAL6() {
  976. String input =
  977. "rule MyRule \n" +
  978. " when \n" +
  979. " eval( param.getMethod().get";
  980. Location location = new CompletionContext(input).getLocation();
  981. assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());
  982. assertEquals("param.getMethod().get", location.getProperty(Location.LOCATION_EVAL_CONTENT));
  983. }
  984. public void testCheckLHSLocationDetermination_INSIDE_EVAL7() {
  985. String input =
  986. "rule MyRule \n" +
  987. " when \n" +
  988. " eval( param.getMethod(\"someStringWith)))\").get";
  989. Location location = new CompletionContext(input).getLocation();
  990. assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());
  991. assertEquals("param.getMethod(\"someStringWith)))\").get", location.getProperty(Location.LOCATION_EVAL_CONTENT));
  992. }
  993. public void testCheckLHSLocationDetermination_INSIDE_EVAL8() {
  994. String input =
  995. "rule MyRule \n" +
  996. " when \n" +
  997. " eval( param.getMethod(\"someStringWith(((\").get";
  998. Location location = new CompletionContext(input).getLocation();
  999. assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());