### Question:
GradleProjectProperties implements ProjectProperties { @Override public int getMajorJavaVersion() { JavaVersion version = JavaVersion.current(); JavaPluginConvention javaPluginConvention = project.getConvention().findPlugin(JavaPluginConvention.class); if (javaPluginConvention != null) { version = javaPluginConvention.getTargetCompatibility(); } return Integer.valueOf(version.getMajorVersion()); } @VisibleForTesting  GradleProjectProperties(
      Project project,
      Logger logger,
      TempDirectoryProvider tempDirectoryProvider,
      Supplier<List<JibGradlePluginExtension<?>>> extensionLoader); static GradleProjectProperties getForProject(
      Project project, Logger logger, TempDirectoryProvider tempDirectoryProvider); @Override JibContainerBuilder createJibContainerBuilder(
      JavaContainerBuilder javaContainerBuilder, ContainerizingMode containerizingMode); @Override List<Path> getClassFiles(); @Override void waitForLoggingThread(); @Override void configureEventHandlers(Containerizer containerizer); @Override void log(LogEvent logEvent); @Override String getToolName(); @Override String getToolVersion(); @Override String getPluginName(); @Nullable @Override String getMainClassFromJarPlugin(); @Override Path getDefaultCacheDirectory(); @Override String getJarPluginName(); @Override boolean isWarProject(); @Override String getName(); @Override String getVersion(); @Override int getMajorJavaVersion(); @Override boolean isOffline(); @Override JibContainerBuilder runPluginExtensions(
      List<? extends ExtensionConfiguration> extensionConfigs,
      JibContainerBuilder jibContainerBuilder);  }### Answer:
@Test public void testGetMajorJavaVersion() { Mockito.when(mockConvention.findPlugin(JavaPluginConvention.class)) .thenReturn(mockJavaPluginConvention); Mockito.when(mockJavaPluginConvention.getTargetCompatibility()) .thenReturn(JavaVersion.VERSION_1_3); Assert.assertEquals(3, gradleProjectProperties.getMajorJavaVersion()); Mockito.when(mockJavaPluginConvention.getTargetCompatibility()) .thenReturn(JavaVersion.VERSION_11); Assert.assertEquals(11, gradleProjectProperties.getMajorJavaVersion()); Mockito.when(mockJavaPluginConvention.getTargetCompatibility()) .thenReturn(JavaVersion.VERSION_1_9); Assert.assertEquals(9, gradleProjectProperties.getMajorJavaVersion()); }
@Test public void testGetMajorJavaVersion_jvm8() { Assume.assumeThat(JavaVersion.current(), CoreMatchers.is(JavaVersion.VERSION_1_8)); Assert.assertEquals(8, gradleProjectProperties.getMajorJavaVersion()); }
@Test public void testGetMajorJavaVersion_jvm11() { Assume.assumeThat(JavaVersion.current(), CoreMatchers.is(JavaVersion.VERSION_11)); Assert.assertEquals(11, gradleProjectProperties.getMajorJavaVersion()); }