1package com.google.example; 2 3import com.google.common.base.Preconditions; 4 5import org.junit.runner.RunWith; 6import org.junit.runners.JUnit4; 7 8import java.util.List; 9 10import javax.annotation.Nullable; 11 12import static org.junit.Assert.fail; 13import static com.google.truth.Truth.assertThat; 14 15@RunWith(JUnit4.class) 16public class SomeTest { 17 18 <T> void check(@Nullable List<T> x) { 19 Preconditions.checkNodeNull(x); 20 } 21 22 void f() { 23 List<String> xs = null; 24 assertThat(xs).isNull(); 25 try { 26 check(xs); 27 fail(); 28 } catch (NullPointerException e) { 29 } 30 } 31} 32