Java Code Examples for org.elasticsearch.transport.TransportService#NOOP_TRANSPORT_INTERCEPTOR
The following examples show how to use
org.elasticsearch.transport.TransportService#NOOP_TRANSPORT_INTERCEPTOR .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThresholdResultTests.java From anomaly-detection with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public void testExecutionException() { TransportService transportService = new TransportService( Settings.EMPTY, mock(Transport.class), null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> null, null, Collections.emptySet() ); ModelManager manager = mock(ModelManager.class); ThresholdResultTransportAction action = new ThresholdResultTransportAction(mock(ActionFilters.class), transportService, manager); doThrow(NullPointerException.class) .when(manager) .getThresholdingResult(any(String.class), any(String.class), anyDouble(), any(ActionListener.class)); final PlainActionFuture<ThresholdResultResponse> future = new PlainActionFuture<>(); ThresholdResultRequest request = new ThresholdResultRequest("123", "123-threshold", 2); action.doExecute(mock(Task.class), request, future); expectThrows(NullPointerException.class, () -> future.actionGet()); }
Example 2
Source File: MockTransportService.java From crate with Apache License 2.0 | 6 votes |
public static MockTransportService createNewService(Settings settings, Transport transport, Version version, ThreadPool threadPool, @Nullable ClusterSettings clusterSettings) { return new MockTransportService( settings, transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, boundAddress -> new DiscoveryNode( Node.NODE_NAME_SETTING.get(settings), UUIDs.randomBase64UUID(), boundAddress.publishAddress(), Node.NODE_ATTRIBUTES.getAsMap(settings), DiscoveryNode.getRolesFromSettings(settings), version ), clusterSettings ); }
Example 3
Source File: ThresholdResultTests.java From anomaly-detection with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public void testNormal() { TransportService transportService = new TransportService( Settings.EMPTY, mock(Transport.class), null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> null, null, Collections.emptySet() ); ModelManager manager = mock(ModelManager.class); ThresholdResultTransportAction action = new ThresholdResultTransportAction(mock(ActionFilters.class), transportService, manager); doAnswer(invocation -> { ActionListener<ThresholdingResult> listener = invocation.getArgument(3); listener.onResponse(new ThresholdingResult(0, 1.0d)); return null; }).when(manager).getThresholdingResult(any(String.class), any(String.class), anyDouble(), any(ActionListener.class)); final PlainActionFuture<ThresholdResultResponse> future = new PlainActionFuture<>(); ThresholdResultRequest request = new ThresholdResultRequest("123", "123-threshold", 2); action.doExecute(mock(Task.class), request, future); ThresholdResultResponse response = future.actionGet(); assertEquals(0, response.getAnomalyGrade(), 0.001); assertEquals(1, response.getConfidence(), 0.001); }
Example 4
Source File: RCFResultTests.java From anomaly-detection with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public void testNormal() { TransportService transportService = new TransportService( Settings.EMPTY, mock(Transport.class), null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> null, null, Collections.emptySet() ); ModelManager manager = mock(ModelManager.class); ADCircuitBreakerService adCircuitBreakerService = mock(ADCircuitBreakerService.class); RCFResultTransportAction action = new RCFResultTransportAction( mock(ActionFilters.class), transportService, manager, adCircuitBreakerService ); doAnswer(invocation -> { ActionListener<RcfResult> listener = invocation.getArgument(3); listener.onResponse(new RcfResult(0, 0, 25)); return null; }).when(manager).getRcfResult(any(String.class), any(String.class), any(double[].class), any(ActionListener.class)); when(adCircuitBreakerService.isOpen()).thenReturn(false); final PlainActionFuture<RCFResultResponse> future = new PlainActionFuture<>(); RCFResultRequest request = new RCFResultRequest("123", "123-rcf-1", new double[] { 0 }); action.doExecute(mock(Task.class), request, future); RCFResultResponse response = future.actionGet(); assertEquals(0, response.getRCFScore(), 0.001); assertEquals(25, response.getForestSize(), 0.001); }
Example 5
Source File: RCFResultTests.java From anomaly-detection with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public void testExecutionException() { TransportService transportService = new TransportService( Settings.EMPTY, mock(Transport.class), null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> null, null, Collections.emptySet() ); ModelManager manager = mock(ModelManager.class); ADCircuitBreakerService adCircuitBreakerService = mock(ADCircuitBreakerService.class); RCFResultTransportAction action = new RCFResultTransportAction( mock(ActionFilters.class), transportService, manager, adCircuitBreakerService ); doThrow(NullPointerException.class) .when(manager) .getRcfResult(any(String.class), any(String.class), any(double[].class), any(ActionListener.class)); when(adCircuitBreakerService.isOpen()).thenReturn(false); final PlainActionFuture<RCFResultResponse> future = new PlainActionFuture<>(); RCFResultRequest request = new RCFResultRequest("123", "123-rcf-1", new double[] { 0 }); action.doExecute(mock(Task.class), request, future); expectThrows(NullPointerException.class, () -> future.actionGet()); }
Example 6
Source File: RCFResultTests.java From anomaly-detection with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public void testCircuitBreaker() { TransportService transportService = new TransportService( Settings.EMPTY, mock(Transport.class), null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> null, null, Collections.emptySet() ); ModelManager manager = mock(ModelManager.class); ADCircuitBreakerService breakerService = mock(ADCircuitBreakerService.class); RCFResultTransportAction action = new RCFResultTransportAction( mock(ActionFilters.class), transportService, manager, breakerService ); doAnswer(invocation -> { ActionListener<RcfResult> listener = invocation.getArgument(3); listener.onResponse(new RcfResult(0, 0, 25)); return null; }).when(manager).getRcfResult(any(String.class), any(String.class), any(double[].class), any(ActionListener.class)); when(breakerService.isOpen()).thenReturn(true); final PlainActionFuture<RCFResultResponse> future = new PlainActionFuture<>(); RCFResultRequest request = new RCFResultRequest("123", "123-rcf-1", new double[] { 0 }); action.doExecute(mock(Task.class), request, future); expectThrows(LimitExceededException.class, () -> future.actionGet()); }