albertogpz commented on a change in pull request #7108: URL: https://github.com/apache/geode/pull/7108#discussion_r753436317
########## File path: geode-gfsh/src/test/java/org/apache/geode/management/internal/cli/commands/StopGatewaySenderCommandTest.java ########## @@ -0,0 +1,91 @@ +/* + * 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.geode.management.internal.cli.commands; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; + +import org.apache.geode.distributed.DistributedMember; +import org.apache.geode.management.internal.SystemManagementService; +import org.apache.geode.management.internal.cli.result.model.ResultModel; +import org.apache.geode.management.internal.functions.CliFunctionResult; +import org.apache.geode.test.junit.rules.GfshParserRule; + +public class StopGatewaySenderCommandTest { + @ClassRule + public static GfshParserRule gfsh = new GfshParserRule(); + + private StopGatewaySenderCommand command; + + @Before + public void before() { + command = spy(StopGatewaySenderCommand.class); + List<CliFunctionResult> functionResults = new ArrayList<>(); + doReturn(functionResults).when(command).executeAndGetFunctionResult(any(), any(), any()); Review comment: @kirklund Thanks a lot for the suggestion. I finally have not needed to modify `GfshCommand`. Nevertheless, I had to inject the command delegate and the `findMembers` test behavior using the constructor. The outcome has not been very clean. If you have any suggestions to make it cleaner, please let me know. Given that `findMembers` is not a static method, I could not pass it when calling the last constructor. Instead, I had to set it after I called it. Something similar happened when trying to inject the delegate to the command. -- 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]
