@Test public void failThreshold() { try { new SimpleBadge( new JavaSourceFile( "class A {", " String name = null;", " String value = null;", " void run() {", " String a = null;", " }", "}" ).nulls(), 2 ).failIfRed(); Assert.fail(); } catch (NullfreeException e) { } }
@Override public void failIfRed() throws NullfreeException { final List<Null> nulls = this.nulls.asList(); if (nulls.size() > threshold) { final StringBuilder message = new StringBuilder(); for (final Null aNull : nulls) { message.append("Found:\n"); message.append(aNull.description()); message.append('\n'); } throw new NullfreeException( String.format( "Found nulls:\n%s", message.toString() ) ); } }
SimpleBadge implements Badge { @Override public void failIfRed() throws NullfreeException { final List<Null> nulls = this.nulls.asList(); if (nulls.size() > threshold) { final StringBuilder message = new StringBuilder(); for (final Null aNull : nulls) { message.append("Found:\n"); message.append(aNull.description()); message.append('\n'); } throw new NullfreeException( String.format( "Found nulls:\n%s", message.toString() ) ); } } }
SimpleBadge implements Badge { @Override public void failIfRed() throws NullfreeException { final List<Null> nulls = this.nulls.asList(); if (nulls.size() > threshold) { final StringBuilder message = new StringBuilder(); for (final Null aNull : nulls) { message.append("Found:\n"); message.append(aNull.description()); message.append('\n'); } throw new NullfreeException( String.format( "Found nulls:\n%s", message.toString() ) ); } } SimpleBadge(final Nulls nulls);  SimpleBadge(final Nulls nulls, final int threshold); }
SimpleBadge implements Badge { @Override public void failIfRed() throws NullfreeException { final List<Null> nulls = this.nulls.asList(); if (nulls.size() > threshold) { final StringBuilder message = new StringBuilder(); for (final Null aNull : nulls) { message.append("Found:\n"); message.append(aNull.description()); message.append('\n'); } throw new NullfreeException( String.format( "Found nulls:\n%s", message.toString() ) ); } } SimpleBadge(final Nulls nulls);  SimpleBadge(final Nulls nulls, final int threshold); @Override void send(final URL url); @Override void failIfRed(); }
SimpleBadge implements Badge { @Override public void failIfRed() throws NullfreeException { final List<Null> nulls = this.nulls.asList(); if (nulls.size() > threshold) { final StringBuilder message = new StringBuilder(); for (final Null aNull : nulls) { message.append("Found:\n"); message.append(aNull.description()); message.append('\n'); } throw new NullfreeException( String.format( "Found nulls:\n%s", message.toString() ) ); } } SimpleBadge(final Nulls nulls);  SimpleBadge(final Nulls nulls, final int threshold); @Override void send(final URL url); @Override void failIfRed();  }