SHARE
TWEET

Untitled

a guest Jun 20th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @Autowired
  2.     Executor existingThreadPool;
  3.  
  4.     @Override
  5.     public void auditData(List<ErrorDetails> alertList) {
  6.         CompletableFuture.runAsync(() -> {
  7.             if (alertList.isEmpty())
  8.                 //externalServiceCall1
  9.             else
  10.                //externalServiceCall2
  11.         }, existingThreadPool);
  12.     }
  13.      
  14. @InjectMock
  15.     AuditService auditService;
  16.  
  17.     @Mock
  18.     private CompletableFuture<Void> completableFuture = null;
  19.  
  20.     @Before
  21.     public void setup() {
  22.         MockitoAnnotations.initMocks(this);
  23.         completableFuture = CompletableFuture.runAsync(new Runnable() {
  24.             @Override
  25.             public void run() {}
  26.         },Executors.newSingleThreadExecutor());
  27.     }
  28.  
  29.     @Test
  30.     public void shouldAuditData() {
  31.         List<ErrorDetails> alertList = new ArrayList();
  32.         auditService.auditData(alertList);
  33.     }
  34.      
  35. java.lang.NullPointerException
  36.     at java.util.concurrent.CompletableFuture.screenExecutor(CompletableFuture.java:415)
  37.     at java.util.concurrent.CompletableFuture.runAsync(CompletableFuture.java:1858)
  38.     at com.service.impl.AuditService.auditData(AuditService.java:15)
  39.     at com.service.impl.AuditServiceTest.shouldAuditData(AuditServiceTest.java:249)
  40.     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  41.     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  42.     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  43.     at java.lang.reflect.Method.invoke(Method.java:498)
  44.     at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
  45.     at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  46.     at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
  47.     at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  48.     at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
  49.     at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
  50.     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
  51.     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
  52.     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  53.     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  54.     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  55.     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  56.     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  57.     at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  58.     at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
  59.     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  60.     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
  61.     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
  62.     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
  63.     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top