title: How i can return Expected exception: java.util.InputMismatchException in my java function
body: <p><strong>This is my function</strong> </p>
  
  <pre><code>public Object check(long number) {
          long root = 0;
              while (number &gt; 0 || root &gt; 9) {
                  if (number == 0) {
                      number = root;
                      root = 0;
                  }
  
                  root += number % 10;
                  number /= 10;
              }
          return root;
  }
  </code></pre>
  
  <p>**I want to pass this test case how can i sov it ** </p>
  
  <pre><code>     @Test(expected = InputMismatchException.class)
          public void testInvalidInput() {
              digitalRoot.check(-87625L);
          }
  </code></pre>