Search in sources :

Example 1 with ScanRequestBuilder

use of org.eclipse.scanning.sequencer.ScanRequestBuilder in project gda-core by openGDA.

the class MScanSubmitterTest method createsCorrectProcessorListForReRunFromFileAndSubmits.

@Test
public void createsCorrectProcessorListForReRunFromFileAndSubmits() throws Exception {
    Object[] arr = { Action.RERUN, TEST_FILE };
    doNothing().when(theFacadeInstance).runCommand(anyString());
    try (final MockedStatic<ScanRequestBuilder> scanBuilder = mockStatic(ScanRequestBuilder.class)) {
        ScanRequest request = new ScanRequest();
        request.setCompoundModel(getCompoundModel(grid, circle));
        scanBuilder.when(() -> ScanRequestBuilder.buildFromNexusFile(TEST_FILE)).thenReturn(Optional.of(request));
        builder.buildAndSubmitBlockingScanRequest(arr);
    }
    List<IClauseElementProcessor> processors = captor.getValue();
    assertThat(processors.size(), is(1));
    assertThat(processors.get(0), instanceOf(ReRunFromFileElementProcessor.class));
    assertThat(processors.get(0).getElement(), is(TEST_FILE));
    assertThat(processors.get(0).getElementValue(), is(TEST_FILE));
    verify(eventSubscriber).addListener(any(IScanListener.class));
    verify(submitter).blockingSubmit(beanCaptor.capture());
    ScanBean bean = beanCaptor.getValue();
    assertThat(bean.getScanRequest().getCompoundModel(), is(equalTo(getBoundedCompoundModel(grid, circle))));
}
Also used : ScanRequest(org.eclipse.scanning.api.event.scan.ScanRequest) IScanListener(org.eclipse.scanning.api.event.scan.IScanListener) ScanBean(org.eclipse.scanning.api.event.scan.ScanBean) IClauseElementProcessor(gda.mscan.processor.IClauseElementProcessor) ReRunFromFileElementProcessor(gda.mscan.processor.ReRunFromFileElementProcessor) ScanRequestBuilder(org.eclipse.scanning.sequencer.ScanRequestBuilder) Test(org.junit.Test)

Aggregations

IClauseElementProcessor (gda.mscan.processor.IClauseElementProcessor)1 ReRunFromFileElementProcessor (gda.mscan.processor.ReRunFromFileElementProcessor)1 IScanListener (org.eclipse.scanning.api.event.scan.IScanListener)1 ScanBean (org.eclipse.scanning.api.event.scan.ScanBean)1 ScanRequest (org.eclipse.scanning.api.event.scan.ScanRequest)1 ScanRequestBuilder (org.eclipse.scanning.sequencer.ScanRequestBuilder)1 Test (org.junit.Test)1