- @Test
- public void testStartPreprocessorAsync() throws Exception {
- CompletableFuture<OperationOutcome> future2 = new CompletableFuture<>();
- context = mock(ControlLoopEventContext.class);
- when(context.obtain(eq(AaiCqResponse.CONTEXT_KEY), any())).thenReturn(future2);
- when(context.getEvent()).thenReturn(event);
- params = params.toBuilder().context(context).build();
-
- AtomicBoolean guardStarted = new AtomicBoolean();
-
- oper = new ModifyConfigOperation(params, config) {
- @Override
- protected CompletableFuture<OperationOutcome> startGuardAsync() {
- guardStarted.set(true);
- return super.startGuardAsync();
- }
- };
-
- CompletableFuture<OperationOutcome> future3 = oper.startPreprocessorAsync();
- assertNotNull(future3);
- assertFalse(future.isDone());
- assertTrue(guardStarted.get());
- verify(context).obtain(eq(AaiCqResponse.CONTEXT_KEY), any());
-
- future2.complete(params.makeOutcome(null));
- assertTrue(executor.runAll(100));
- assertTrue(future3.isDone());
- assertEquals(OperationResult.SUCCESS, future3.get().getResult());
- }
-
- /**
- * Tests startPreprocessorAsync(), when preprocessing is disabled.
- */
- @Test
- public void testStartPreprocessorAsyncDisabled() {
- params = params.toBuilder().preprocessed(true).build();
- assertNull(new ModifyConfigOperation(params, config).startPreprocessorAsync());
- }
-