⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hibernateormappingtests.java

📁 一个hibernate的自动测试框架源码
💻 JAVA
字号:
/*
 * Copyright (c) 2005 Chris Richardson
 * 
 * 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 net.chrisrichardson.ormunit.hibernate;

import java.util.Collections;
import java.util.Set;

import net.chrisrichardson.ormunit.PropertyNameSet;

import org.hibernate.MappingException;
import org.hibernate.PropertyNotFoundException;

/**
 * Base class for writing tests that make assertions about a Hibernate O/R
 * mapping document.
 * 
 * @author cer
 * 
 */
public abstract class HibernateORMappingTests extends AbstractORMappingTests {

	protected ComponentPropertyMapping getComponentPropertyMapping(String propertyName)
			throws MappingException {
		return classChecker.getComponentPropertyMapping(propertyName);
	}

	protected void assertAllPropertiesMapped() throws MappingException {
		classChecker.assertAllPropertiesMappedExcept(Collections.EMPTY_SET);
	}

	protected void assertAllPropertiesMappedExcept(Set propertyNames)
			throws MappingException {
		classChecker.assertAllPropertiesMappedExcept(propertyNames);
	}

	protected void assertCompositeListProperty(String propertyName)
			throws MappingException {
		classChecker.assertCompositeListProperty(propertyName);
	}

	protected ListPropertyMapping assertListProperty(String propertyName)
			throws MappingException {
		return classChecker.assertListProperty(propertyName);
	}

	protected CompositeListPropertyMapping getCompositeListPropertyMapping(
			String propertyName) throws MappingException {
		return classChecker.getCompositeListPropertyMapping(propertyName);
	}

	protected ListPropertyMapping getListPropertyMapping(String propertyName)
			throws MappingException {
		return classChecker.getListPropertyMapping(propertyName);
	}

	protected void assertComponentProperty(String propertyName)
			throws MappingException {
		classChecker.assertComponentProperty(propertyName);
	}

	protected void assertSetProperty(String propertyName) throws MappingException {
		classChecker.assertSetProperty(propertyName);
	}

	protected ToOnePropertyMapping assertManyToOneProperty(String propertyName,
			String foreignKeyColumnName) throws MappingException {
		return classChecker.assertManyToOneProperty(propertyName,
		foreignKeyColumnName);
	}

	protected void assertVersionProperty(String propertyName, String columnName) {
		classChecker.assertVersionProperty(propertyName, columnName);
	}

	protected void assertIdProperty(String idProperty, String idColumn)
			throws PropertyNotFoundException, MappingException {
		classChecker.assertIdProperty(idProperty, idColumn);
	}

	protected void assertProperty(String propertyName, String columnName)
			throws MappingException {
		classChecker.assertProperty(propertyName, columnName);
	}

	protected void assertProperty(String propertyName, String columnName,
			Class fieldType) {
		classChecker.assertProperty(propertyName, columnName, fieldType);
	}

	protected void assertOneToManyListProperty(String propertyName,
			String foreignKeyColumn, String indexColumn)
			throws MappingException {
		classChecker.assertOneToManyListProperty(propertyName, foreignKeyColumn,
		indexColumn);
	}

	protected void assertAllPropertiesMappedExcept(String field1, String field2,
			String field3) throws MappingException {
		classChecker.assertAllPropertiesMappedExcept(field1, field2, field3);
	}

	protected void assertAllPropertiesMappedExcept(String field1, String field2)
			throws MappingException {
		classChecker.assertAllPropertiesMappedExcept(field1, field2);
	}

	protected void assertAllPropertiesMappedExcept(String field1)
			throws MappingException {
		classChecker.assertAllPropertiesMappedExcept(field1);
	}

	protected CompositeSetPropertyMapping getCompositeSetPropertyMapping(String propertyName) {
		return classChecker.getCompositeSetPropertyMapping(propertyName);
	}

	protected PropertyNameSet makePropertyNameSet(Class type, String field) {
		return PropertyNameSet.makePropertyNameSet(type, field);
	}

	protected void assertAllClassesMapped(PropertyNameSet set) {
		assertAllClassesMapped(set.asSet());
	}

	protected PropertyNameSet except(Class type, String name) {
		return PropertyNameSet.except(type, name);
	}

	protected PropertyNameSet except(String propertyName) {
		return PropertyNameSet.except(propertyName);
	}

	protected void assertAllPropertiesMapped(PropertyNameSet set) {
		assertAllPropertiesMappedExcept(set.asSet());
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -