1 package org
.argeo
.slc
.core
.test
;
3 import org
.argeo
.slc
.core
.UnsupportedException
;
5 /** Utilities for dealing with test datas. */
6 public class TestDataUtils
{
7 /** Extracts the test data from the given provider. */
8 public static <T
extends TestData
> T
getFromProvider(Object obj
,
9 Class
<T
> clss
, String key
) {
10 if (obj
instanceof TestDataProvider
) {
11 TestDataProvider testDataProvider
= (TestDataProvider
) obj
;
12 return testDataProvider
.getTestData(clss
, key
);
14 throw new UnsupportedException("test data provider", obj
);
19 * Extracts the test data from the given provider using <code>null</code>
22 public static <T
extends TestData
> T
getFromProvider(Object obj
,
24 return getFromProvider(obj
, clss
, null);
28 * Returns it self after making the proper checks. Used for test data being
29 * their own data providers.
31 public static <T
extends TestData
> T
getItSelf(Class
<T
> clss
,
32 TestData testDataObject
) {
33 if (clss
.isAssignableFrom(testDataObject
.getClass())) {
34 return (T
) testDataObject
;
36 throw new UnsupportedException("test data", testDataObject
);
41 /** Makes sure this is an utility class. */
42 private TestDataUtils() {