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