/**
* Copyright 1999-2009 The Pegadi Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pegadi.sources.search;
import junit.framework.TestCase;
public class CategoryTermTest extends TestCase {
CategoryTerm termRef;
CategoryTerm termPattern;
public void setUp() {
termRef = new CategoryTerm(2);
termPattern = new CategoryTerm("something");
}
public void testGetQueryByRef() {
String query = "SELECT Source_person.ID FROM Source_person, Source_Category, Source_Category_MemberShip WHERE (Source_Category_MemberShip.sourceID = Source_person.ID AND Source_Category_MemberShip.categoryID = Source_Category.ID AND Source_Category.ID = 2)";
assertEquals(query, termRef.getQuery("Source_person.ID"));
}
public void testGetQueryByPattern() {
String query = "SELECT Source_person.ID FROM Source_person, Source_Category, Source_Category_MemberShip WHERE (Source_Category_MemberShip.sourceID = Source_person.ID AND Source_Category_MemberShip.categoryID = Source_Category.ID AND Source_Category.name like '%something%')";
assertEquals(query, termPattern.getQuery("Source_person.ID"));
}
}