ConnectCommandRunner extends AbstractServerCommandRunner { private MoveFilesToChangelistResult moveFilesToChangelist(IClient client, ClientConfig config, MoveFilesToChangelistAction action) throws ConnectionException, AccessException, RequestException { if (action.getFiles().isEmpty()) { throw new IllegalArgumentException("must provide at least one file to move"); } if (LOG.isDebugEnabled()) { LOG.debug("Running move files to changelist against the server for " + action.getChangelistId() + " / " + action.getFiles()); } List<IFileSpec> res = cmd.reopenFiles(client, action.getFiles(), action.getChangelistId()); String info = null; List<P4RemoteFile> files = new ArrayList<>(res.size()); for (IFileSpec spec : res) { IServerMessage msg = spec.getStatusMessage(); if (msg != null) { if (msg.isInfo()) { info = msg.getLocalizedMessage(); } if (msg.isWarning() || msg.isError()) { throw new RequestException(msg); } } else { files.add(new P4RemoteFileImpl(spec)); } } return new MoveFilesToChangelistResult(config, action.getChangelistId(), info, files); } ConnectCommandRunner(
            @NotNull Project project,
            @NotNull ConnectionManager connectionManager); @Override void disconnect(@NotNull P4ServerName config); @NotNull @Override P4CommandRunner.QueryAnswer<AnnotateFileResult> getFileAnnotation(
            @NotNull ClientConfig config,
            @NotNull final AnnotateFileQuery query); @NotNull @Override P4CommandRunner.QueryAnswer<DescribeChangelistResult> describeChangelist(
            @NotNull OptionalClientServerConfig config,
            @NotNull DescribeChangelistQuery query); @NotNull @Override P4CommandRunner.QueryAnswer<GetJobSpecResult> getJobSpec(
            @NotNull OptionalClientServerConfig config); @NotNull @Override P4CommandRunner.QueryAnswer<ListOpenedFilesChangesResult> listOpenedFilesChanges(@NotNull ClientConfig config,
            @NotNull ListOpenedFilesChangesQuery query); @NotNull @Override P4CommandRunner.QueryAnswer<ListClientsForUserResult> getClientsForUser(
            @NotNull OptionalClientServerConfig config,
            @NotNull ListClientsForUserQuery query); @NotNull @Override P4CommandRunner.QueryAnswer<ListSubmittedChangelistsResult> listSubmittedChangelists(
            @NotNull final ClientConfig config, @NotNull final ListSubmittedChangelistsQuery query); @NotNull @Override P4CommandRunner.QueryAnswer<GetFileContentsResult> getFileContents(
            @NotNull ClientConfig config,
            @NotNull final GetFileContentsQuery query); @NotNull @Override P4CommandRunner.QueryAnswer<ListFileHistoryResult> listFilesHistory(
            @NotNull ClientConfig config,
            @NotNull final ListFileHistoryQuery query); @NotNull @Override P4CommandRunner.QueryAnswer<ListFilesDetailsResult> listFilesDetails(
            @NotNull ClientConfig config,
            @NotNull final ListFilesDetailsQuery query); @NotNull @Override P4CommandRunner.QueryAnswer<ListJobsResult> listJobs(
            @NotNull OptionalClientServerConfig config,
            @NotNull final ListJobsQuery query); @NotNull @Override P4CommandRunner.QueryAnswer<ListLabelsResult> listLabels(
            @NotNull OptionalClientServerConfig config,
            @NotNull final ListLabelsQuery query); @NotNull @Override P4CommandRunner.QueryAnswer<ListUsersResult> listUsers(
            @NotNull OptionalClientServerConfig config,
            @NotNull final ListUsersQuery query); @NotNull @Override P4CommandRunner.QueryAnswer<SwarmConfigResult> getSwarmConfig(
            @NotNull OptionalClientServerConfig config,
            @NotNull final SwarmConfigQuery query);  }
@ExtendWith(TemporaryFolderExtension.class) @Test void moveFilesToChangelist(TemporaryFolder tmpDir) throws IOException { idea.useInlineThreading(null); MockConfigPart part = new MockConfigPart() .withServerName(server.getRshUrl()) .withUsername(server.getUser()) .withNoPassword() .withClientname("client1"); final ServerConfig serverConfig = ServerConfig.createFrom(part); final ClientConfig clientConfig = ClientConfig.createFrom(serverConfig, part); final File clientRoot = tmpDir.newFile("clientRoot"); final FilePath newFile = VcsUtil.getFilePath(touchFile(clientRoot, "a@b.txt")); final TestableP4RequestErrorHandler errorHandler = new TestableP4RequestErrorHandler(idea.getMockProject()); final P4ChangelistId defaultId = new P4ChangelistIdImpl(0, clientConfig.getClientServerRef()); setupClient(clientConfig, tmpDir, clientRoot, errorHandler) .map((cm) -> new ConnectCommandRunner(idea.getMockProject(), cm)) .futureMap((runner, sink) -> runner.perform( clientConfig, new AddEditAction(newFile, null, defaultId, clientConfig.getCharSetName())) .mapActionAsync((res) -> runner.perform(clientConfig, new CreateChangelistAction(clientConfig.getClientServerRef(), "Destination change", "local-id"))) .mapActionAsync((res) -> runner.perform(clientConfig, new MoveFilesToChangelistAction( new P4ChangelistIdImpl(res.getChangelistId(), clientConfig.getClientServerRef()), Collections.singletonList(newFile)))) .whenCompleted(sink::resolve) .whenServerError(sink::reject) ) .whenCompleted((r) -> { assertThat(r, instanceOf(MoveFilesToChangelistResult.class)); MoveFilesToChangelistResult res = (MoveFilesToChangelistResult) r; assertSame(clientConfig, res.getClientConfig()); assertNull(res.getMessage()); assertSize(1, res.getFiles()); P4RemoteFile remote = res.getFiles().get(0); assertEquals(" assertEquals(" }) .whenFailed(Assertions::fail); }