### Question:
MavenProjectProperties implements ProjectProperties { @Override public int getMajorJavaVersion() { if (project.getProperties().getProperty("maven.compiler.target") != null) { return getVersionFromString(project.getProperties().getProperty("maven.compiler.target")); } if (project.getProperties().getProperty("maven.compiler.release") != null) { return getVersionFromString(project.getProperties().getProperty("maven.compiler.release")); } Plugin mavenCompilerPlugin = project.getPlugin("org.apache.maven.plugins:maven-compiler-plugin"); if (mavenCompilerPlugin != null) { Xpp3Dom pluginConfiguration = (Xpp3Dom) mavenCompilerPlugin.getConfiguration(); Optional<String> target = getChildValue(pluginConfiguration, "target"); if (target.isPresent()) { return getVersionFromString(target.get()); } Optional<String> release = getChildValue(pluginConfiguration, "release"); if (release.isPresent()) { return getVersionFromString(release.get()); } } return 6; } @VisibleForTesting  MavenProjectProperties(
      PluginDescriptor jibPluginDescriptor,
      MavenProject project,
      MavenSession session,
      Log log,
      TempDirectoryProvider tempDirectoryProvider,
      Supplier<List<JibMavenPluginExtension<?>>> extensionLoader); static MavenProjectProperties getForProject(
      PluginDescriptor jibPluginDescriptor,
      MavenProject project,
      MavenSession session,
      Log log,
      TempDirectoryProvider tempDirectoryProvider); @Nullable static String getProperty(
      String propertyName, @Nullable MavenProject project, @Nullable MavenSession session); @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); static final String PLUGIN_NAME; static final String PLUGIN_KEY; }### Answer:
@Test public void testGetMajorJavaVersion_undefinedDefaultsTo6() { Assert.assertEquals(6, mavenProjectProperties.getMajorJavaVersion()); }
@Test public void testValidateBaseImageVersion_compilerPluginTarget() { Mockito.when(mockMavenProject.getPlugin("org.apache.maven.plugins:maven-compiler-plugin")) .thenReturn(mockPlugin); Mockito.when(mockPlugin.getConfiguration()).thenReturn(pluginConfiguration); Xpp3Dom compilerTarget = new Xpp3Dom("target"); pluginConfiguration.addChild(compilerTarget); compilerTarget.setValue("1.8"); Assert.assertEquals(8, mavenProjectProperties.getMajorJavaVersion()); compilerTarget.setValue("1.6"); Assert.assertEquals(6, mavenProjectProperties.getMajorJavaVersion()); compilerTarget.setValue("13"); Assert.assertEquals(13, mavenProjectProperties.getMajorJavaVersion()); }
@Test public void testValidateBaseImageVersion_compilerPluginRelease() { Mockito.when(mockMavenProject.getPlugin("org.apache.maven.plugins:maven-compiler-plugin")) .thenReturn(mockPlugin); Mockito.when(mockPlugin.getConfiguration()).thenReturn(pluginConfiguration); Xpp3Dom compilerRelease = new Xpp3Dom("release"); pluginConfiguration.addChild(compilerRelease); compilerRelease.setValue("1.8"); Assert.assertEquals(8, mavenProjectProperties.getMajorJavaVersion()); compilerRelease.setValue("10"); Assert.assertEquals(10, mavenProjectProperties.getMajorJavaVersion()); compilerRelease.setValue("13"); Assert.assertEquals(13, mavenProjectProperties.getMajorJavaVersion()); }