All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.testing.orm.junit.JUnitHelper Maven / Gradle / Ivy

There is a newer version: 5.6.15.Final
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later
 * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
 */
package org.hibernate.testing.orm.junit;

import org.junit.jupiter.api.extension.Extension;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ParameterContext;

import static org.junit.jupiter.api.extension.ExtensionContext.Namespace.create;

/**
 * @author Steve Ebersole
 */
public class JUnitHelper {
	public static ExtensionContext.Store locateExtensionStore(
			Class extensionClass,
			ExtensionContext context,
			Object scopeObject) {
		return context.getStore( create( extensionClass.getName(), scopeObject ) );
	}

	public static ExtensionContext.Store locateExtensionStore(
			ExtensionContext context,
			Object... scopeRefs) {
		return context.getStore( create( scopeRefs ) );
	}

	private JUnitHelper() {
	}

	public static boolean supportsParameterInjection(ParameterContext parameterContext, Class... supportedTypes) {
		for ( Class supportedType : supportedTypes ) {
			if ( parameterContext.getParameter().getType().isAssignableFrom( supportedType ) ) {
				return true;
			}
		}

		return false;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy