Java Code Examples for com.google.common.testing.NullPointerTester#testConstructors()

The following examples show how to use com.google.common.testing.NullPointerTester#testConstructors() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProcessThreadMetricsTest.java    From micrometer-jvm-extras with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullContract() {
    final ProcessThreadMetrics uut = new ProcessThreadMetrics(status);

    final NullPointerTester npt = new NullPointerTester();

    npt.testConstructors(uut.getClass(), Visibility.PACKAGE);
    npt.testStaticMethods(uut.getClass(), Visibility.PACKAGE);
    npt.testInstanceMethods(uut, Visibility.PACKAGE);
}
 
Example 2
Source File: ProcessMemoryMetricsTest.java    From micrometer-jvm-extras with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullContract() {
    final ProcessMemoryMetrics uut = new ProcessMemoryMetrics(status);

    final NullPointerTester npt = new NullPointerTester();

    npt.testConstructors(uut.getClass(), Visibility.PACKAGE);
    npt.testStaticMethods(uut.getClass(), Visibility.PACKAGE);
    npt.testInstanceMethods(uut, Visibility.PACKAGE);
}
 
Example 3
Source File: ProcfsStatusTest.java    From micrometer-jvm-extras with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullContract() {
    final ProcfsStatus uut = new ProcfsStatus(mock(ProcfsReader.class));

    final NullPointerTester npt = new NullPointerTester();

    npt.testConstructors(uut.getClass(), Visibility.PACKAGE);
    npt.testStaticMethods(uut.getClass(), Visibility.PACKAGE);
    npt.testInstanceMethods(uut, Visibility.PACKAGE);
}
 
Example 4
Source File: ProcfsEntryTest.java    From micrometer-jvm-extras with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullContract() {
    final NullPointerTester npt = new NullPointerTester();

    npt.testConstructors(uut.getClass(), Visibility.PACKAGE);
    npt.testStaticMethods(uut.getClass(), Visibility.PACKAGE);
    npt.testInstanceMethods(uut, Visibility.PACKAGE);
}
 
Example 5
Source File: ProcfsReaderTest.java    From micrometer-jvm-extras with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullContract() throws Exception {
    final ProcfsReader uut = new ProcfsReader(BASE, "smaps-001.txt");

    final NullPointerTester npt = new NullPointerTester();

    npt.testConstructors(uut.getClass(), Visibility.PACKAGE);
    npt.testStaticMethods(uut.getClass(), Visibility.PACKAGE);
    npt.testInstanceMethods(uut, Visibility.PACKAGE);
}
 
Example 6
Source File: ProcfsSmapsTest.java    From micrometer-jvm-extras with Apache License 2.0 5 votes vote down vote up
@Test
public void testNullContract() {
    final ProcfsSmaps uut = new ProcfsSmaps(mock(ProcfsReader.class));

    final NullPointerTester npt = new NullPointerTester();

    npt.testConstructors(uut.getClass(), Visibility.PACKAGE);
    npt.testStaticMethods(uut.getClass(), Visibility.PACKAGE);
    npt.testInstanceMethods(uut, Visibility.PACKAGE);
}
 
Example 7
Source File: CcCompilationHelperTest.java    From bazel with Apache License 2.0 5 votes vote down vote up
@Test
public void testConstructorThrowsNPE() throws Exception {
  ConfiguredTarget target =
      scratchConfiguredTarget("a", "b", "cc_library(name = 'b', srcs = [],)");
  RuleContext ruleContext = getRuleContext(target);
  CcToolchainProvider ccToolchain =
      CppHelper.getToolchainUsingDefaultCcToolchainAttribute(ruleContext);
  FdoContext fdoContext = ccToolchain.getFdoContext();
  Artifact grepIncludes = getBinArtifact("grep_includes", target);
  NullPointerTester tester =
      new NullPointerTester()
          .setDefault(RuleContext.class, ruleContext)
          .setDefault(CcCommon.class, new CcCommon(ruleContext))
          .setDefault(CppSemantics.class, MockCppSemantics.INSTANCE)
          .setDefault(CcToolchainProvider.class, ccToolchain)
          .setDefault(BuildConfiguration.class, ruleContext.getConfiguration())
          .setDefault(FdoContext.class, fdoContext)
          .setDefault(Label.class, ruleContext.getLabel())
          .setDefault(Artifact.class, grepIncludes)
          .setDefault(CcCompilationOutputs.class, CcCompilationOutputs.builder().build());
  tester.testConstructors(CcCompilationHelper.class, Visibility.PACKAGE);
  tester.testAllPublicInstanceMethods(
      new CcCompilationHelper(
          ruleContext,
          ruleContext,
          target.getLabel(),
          /* grepIncludes= */ null,
          MockCppSemantics.INSTANCE,
          FeatureConfiguration.EMPTY,
          ccToolchain,
          fdoContext,
          /* executionInfo= */ ImmutableMap.of(),
          /* shouldProcessHeaders= */ true));
}