1 package org
.argeo
.slc
.runtime
.test
;
3 import org
.argeo
.api
.slc
.UnsupportedException
;
4 import org
.argeo
.api
.slc
.test
.TestData
;
5 import org
.argeo
.api
.slc
.test
.TestDataProvider
;
7 /** Utilities for dealing with test datas. */
8 public class TestDataUtils
{
9 /** Extracts the test data from the given provider. */
10 public static <T
extends TestData
> T
getFromProvider(Object obj
,
11 Class
<T
> clss
, String key
) {
12 if (obj
instanceof TestDataProvider
) {
13 TestDataProvider testDataProvider
= (TestDataProvider
) obj
;
14 return testDataProvider
.getTestData(clss
, key
);
16 throw new UnsupportedException("test data provider", obj
);
21 * Extracts the test data from the given provider using <code>null</code>
24 public static <T
extends TestData
> T
getFromProvider(Object obj
,
26 return getFromProvider(obj
, clss
, null);
30 * Returns it self after making the proper checks. Used for test data being
31 * their own data providers.
33 @SuppressWarnings("unchecked")
34 public static <T
extends TestData
> T
getItSelf(Class
<T
> clss
,
35 TestData testDataObject
) {
36 if (clss
.isAssignableFrom(testDataObject
.getClass())) {
37 return (T
) testDataObject
;
39 throw new UnsupportedException("test data", testDataObject
);
44 /** Makes sure this is an utility class. */
45 private TestDataUtils() {