title: Cannot invoke "reactor.core.publisher.Mono.thenReturn(Object)" because the return value is null
body: <p>I'm trying to write a test cases for createEmployee and updateEmployee by mocking the repository class. But, it's failing with below error.</p>
  <p>Note : Other methods for find, findAll are working fine.</p>
  <pre><code>java.lang.NullPointerException: Cannot invoke &quot;reactor.core.publisher.Mono.thenReturn(Object)&quot; because the return value of &quot;com.springflexcounchdb.dao.IEmployeeDAO.create(com.springflexcounchdb.model.Employee)&quot; is null
      at com.springflexcounchdb.test.service.EmployeeServiceTest.createEmployeeTest(EmployeeServiceTest.java:71)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:568)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
      at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
      at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
      at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:93)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
  </code></pre>
  <p>//test class where repository class is mocked and update service method called</p>
  <pre class="lang-java prettyprint-override"><code>    @RunWith(SpringRunner.class)
      @WebFluxTest(EmployeeService.class)
      public class EmployeeServiceTest {
      
          @Autowired
          private EmployeeService employeeService;
          
          @MockBean
          @Qualifier(&quot;employeeDAO&quot;)
          private IEmployeeDAO employeeDAO;
          
          @Test
          public void createEmployeeTest() {
      
              List&lt;AddressDTO&gt; addressDTOList= new ArrayList&lt;&gt;(); 
              addressDTOList.add(new AddressDTO(&quot;address&quot;));
              List&lt;Address&gt; addressList= new ArrayList&lt;&gt;(); 
              addressList.add(new Address(&quot;address&quot;));
              EmployeeDTO employeeDTO= new EmployeeDTO(&quot;1&quot;, &quot;1&quot;, &quot;1-1234&quot;, &quot;Test-Employee&quot;, 20, addressDTOList);
              
              Employee employee = new Employee(&quot;1&quot;, &quot;1&quot;, &quot;1-1234&quot;, &quot;Test-Employee&quot;, 20, addressList);
              
              Mono&lt;Employee&gt; monoEmployee = Mono.just(employee);
              
              when(employeeDAO.create(employee).thenReturn(Mono.just(&quot;1&quot;)));
              Mono&lt;String&gt; responseEmployee  = employeeService.create(employeeDTO);
              
              try {
                  assertEquals(true, responseEmployee.toFuture().get());
              } catch (InterruptedException e) {
                  e.printStackTrace();
              } catch (ExecutionException e) {
                  e.printStackTrace();
              }                   
          }
      }
  </code></pre>
  <p>//service class where update method is present</p>
  <pre class="lang-java prettyprint-override"><code>    @Service
      public class EmployeeService implements IEmployeeService {
      
         @Autowired
         @Qualifier(&quot;employeeDAO&quot;)
         IEmployeeDAO iEmployeeDAO;
      
         public Mono&lt;EmployeeDTO&gt; update(EmployeeDTO e) {
              return MappingDtoToEntity.convertEmpoyeeToMono(iEmployeeDAO.update(MappingDtoToEntity.convertEmployeeEntity(e)));
         }
      }
  </code></pre>