The problem as far as I see here is that the .build() method here may fail with an exception (and, by the way, Exception is too broad imho; it may go without saying but RuntimeException extends Exception therefore all RuntimeExceptions will also be thrown); but in this case the test will end up as an _error_, not a failure.
Now, how to not trigger false positives in this case... Well, with TestNG it's relatively simple:
@Test(expectedException = SomeException.class)
public void myTest()
throws SomeException
{
// whatever
}
With JUnit, no idea... This SO post gives some ideas:
And then you should not really be a slave to your static source code analyzer so what to do in this case would really be to rewrite the test:
@Test
public void testTimeTokenNull()
throws Exception
{
try {
builder.build();
fail("Hey, I should have had an NPE here");
} catch (NullPointerException expected) {
assertTrue(true);
}
}