/** * Get the GWT RPC service. * @param callback The callback to use when determining the service. */ private void getService(final ServiceCallback callback) { if (xsrfRequestBuilder.getXsrfToken() != null) { callback.serviceFound(service); } else { xsrfService.getNewXsrfToken(new AsyncCallback<XsrfToken>() { @Override public void onSuccess(XsrfToken token) { xsrfRequestBuilder.setXsrfToken(token); callback.serviceFound(service); } @Override public void onFailure(Throwable caught) { callback.onFailure(caught); } }); } }
@BeforeEach public void setUp() { mockService = mock(GenericApiGWTServiceAsync.class, withSettings().extraInterfaces(ServiceDefTarget.class)); fakeScheduler = new FakeGWTScheduler(); CommunicationProvider communicationsProvider = new GWTRPCCommunicationProvider(mockService, mockXsrfService, mockXsrfRpcRequestBuilder); when(mockXsrfRpcRequestBuilder.getXsrfToken()).thenReturn(new XsrfToken("Something")); //$NON-NLS-1$ OperationProcessor operationProcessor = new OperationProcessor(communicationsProvider); operationProcessor.setScheduler(fakeScheduler); VdcOperationManager operationsManager = new VdcOperationManager(mockEventBus, operationProcessor); frontend = new Frontend(operationsManager, mockValidateErrorsTranslator, mockVdsmErrorsTranslator, mockEventBus); frontend.frontendFailureEvent = mockFrontendFailureEvent; frontend.frontendNotLoggedInEvent = mockFrontendNotLoggedInEvent; frontend.setEventsHandler(mockEventsHandler); frontend.setConstants(mockConstants); when(mockAsyncQuery.getModel()).thenReturn(ASYNC_OPERATION_TARGET); when(mockAsyncQuery.getAsyncCallback()).thenReturn(mockAsyncCallback); }
@BeforeEach public void setUp() { mockService = mock(GenericApiGWTServiceAsync.class, withSettings().extraInterfaces(ServiceDefTarget.class)); fakeScheduler = new FakeGWTScheduler(); CommunicationProvider communicationsProvider = new GWTRPCCommunicationProvider(mockService, mockXsrfService, mockXsrfRpcRequestBuilder); when(mockXsrfRpcRequestBuilder.getXsrfToken()).thenReturn(new XsrfToken("Something")); //$NON-NLS-1$ OperationProcessor operationProcessor = new OperationProcessor(communicationsProvider); operationProcessor.setScheduler(fakeScheduler); VdcOperationManager operationsManager = new VdcOperationManager(mockEventBus, operationProcessor); frontend = new Frontend(operationsManager, mockValidateErrorsTranslator, mockVdsmErrorsTranslator, mockEventBus); frontend.setEventsHandler(mockEventsHandler); frontend.setConstants(mockConstants); frontend.frontendFailureEvent = mockFrontendFailureEvent; when(mockConstants.noValidateMessage()).thenReturn(NO_MESSAGE); }