use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.
the class ScanRequestConverterTest method testScanPathIsIncluded.
@Test
public void testScanPathIsIncluded() throws Exception {
// Act - convert mapping bean to scan request (with the default set-up)
final ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
// Assert
assertEquals(scanRequest.getCompoundModel().getModels().get(0), scanPath);
// Act again - convert scan request back to mapping bean
scanRequestConverter.mergeIntoMappingBean(scanRequest, newMappingBean);
// Assert again
assertEquals(newMappingBean.getScanDefinition().getMappingScanRegion().getScanPath(), scanPath);
}
use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.
the class ScanRequestConverterTest method testBeamSizeScannableIncluded.
@Test
public void testBeamSizeScannableIncluded() throws Exception {
ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
assertTrue(scanRequest.getMonitorNamesPerScan().contains(BEAM_SIZE_NAME));
mappingStageInfo.setBeamSize(null);
scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
assertFalse(scanRequest.getMonitorNamesPerScan().contains(BEAM_SIZE_NAME));
}
use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.
the class ScanRequestConverterTest method testBeamlineConfigurationIncludedCorrectly.
@Test
public void testBeamlineConfigurationIncludedCorrectly() throws Exception {
// Arrange
final Map<String, Object> beamlineConfiguration = new HashMap<>();
beamlineConfiguration.put("energy", 12345.67);
beamlineConfiguration.put("attenuator_pos", "Gap");
beamlineConfiguration.put("kb_mirror_pos", 7.0);
mappingBean.setBeamlineConfiguration(beamlineConfiguration);
// Act - convert mapping bean to scan request
final ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
// Assert
final IPosition startPos = scanRequest.getStartPosition();
assertThat(startPos.getNames().size(), is(equalTo(beamlineConfiguration.size())));
for (String scannableName : beamlineConfiguration.keySet()) {
assertThat(startPos.get(scannableName), is(equalTo(beamlineConfiguration.get(scannableName))));
}
// Act again - convert scan request back to a mapping bean
scanRequestConverter.mergeIntoMappingBean(scanRequest, newMappingBean);
// Assert - the new beamline configuration should be equal to the original one
final Map<String, Object> newBeamlineConfiguration = newMappingBean.getBeamlineConfiguration();
assertThat(newBeamlineConfiguration, is(notNullValue()));
assertThat(newBeamlineConfiguration, is(equalTo(beamlineConfiguration)));
}
use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.
the class ScanRequestConverterTest method testOuterScannableAddedToMappingBeanIfNotThereAlready.
@Test
public void testOuterScannableAddedToMappingBeanIfNotThereAlready() {
// Arrange
final IScanPointGeneratorModel outerModel = new AxialStepModel(Z_AXIS_NAME, -3, 2, 0.5);
final List<IScanModelWrapper<IScanPointGeneratorModel>> outerScannables = Arrays.asList(new ScanPathModelWrapper(Z_AXIS_NAME, outerModel, true));
mappingBean.getScanDefinition().setOuterScannables(outerScannables);
// Act - convert mapping bean to scan request
final ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
// Creates a new wrapper for the outer scannable in newMappingBean
scanRequestConverter.mergeIntoMappingBean(scanRequest, newMappingBean);
assertThat(newMappingBean.getScanDefinition().getOuterScannables(), contains(outerScannables.toArray()));
}
use of org.eclipse.scanning.api.event.scan.ScanRequest in project gda-core by openGDA.
the class ScanRequestConverterTest method testNullTemplateListInScanRequest.
@Test
public void testNullTemplateListInScanRequest() {
final String first = "first.yaml";
final String second = "second.yaml";
final TemplateFileWrapper firstWrapper = new TemplateFileWrapper(first, true);
final TemplateFileWrapper secondWrapper = new TemplateFileWrapper(second, true);
mappingBean.setTemplateFiles(Arrays.asList(firstWrapper, secondWrapper));
final ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
scanRequest.setTemplateFilePaths(null);
assertNull(scanRequest.getTemplateFilePaths());
scanRequestConverter.mergeIntoMappingBean(scanRequest, mappingBean);
// Merging a null list of file paths should deactivate (but not delete) all files in the mapping bean
final List<TemplateFileWrapper> templateFiles = mappingBean.getTemplateFiles();
assertEquals(2, templateFiles.size());
assertContainsWrapper(templateFiles, first, false);
assertContainsWrapper(templateFiles, second, false);
}
Aggregations