Use an ExpectedException junit rule for this test instead of the boolean, conditionals and try.