SimpleNullfree implements Nullfree { @Override public Badge badge() throws NullfreeException { return badgeFactory.execute(sources.nulls()); } SimpleNullfree(
        final Sources sources,
        final Function1<Badge, Nulls, NullfreeException> badgeFactory
    ); @Override Badge badge();  }
@Test public void failIfRedWhenRed() throws Exception { try { new SimpleNullfree( new SimpleSources( Collections.singletonList( new JavaSourceFile( "package simple.pkg;\n", "\n", "class B {\n", " void a() {\n", " String foo = null;", " }\n", " static class A {\n", " void b() {\n", " new Runnable() {\n", " public void run() {\n", " String name = null;\n", " }\n", " };\n", " }\n", " }\n", "}\n" ) ) ), SimpleBadge::new ).badge().failIfRed(); Assert.fail(); } catch (NullfreeException e) { } }
@Test public void failIfRedWhenGreen() throws Exception { try { new SimpleNullfree( new SimpleSources( Collections.singletonList( new JavaSourceFile( "class B {\n", " void a() {\n", " String foo = \"bar\";", " }\n", "}\n" ) ) ), SimpleBadge::new ).badge().failIfRed(); } catch (NullfreeException e) { Assert.fail(); } }