Repository: GoogleContainerTools/jib
File: jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/GradleRawConfigurationTest.java (Java)

Code before:
/*
 * Copyright 2018 Google LLC.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.google.cloud.tools.jib.gradle;

import com.google.cloud.tools.jib.plugins.common.AuthProperty;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import org.gradle.api.internal.provider.DefaultMapProperty;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;

/** Test for {@link GradleRawConfiguration}. */
public class GradleRawConfigurationTest {

  @Test
  public void testGetters() {
    JibExtension jibExtension = Mockito.mock(JibExtension.class);

    AuthParameters authParameters = Mockito.mock(AuthParameters.class);
    BaseImageParameters baseImageParameters = Mockito.mock(BaseImageParameters.class);
    TargetImageParameters targetImageParameters = Mockito.mock(TargetImageParameters.class);
    ContainerParameters containerParameters = Mockito.mock(ContainerParameters.class);
    DockerClientParameters dockerClientParameters = Mockito.mock(DockerClientParameters.class);
    OutputPathsParameters outputPathsParameters = Mockito.mock(OutputPathsParameters.class);

    Mockito.when(authParameters.getUsername()).thenReturn("user");
    Mockito.when(authParameters.getPassword()).thenReturn("password");
    Mockito.when(authParameters.getAuthDescriptor()).thenReturn("from.auth");
    Mockito.when(authParameters.getUsernameDescriptor()).thenReturn("from.auth.username");
    Mockito.when(authParameters.getPasswordDescriptor()).thenReturn("from.auth.password");

    Mockito.when(jibExtension.getFrom()).thenReturn(baseImageParameters);

Review comment (suggestion):
`internal` concerns me. Let's do this:
```diff
@@ -21,16 +21,23 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Sets;
 import java.nio.file.Paths;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import org.gradle.api.internal.provider.DefaultMapProperty;
+import org.gradle.api.provider.MapProperty;
 import org.junit.Assert;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
 import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
 
 /** Test for {@link GradleRawConfiguration}. */
+@RunWith(MockitoJUnitRunner.class)
 public class GradleRawConfigurationTest {
 
+  @Mock private MapProperty<String, String> labels;
+
   @Test
   public void testGetters() {
     JibExtension jibExtension = Mockito.mock(JibExtension.class);
@@ -68,10 +75,8 @@ public class GradleRawConfigurationTest {
     Mockito.when(containerParameters.getEnvironment())
         .thenReturn(new HashMap<>(ImmutableMap.of("currency", "dollar")));
     Mockito.when(containerParameters.getJvmFlags()).thenReturn(Arrays.asList("-cp", "."));
-    DefaultMapProperty<String, String> labelProperties =
-        new DefaultMapProperty<>(String.class, String.class);
-    labelProperties.set(new HashMap<>(ImmutableMap.of("unit", "cm")));
-    Mockito.when(containerParameters.getLabels()).thenReturn(labelProperties);
+    Mockito.when(labels.get()).thenReturn(Collections.singletonMap("unit", "cm"));
+    Mockito.when(containerParameters.getLabels()).thenReturn(labels);
     Mockito.when(containerParameters.getMainClass()).thenReturn("com.example.Main");
     Mockito.when(containerParameters.getPorts()).thenReturn(Arrays.asList("80/tcp", "0"));
     Mockito.when(containerParameters.getUser()).thenReturn("admin:wheel");
```

Code after:
/*
 * Copyright 2018 Google LLC.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.google.cloud.tools.jib.gradle;

import com.google.cloud.tools.jib.plugins.common.AuthProperty;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import org.gradle.api.provider.MapProperty;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;

/** Test for {@link GradleRawConfiguration}. */
@RunWith(MockitoJUnitRunner.class)
public class GradleRawConfigurationTest {

  @Mock private MapProperty<String, String> labels;

  @Test
  public void testGetters() {
    JibExtension jibExtension = Mockito.mock(JibExtension.class);

    AuthParameters authParameters = Mockito.mock(AuthParameters.class);
    BaseImageParameters baseImageParameters = Mockito.mock(BaseImageParameters.class);
    TargetImageParameters targetImageParameters = Mockito.mock(TargetImageParameters.class);
    ContainerParameters containerParameters = Mockito.mock(ContainerParameters.class);
    DockerClientParameters dockerClientParameters = Mockito.mock(DockerClientParameters.class);
    OutputPathsParameters outputPathsParameters = Mockito.mock(OutputPathsParameters.class);