use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.
the class ScanRequestConverterTest method testDetectorIsExcludedCorrectly.
@Test
public void testDetectorIsExcludedCorrectly() throws Exception {
// Arrange
final String displayName = "Mandelbrot Detector";
final IDetectorModel detModel = new MandelbrotModel();
mappingBean.setDetectorParameters(Arrays.asList(new DetectorModelWrapper(displayName, detModel, false)));
// Act - convert mapping bean to scan request
final ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
// Assert
assertThat(scanRequest.getDetectors().entrySet(), is(empty()));
// Act again - merge the scan request back into the same mapping bean
scanRequestConverter.mergeIntoMappingBean(scanRequest, mappingBean);
// Assert again - check the mapping bean is the same as the original
List<IScanModelWrapper<IDetectorModel>> newDetectorParams = mappingBean.getDetectorParameters();
assertThat(newDetectorParams.size(), is(1));
IScanModelWrapper<IDetectorModel> wrapper = newDetectorParams.get(0);
assertThat(wrapper.getName(), is(equalTo(displayName)));
// names must be same, i.e. mandlebrot
assertThat(wrapper.getModel(), is(equalTo(detModel)));
assertThat(wrapper.isIncludeInScan(), is(false));
}
use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.
the class ScanRequestConverterTest method testDetectorIsIncludedCorrectly.
@Test
public void testDetectorIsIncludedCorrectly() throws Exception {
// Arrange
final String detName = "mandelbrot";
final String displayName = "Mandelbrot Detector";
final IDetectorModel detModel = new MandelbrotModel();
detModel.setName(detName);
mappingBean.setDetectorParameters(Arrays.asList(new DetectorModelWrapper(displayName, detModel, true)));
// Act - convert mapping bean to scan request
final ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
// Assert
assertEquals(detModel, scanRequest.getDetectors().get(detName));
// Act again - convert scan request back to mapping bean
((DetectorModelWrapper) mappingBean.getDetectorParameters().get(0)).setIncludeInScan(false);
scanRequestConverter.mergeIntoMappingBean(scanRequest, mappingBean);
// Assert - check the new mapping bean is the same as the original
List<IScanModelWrapper<IDetectorModel>> newDetectorParams = mappingBean.getDetectorParameters();
assertThat(newDetectorParams.size(), is(1));
IScanModelWrapper<IDetectorModel> wrapper = newDetectorParams.get(0);
assertThat(wrapper.getName(), is(equalTo(displayName)));
assertThat(wrapper.getModel(), is(equalTo(detModel)));
assertThat(wrapper.isIncludeInScan(), is(true));
}
use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.
the class ScanRequestConverterTest method testMonitorNameSetCorrectly.
@Test
public void testMonitorNameSetCorrectly() throws Exception {
// Arrange
final Set<String> perPointMonitorNames = mappingBean.getPerPointMonitorNames();
final Set<String> perScanMonitorNames = mappingBean.getPerScanMonitorNames();
// Act - convert mapping bean to scan request
ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
// Assert
assertEquals(perPointMonitorNames, scanRequest.getMonitorNamesPerPoint());
Set<String> expectedPerScanMonitorNames = new HashSet<>(perScanMonitorNames);
expectedPerScanMonitorNames.add(BEAM_SIZE_NAME);
assertEquals(expectedPerScanMonitorNames, scanRequest.getMonitorNamesPerScan());
}
use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.
the class ScanRequestFactoryTest method testNotEmptyTemplateFile.
@Test
public void testNotEmptyTemplateFile() throws Exception {
IMalcolmModel model = Mockito.mock(IMalcolmModel.class);
when(detectorModel.getModel()).thenReturn(model);
ScanningAcquisition scanningAcquisition = loadScanningAcquisition();
URL file1 = new URL("file:/lev1/lev2");
URL file2 = new URL("file:/lev3/lev4");
List<URL> paths = new ArrayList<>();
paths.add(file1);
paths.add(file2);
ApplyNexusTemplatesRequest request = (new ApplyNexusTemplatesRequest.Builder()).withValue(paths).build();
scanningAcquisition.getAcquisitionConfiguration().setProcessingRequest(new ArrayList<>());
scanningAcquisition.getAcquisitionConfiguration().getProcessingRequest().add(request);
ScanRequestFactory scanRequestFactory = new ScanRequestFactory(scanningAcquisition);
ScanRequest scanRequest = scanRequestFactory.createScanRequest(runnableService);
Assert.assertEquals(2, scanRequest.getTemplateFilePaths().size());
}
use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.
the class ApplyNexusTemplateTest method testApplyNexusTemplateRequest.
@Test
public void testApplyNexusTemplateRequest() throws Exception {
ProcessingRequestHandler handler = new ApplyNexusTemplateHandler();
List<URL> paths = new ArrayList<>();
paths.add(file1);
paths.add(file2);
ApplyNexusTemplatesRequest request = new ApplyNexusTemplatesRequest.Builder().withValue(paths).build();
ScanRequest scanRequest = new ScanRequest();
scanRequest.setProcessingRequest(new ProcessingRequest());
scanRequest.getProcessingRequest().setRequest(new HashMap<>());
handler.handle(request, scanRequest);
Set<String> translated = scanRequest.getTemplateFilePaths();
Assert.assertEquals(2, translated.size());
Assert.assertTrue(translated.contains(file1.getPath()));
Assert.assertTrue(translated.contains(file2.getPath()));
}
Aggregations