X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=org.argeo.slc.runtime%2Fsrc%2Forg%2Fargeo%2Fslc%2Fruntime%2Ftest%2FTestDataUtils.java;h=872f1a5ab3bb4acd24a7ec2af0d0e9cd9d0c4de9;hb=d64292c93f4a3532576e98f651344d89e883e2aa;hp=b2d74a7c90aeeaa8fa8f06459d5243c3f23d7e98;hpb=dfac3414a612edd63eaaf8568ddc80271707af22;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/TestDataUtils.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/TestDataUtils.java index b2d74a7c9..872f1a5ab 100644 --- a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/TestDataUtils.java +++ b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/TestDataUtils.java @@ -1,63 +1,48 @@ -/* - * Copyright (C) 2007-2012 Argeo GmbH - * - * 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.argeo.slc.runtime.test; - -import org.argeo.slc.UnsupportedException; -import org.argeo.slc.test.TestData; -import org.argeo.slc.test.TestDataProvider; - -/** Utilities for dealing with test datas. */ -public class TestDataUtils { - /** Extracts the test data from the given provider. */ - public static T getFromProvider(Object obj, - Class clss, String key) { - if (obj instanceof TestDataProvider) { - TestDataProvider testDataProvider = (TestDataProvider) obj; - return testDataProvider.getTestData(clss, key); - } else { - throw new UnsupportedException("test data provider", obj); - } - } - - /** - * Extracts the test data from the given provider using null - * as key. - */ - public static T getFromProvider(Object obj, - Class clss) { - return getFromProvider(obj, clss, null); - } - - /** - * Returns it self after making the proper checks. Used for test data being - * their own data providers. - */ - @SuppressWarnings("unchecked") - public static T getItSelf(Class clss, - TestData testDataObject) { - if (clss.isAssignableFrom(testDataObject.getClass())) { - return (T) testDataObject; - } else { - throw new UnsupportedException("test data", testDataObject); - } - - } - - /** Makes sure this is an utility class. */ - private TestDataUtils() { - - } -} +package org.argeo.slc.runtime.test; + +import org.argeo.slc.UnsupportedException; +import org.argeo.slc.test.TestData; +import org.argeo.slc.test.TestDataProvider; + +/** Utilities for dealing with test datas. */ +public class TestDataUtils { + /** Extracts the test data from the given provider. */ + public static T getFromProvider(Object obj, + Class clss, String key) { + if (obj instanceof TestDataProvider) { + TestDataProvider testDataProvider = (TestDataProvider) obj; + return testDataProvider.getTestData(clss, key); + } else { + throw new UnsupportedException("test data provider", obj); + } + } + + /** + * Extracts the test data from the given provider using null + * as key. + */ + public static T getFromProvider(Object obj, + Class clss) { + return getFromProvider(obj, clss, null); + } + + /** + * Returns it self after making the proper checks. Used for test data being + * their own data providers. + */ + @SuppressWarnings("unchecked") + public static T getItSelf(Class clss, + TestData testDataObject) { + if (clss.isAssignableFrom(testDataObject.getClass())) { + return (T) testDataObject; + } else { + throw new UnsupportedException("test data", testDataObject); + } + + } + + /** Makes sure this is an utility class. */ + private TestDataUtils() { + + } +}