Package gda
Class TestHelpers
java.lang.Object
gda.TestHelpers
Collection of utility functions to assist testing.
-
Method Summary
Modifier and TypeMethodDescriptionstatic DetectorcreateTestCounterTimer(String name, Object position, String[] extraNames, String[] inputNames, int level, String[] outputFormat, NexusGroupData data, String filename, String description, String detectorID, String detectorType, String[] channelNames) static DetectorcreateTestDetector(String name, Object position, String[] extraNames, String[] inputNames, int level, String[] outputFormat, NexusGroupData data, String filename, String description, String detectorID, String detectorType) static Factorystatic DetectorcreateTestFileDetector(String name, int level, String fileNameFormat, int[] dim, String description, String detectorID, String detectorType) static NexusDetectorcreateTestISubDetector(String name, Object position, String[] extraNames, String[] inputNames, int level, String[] outputFormat, NexusGroupData data, String filename, String description, String detectorID, String detectorType) static NexusGroupDatacreateTestNexusGroupData(Class<? extends org.eclipse.january.dataset.Dataset> clazz, int[] shape, boolean useSuperToString) static ScannablecreateTestScannable(String name, Object position, String[] extraNames, String[] inputNames, int level, String[] outputFormat, String[] units) static ScannablecreateTestScannableGaussianXY(String name, Double xPosition, String xName, String yName, Double center, Double width, Double magnitude, Double pcNoise, int level, String outputFormatx, String outputFormaty, String unitsx, String unitsy) static ScannablecreateTestScannableSine(String name, Double xPosition, Double magnitude, Double pcNoise, String xName, String yName, int level, String outputFormatx, String outputFormaty, String unitsx, String unitsy) static final <T> TdeserialiseDocument(String resourcePath, Class<T> documentClass) Deserialise a simple class from a JSON document.static StringSets up of environment for the a test Set property so that output is to Nexus format file Uses MockJythonServerFacade and MockJythonServer to configure InterfaceProviderstatic StringsetUpTest(Class<?> testClass, String nameOfTest, boolean makedir, Class<? extends DataWriter> dataWriterClass)
-
Method Details
-
setUpTest
public static String setUpTest(Class<?> testClass, String nameOfTest, boolean makedir) throws Exception Sets up of environment for the a test Set property so that output is to Nexus format file Uses MockJythonServerFacade and MockJythonServer to configure InterfaceProvider- Parameters:
testClass- e.g. gda.data.nexus.ScanToNexusTestnameOfTest- name of test method which the testClass e.g. testCreateScanFilemakedir- if true the scratch dir is deleted and constructed- Returns:
- The directory into which output will be sent
- Throws:
Exception- if setup fails
-
setUpTest
public static String setUpTest(Class<?> testClass, String nameOfTest, boolean makedir, Class<? extends DataWriter> dataWriterClass) throws Exception - Throws:
Exception
-
createTestScannable
-
createTestScannableGaussianXY
-
createTestScannableSine
-
createTestDetector
-
createTestCounterTimer
-
createTestFileDetector
-
createTestISubDetector
-
createTestNexusGroupData
public static NexusGroupData createTestNexusGroupData(Class<? extends org.eclipse.january.dataset.Dataset> clazz, int[] shape, boolean useSuperToString) -
createTestFactory
- Returns:
- Factory implementation that can be used for testing - simply add findables and add to Finder instance
-
deserialiseDocument
public static final <T> T deserialiseDocument(String resourcePath, Class<T> documentClass) throws GDAException Deserialise a simple class from a JSON document. The class should not require custom deserialiser.- Type Parameters:
T- theClassof the object to deserialise- Parameters:
resourcePath- the source relative path where the file isdocumentClass- theClassrepresenting the document to deserialise- Returns:
- the deserialised object class
- Throws:
GDAException- if anIOExceptionoccours
-