use of org.eclipse.scanning.api.points.IPointGeneratorService in project gda-core by openGDA.
the class ScanRequestConverterTest method testRoiAxisNamesAreSet.
@Test
public void testRoiAxisNamesAreSet() throws Exception {
IPointGeneratorService pointGeneratorService = new PointGeneratorService();
// Act - convert mapping bean to scan request
final ScanRequest scanRequest = scanRequestConverter.convertToScanRequest(mappingBean);
final Collection<ScanRegion> regions = scanRequest.getCompoundModel().getRegions();
// Assert - ensure only one region
assertThat(regions.size(), is(equalTo(1)));
for (final ScanRegion scanRegion : regions) {
final List<String> scannables = scanRegion.getScannables();
final RectangularROI roi = (RectangularROI) scanRegion.getRoi();
/* Post DAQ-2739, this ensures if x-y axes of regions are flipped again it will be noticed either here or in the num of point
* [n.b. shortly before 2739, Regions were not passed to CompoundModels, then they were but reflected, which broke scanning]
*/
assertThat(scannables.get(0), is(equalTo(X_AXIS_NAME)));
assertThat(scannables.get(1), is(equalTo(Y_AXIS_NAME)));
assertEquals(X_START, roi.getPoint()[0], DIFF_LIMIT);
assertEquals(Y_START, roi.getPoint()[1], DIFF_LIMIT);
assertEquals(X_LENGTH, roi.getLengths()[0], DIFF_LIMIT);
assertEquals(Y_LENGTH, roi.getLengths()[1], DIFF_LIMIT);
}
// Act again - convert scan request back to mapping bean
scanRequestConverter.mergeIntoMappingBean(scanRequest, newMappingBean);
assertEquals(mappingBean.getScanDefinition().getMappingScanRegion().getRegion(), newMappingBean.getScanDefinition().getMappingScanRegion().getRegion());
List<IPosition> allPositions = pointGeneratorService.createCompoundGenerator(scanRequest.getCompoundModel()).createPoints();
assertEquals(25, allPositions.size());
}
Aggregations