gnodet-bot commented on code in PR #13542:
URL: https://github.com/apache/maven/pull/13542#discussion_r4330423121


##########
impl/maven-core/src/test/java/org/apache/maven/internal/build/DefaultBuildInvocationTest.java:
##########
@@ -0,0 +1,391 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.maven.internal.build;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.maven.api.BuildInvocation;
+import org.apache.maven.api.MakeBehavior;
+import org.apache.maven.api.ReactorFailureBehavior;
+import org.apache.maven.execution.DefaultMavenExecutionRequest;
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenSession;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class DefaultBuildInvocationTest {
+
+    private static MavenExecutionRequest newRequest() {
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest();
+        request.setLocalRepositoryPath(new File("/tmp/test-repo"));
+        return request;
+    }
+
+    @Test
+    void fromBasicRequest() {
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest();
+        request.setGoals(List.of("clean", "install"));
+        request.setOffline(true);
+        request.setUpdateSnapshots(true);
+        request.setInteractiveMode(false);
+        
request.setReactorFailureBehavior(MavenExecutionRequest.REACTOR_FAIL_AT_END);
+
+        MavenSession session = mock(MavenSession.class);
+        when(session.getRequest()).thenReturn(request);
+
+        BuildInvocation inv = DefaultBuildInvocation.from(session);
+
+        assertEquals(List.of("clean", "install"), inv.goals());
+        assertTrue(inv.offline());
+        assertTrue(inv.updateSnapshots());
+        assertTrue(inv.batchMode());
+        assertEquals(ReactorFailureBehavior.FAIL_AT_END, 
inv.reactorFailureBehavior());
+        assertTrue(inv.recursive());
+        assertFalse(inv.resume());
+        assertNull(inv.makeBehavior());
+        assertTrue(inv.excludedProjects().isEmpty());
+    }
+
+    @Test
+    void fromNullGoals() {
+        MavenExecutionRequest request = newRequest();
+        MavenSession session = mock(MavenSession.class);
+        when(session.getRequest()).thenReturn(request);
+
+        BuildInvocation inv = DefaultBuildInvocation.from(session);
+
+        assertNotNull(inv.goals());
+        assertTrue(inv.goals().isEmpty());
+    }
+
+    @Test
+    void fromNullActiveProfiles() {
+        MavenExecutionRequest request = newRequest();
+        MavenSession session = mock(MavenSession.class);
+        when(session.getRequest()).thenReturn(request);
+
+        BuildInvocation inv = DefaultBuildInvocation.from(session);
+
+        assertNotNull(inv.activeProfiles());
+        assertTrue(inv.activeProfiles().isEmpty());
+    }
+
+    @Test
+    void fromNullSelectedProjects() {
+        MavenExecutionRequest request = newRequest();
+        MavenSession session = mock(MavenSession.class);
+        when(session.getRequest()).thenReturn(request);
+
+        BuildInvocation inv = DefaultBuildInvocation.from(session);
+
+        assertNotNull(inv.selectedProjects());
+        assertTrue(inv.selectedProjects().isEmpty());
+    }
+
+    @Test
+    void fromNullLocalRepositoryPathThrows() {
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest();
+        MavenSession session = mock(MavenSession.class);
+        when(session.getRequest()).thenReturn(request);
+
+        assertThrows(IllegalStateException.class, () -> 
DefaultBuildInvocation.from(session));
+    }

Review Comment:
   ❌ **Broken test — will fail at CI.** The commit that dropped 
`localRepository()` also removed the `IllegalStateException` guard from 
`DefaultBuildInvocation.from()`. This test asserts the exception is thrown, but 
the throw no longer exists. Delete this test method.
   
   ```suggestion
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to