package org.ovirt.engine.core.searchbackend;

import java.util.Arrays;
import java.util.List;

import junit.framework.TestCase;

/**
 * this is the main test class for the BaseConditionFieldAutoCompleter class
 *
 */
public class AdGroupConditionFieldAutoCompleterTest extends TestCase {
    public void testEmpty() {
        IConditionFieldAutoCompleter comp = new AdGroupConditionFieldAutoCompleter();
        List<String> comps = Arrays.asList(comp.getCompletion(""));
        System.out.println(comps);
        assertTrue("name", comps.contains("name"));
        assertFalse("False", comps.contains("False"));
    }

    public void testValidateFieldValue() {
        IConditionFieldAutoCompleter comp = new AdGroupConditionFieldAutoCompleter();
        assertTrue("Jar Jar", comp.validateFieldValue("NAME", "Jar Jar"));
        assertTrue("1234", comp.validateFieldValue("NAME", "1234"));
        assertFalse("<>", comp.validateFieldValue("NAME", "<>"));
        assertTrue("Invalid Field", comp.validateFieldValue("NAME222", "Jar Jar"));
        assertTrue("Lowercase Field", comp.validateFieldValue("name", "<>"));
    }

    public void testGetDbFieldName() {
        IConditionFieldAutoCompleter comp = new AdGroupConditionFieldAutoCompleter();
        assertEquals("$CN", "$CN", comp.getDbFieldName("NAME"));
        assertNull("name", comp.getDbFieldType("name"));
        assertNull("22", comp.getDbFieldType("22"));
    }

    public void testGetDbFieldType() {
        IConditionFieldAutoCompleter comp = new AdGroupConditionFieldAutoCompleter();
        assertEquals("NAME", String.class, comp.getDbFieldType("NAME"));
        assertNull("name", comp.getDbFieldType("name"));
        assertNull("22", comp.getDbFieldType("22"));
    }

    public void testBuildFreeTextConditionSql() {
        IConditionFieldAutoCompleter comp = new AdGroupConditionFieldAutoCompleter();
        String sql = comp.buildFreeTextConditionSql("ATable", "=", "JarJar", false);
        assertEquals(" (  ATable.$CN LIKE '%JarJar%' ) ", " (  ATable.$CN LIKE '%JarJar%' ) ", sql);
        sql = comp.buildFreeTextConditionSql("ATable", "!=", "JarJar", false);
        assertEquals(" (  ATable.$CN NOT LIKE '%JarJar%' ) ", " (  ATable.$CN NOT LIKE '%JarJar%' ) ", sql);
    }
}

@@ -39,16 +39,192 @@
 ckend;%0A%0A
+import static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertNull;%0Aimport static org.junit.Assert.assertTrue;%0A%0A
 import j
@@ -275,32 +275,22 @@
 ort 
+org.
 junit.
-framework.TestCase
+Test
 ;%0A%0A/
@@ -373,11 +373,8 @@
 ass%0A
- *%0A
  */%0A
@@ -429,26 +429,20 @@
 est 
-extends TestCase %7B
+%7B%0A%0A    @Test
 %0A   
@@ -763,32 +763,42 @@
 alse%22));%0A    %7D%0A%0A
+    @Test%0A
     public void 
@@ -1281,32 +1281,42 @@
  %22%3C%3E%22));%0A    %7D%0A%0A
+    @Test%0A
     public void 
@@ -1598,32 +1598,42 @@
 (%2222%22));%0A    %7D%0A%0A
+    @Test%0A
     public void 
@@ -1927,24 +1927,34 @@
 %22));%0A    %7D%0A%0A
+    @Test%0A
     public v

Use Junit annotations in AdGroupConditionFieldAutoCompleterTest