diff --git a/develocity-gradle-plugin-adapters/src/develocityCompatibilityTest/java/com/gradle/develocity/agent/gradle/adapters/develocity/BuildScanConfigurationAdapterTest.java b/develocity-gradle-plugin-adapters/src/develocityCompatibilityTest/java/com/gradle/develocity/agent/gradle/adapters/develocity/BuildScanConfigurationAdapterTest.java index f6e9aa4..c5812f7 100644 --- a/develocity-gradle-plugin-adapters/src/develocityCompatibilityTest/java/com/gradle/develocity/agent/gradle/adapters/develocity/BuildScanConfigurationAdapterTest.java +++ b/develocity-gradle-plugin-adapters/src/develocityCompatibilityTest/java/com/gradle/develocity/agent/gradle/adapters/develocity/BuildScanConfigurationAdapterTest.java @@ -21,6 +21,7 @@ import org.mockito.junit.jupiter.MockitoExtension; import java.util.Collections; +import java.util.List; import static com.gradle.develocity.agent.gradle.adapters.ActionMockFixtures.doExecuteActionWith; import static com.gradle.develocity.agent.gradle.adapters.PropertyMockFixtures.mockProperty; @@ -163,11 +164,16 @@ void testBackgroundAction() { @Test @DisplayName("build finished action can be configured via an adapter using the new build result model") + @SuppressWarnings("Convert2Lambda") void testBuildFinishedAction() { // given Throwable failure = new RuntimeException("New build failure!"); - BuildResult buildResult = mock(); - when(buildResult.getFailures()).thenReturn(Collections.singletonList(failure)); + BuildResult buildResult = new BuildResult() { + @Override + public List getFailures() { + return Collections.singletonList(failure); + } + }; // and doExecuteActionWith(buildResult).when(configuration).buildFinished(any()); diff --git a/develocity-gradle-plugin-adapters/src/enterpriseCompatibilityTest/java/com/gradle/develocity/agent/gradle/adapters/enterprise/BuildScanExtensionAdapterTest.java b/develocity-gradle-plugin-adapters/src/enterpriseCompatibilityTest/java/com/gradle/develocity/agent/gradle/adapters/enterprise/BuildScanExtensionAdapterTest.java index 0eacd43..cbce3a0 100644 --- a/develocity-gradle-plugin-adapters/src/enterpriseCompatibilityTest/java/com/gradle/develocity/agent/gradle/adapters/enterprise/BuildScanExtensionAdapterTest.java +++ b/develocity-gradle-plugin-adapters/src/enterpriseCompatibilityTest/java/com/gradle/develocity/agent/gradle/adapters/enterprise/BuildScanExtensionAdapterTest.java @@ -1,6 +1,5 @@ package com.gradle.develocity.agent.gradle.adapters.enterprise; -import com.gradle.develocity.agent.gradle.adapters.ActionMockFixtures; import com.gradle.develocity.agent.gradle.adapters.ActionMockFixtures.ArgCapturingAction; import com.gradle.develocity.agent.gradle.adapters.BuildResultAdapter; import com.gradle.develocity.agent.gradle.adapters.BuildScanAdapter; @@ -17,6 +16,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; +import java.net.URI; import java.util.Collections; import static com.gradle.develocity.agent.gradle.adapters.ActionMockFixtures.doExecuteActionWith; @@ -158,11 +158,16 @@ void testBackgroundAction() { @Test @DisplayName("can run the build finished action using the proxy") + @SuppressWarnings("Convert2Lambda") void testBuildFinishedAction() { // given Throwable failure = new RuntimeException("Boom!"); - BuildResult buildResult = mock(); - when(buildResult.getFailure()).thenReturn(failure); + BuildResult buildResult = new BuildResult() { + @Override + public Throwable getFailure() { + return failure; + } + }; doExecuteActionWith(buildResult).when(extension).buildFinished(any()); // when @@ -177,8 +182,17 @@ void testBuildFinishedAction() { @DisplayName("can run the build scan published action using the proxy") void testBuildScanPublishedAction() { // given - PublishedBuildScan scan = mock(); - when(scan.getBuildScanId()).thenReturn("scanId"); + PublishedBuildScan scan = new PublishedBuildScan() { + @Override + public String getBuildScanId() { + return "scanId"; + } + + @Override + public URI getBuildScanUri() { + return null; + } + }; doExecuteActionWith(scan).when(extension).buildScanPublished(any()); // when diff --git a/develocity-gradle-plugin-adapters/src/enterpriseCompatibilityTest/java/com/gradle/develocity/agent/gradle/adapters/enterprise/BuildScanExtension_1_X_AdapterTest.java b/develocity-gradle-plugin-adapters/src/enterpriseCompatibilityTest/java/com/gradle/develocity/agent/gradle/adapters/enterprise/BuildScanExtension_1_X_AdapterTest.java index f7eda01..889cb76 100644 --- a/develocity-gradle-plugin-adapters/src/enterpriseCompatibilityTest/java/com/gradle/develocity/agent/gradle/adapters/enterprise/BuildScanExtension_1_X_AdapterTest.java +++ b/develocity-gradle-plugin-adapters/src/enterpriseCompatibilityTest/java/com/gradle/develocity/agent/gradle/adapters/enterprise/BuildScanExtension_1_X_AdapterTest.java @@ -1,18 +1,20 @@ package com.gradle.develocity.agent.gradle.adapters.enterprise; -import com.gradle.develocity.agent.gradle.adapters.ActionMockFixtures; import com.gradle.develocity.agent.gradle.adapters.ActionMockFixtures.ArgCapturingAction; import com.gradle.develocity.agent.gradle.adapters.BuildResultAdapter; import com.gradle.develocity.agent.gradle.adapters.DevelocityAdapter; import com.gradle.develocity.agent.gradle.adapters.PublishedBuildScanAdapter; import com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension; +import com.gradle.scan.plugin.BuildResult; import com.gradle.scan.plugin.BuildScanExtension; +import com.gradle.scan.plugin.PublishedBuildScan; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; +import java.net.URI; import java.util.Collections; import static com.gradle.develocity.agent.gradle.adapters.ActionMockFixtures.doExecuteActionWith; @@ -25,7 +27,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; -import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) public class BuildScanExtension_1_X_AdapterTest { @@ -221,11 +222,16 @@ void testBackgroundAction() { @Test @DisplayName("build finished action can be configured via an adapter using the new build result model") + @SuppressWarnings("Convert2Lambda") void testBuildFinishedAction() { // given Throwable failure = new RuntimeException("Old build failure!"); - com.gradle.scan.plugin.BuildResult buildResult = mock(); - when(buildResult.getFailure()).thenReturn(failure); + BuildResult buildResult = new BuildResult() { + @Override + public Throwable getFailure() { + return failure; + } + }; // and doExecuteActionWith(buildResult).when(extension).buildFinished(any()); @@ -242,8 +248,17 @@ void testBuildFinishedAction() { @DisplayName("build scan published action can be configured via an adapter using the new scan model") void testBuildScanPublishedAction() { // given - com.gradle.scan.plugin.PublishedBuildScan publishedScan = mock(); - when(publishedScan.getBuildScanId()).thenReturn("scanId"); + PublishedBuildScan publishedScan = new PublishedBuildScan() { + @Override + public String getBuildScanId() { + return "scanId"; + } + + @Override + public URI getBuildScanUri() { + return null; + } + }; doExecuteActionWith(publishedScan).when(extension).buildScanPublished(any()); // when