ConnectCommandRunner extends AbstractServerCommandRunner { @NotNull @Override public P4CommandRunner.QueryAnswer<ListFilesDetailsResult> listFilesDetails( @NotNull ClientConfig config, @NotNull final ListFilesDetailsQuery query) { final List<IFileSpec> fileSpecs = FileSpecBuildUtil.escapedForFilePathsAnnotated( query.getFiles(), query.getRevState() == ListFilesDetailsQuery.RevState.HEAD ? "#head" : "#have", true); return new QueryAnswerImpl<>(connectionManager.withConnection(config, (client) -> new ListFilesDetailsResult(config, cmd.getFilesDetails( client, fileSpecs, query.getMaxResultCount() ).stream() .map((e) -> query.getRevState() == ListFilesDetailsQuery.RevState.HEAD ? P4FileRevisionImpl.getHead(config.getClientServerRef(), e) : P4FileRevisionImpl.getHave(config.getClientServerRef(), e) ) .collect(Collectors.toList())))); } 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 listFilesDetails_have_is_head(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 P4ChangelistId defaultId = new P4ChangelistIdImpl(0, clientConfig.getClientServerRef()); final int[] committedChangelistId = { 0 }; setupClient(clientConfig, tmpDir, clientRoot) .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 SubmitChangelistAction( new P4ChangelistIdImpl(0, clientConfig.getClientServerRef()), Collections.singletonList(newFile), null, "add file", null))) .whenCompleted(res -> committedChangelistId[0] = res.getChangelistId().getChangelistId()) .mapQueryAsync((res) -> runner.listFilesDetails(clientConfig, new ListFilesDetailsQuery( Collections.singletonList(newFile.getParentPath()), ListFilesDetailsQuery.RevState.HAVE, 100))) .whenCompleted(sink::resolve) .whenServerError(sink::reject) ) .whenCompleted((r) -> { assertNotNull(r); assertThat(r, instanceOf(ListFilesDetailsResult.class)); ListFilesDetailsResult res = (ListFilesDetailsResult) r; assertSame(clientConfig, res.getClientConfig()); assertSize(1, res.getFiles()); assertEquals(1, res.getFiles().size()); P4FileRevision details = res.getFiles().get(0); assertNotNull(details.getDate()); assertNotNull(details.getChangelistId()); assertEquals(committedChangelistId[0], details.getChangelistId().getChangelistId()); assertEquals(1, details.getRevision().getLongRevisionNumber()); assertEquals(P4FileAction.ADD, details.getFileAction()); assertEquals(P4FileType.BaseType.TEXT, details.getFileType().getBaseType()); assertNull(details.getIntegratedFrom()); P4RemoteFile file = details.getFile(); assertNotNull(file); assertEquals(" assertEquals(" }) .whenFailed(Assertions::fail); }
@ExtendWith(TemporaryFolderExtension.class) @Test void listFilesDetails_have_not_head(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 P4ChangelistId defaultId = new P4ChangelistIdImpl(0, clientConfig.getClientServerRef()); final int[] committedChangelistId = { 0, 0 }; setupClient(clientConfig, tmpDir, clientRoot) .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 SubmitChangelistAction( new P4ChangelistIdImpl(0, clientConfig.getClientServerRef()), Collections.singletonList(newFile), null, "add file", null))) .whenCompleted(res -> committedChangelistId[0] = res.getChangelistId().getChangelistId()) .mapActionAsync((res) -> runner.perform( clientConfig, new AddEditAction(newFile, null, defaultId, clientConfig.getCharSetName()))) .mapActionAsync((res) -> runner.perform( clientConfig, new SubmitChangelistAction( new P4ChangelistIdImpl(0, clientConfig.getClientServerRef()), Collections.singletonList(newFile), null, "add file", null))) .whenCompleted(res -> committedChangelistId[1] = res.getChangelistId().getChangelistId()) .mapActionAsync(res -> runner.perform( clientConfig, new FetchFilesAction(Collections.singletonList(newFile), "@" + committedChangelistId[0], false))) .mapQueryAsync((res) -> runner.listFilesDetails( clientConfig, new ListFilesDetailsQuery( Collections.singletonList(newFile.getParentPath()), ListFilesDetailsQuery.RevState.HAVE, 100))) .whenCompleted(sink::resolve) .whenServerError(sink::reject) ) .whenCompleted((r) -> { assertNotNull(r); assertThat(r, instanceOf(ListFilesDetailsResult.class)); ListFilesDetailsResult res = (ListFilesDetailsResult) r; assertSame(clientConfig, res.getClientConfig()); assertSize(1, res.getFiles()); assertEquals(1, res.getFiles().size()); P4FileRevision details = res.getFiles().get(0); assertNotNull(details.getDate()); assertNotNull(details.getChangelistId()); assertEquals(committedChangelistId[0], details.getChangelistId().getChangelistId()); assertEquals(1, details.getRevision().getLongRevisionNumber()); assertEquals(P4FileAction.ADD, details.getFileAction()); assertEquals(P4FileType.BaseType.TEXT, details.getFileType().getBaseType()); assertNull(details.getIntegratedFrom()); P4RemoteFile file = details.getFile(); assertNotNull(file); assertEquals(" assertEquals(" }) .whenFailed(Assertions::fail); }
@ExtendWith(TemporaryFolderExtension.class) @Test void listFilesDetails_head_have_head(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 P4ChangelistId defaultId = new P4ChangelistIdImpl(0, clientConfig.getClientServerRef()); final int[] committedChangelistId = { 0, 0 }; setupClient(clientConfig, tmpDir, clientRoot) .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 SubmitChangelistAction( new P4ChangelistIdImpl(0, clientConfig.getClientServerRef()), Collections.singletonList(newFile), null, "add file", null))) .whenCompleted(res -> committedChangelistId[0] = res.getChangelistId().getChangelistId()) .mapActionAsync((res) -> runner.perform( clientConfig, new AddEditAction(newFile, null, defaultId, clientConfig.getCharSetName()))) .mapActionAsync((res) -> runner.perform( clientConfig, new SubmitChangelistAction( new P4ChangelistIdImpl(0, clientConfig.getClientServerRef()), Collections.singletonList(newFile), null, "add file", null))) .whenCompleted(res -> committedChangelistId[1] = res.getChangelistId().getChangelistId()) .mapQueryAsync((res) -> runner.listFilesDetails( clientConfig, new ListFilesDetailsQuery( Collections.singletonList(newFile.getParentPath()), ListFilesDetailsQuery.RevState.HEAD, 100))) .whenCompleted(sink::resolve) .whenServerError(sink::reject) ) .whenCompleted((r) -> { assertNotNull(r); assertThat(r, instanceOf(ListFilesDetailsResult.class)); ListFilesDetailsResult res = (ListFilesDetailsResult) r; assertSame(clientConfig, res.getClientConfig()); assertSize(1, res.getFiles()); assertEquals(1, res.getFiles().size()); P4FileRevision details = res.getFiles().get(0); assertNotNull(details.getDate()); assertNotNull(details.getChangelistId()); assertEquals(committedChangelistId[1], details.getChangelistId().getChangelistId()); assertEquals(2, details.getRevision().getLongRevisionNumber()); assertEquals(P4FileAction.EDIT, details.getFileAction()); assertEquals(P4FileType.BaseType.TEXT, details.getFileType().getBaseType()); assertNull(details.getIntegratedFrom()); P4RemoteFile file = details.getFile(); assertNotNull(file); assertEquals(" assertEquals(" }) .whenFailed(Assertions::fail); }
@ExtendWith(TemporaryFolderExtension.class) @Test void listFilesDetails_head_have_not_head(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 P4ChangelistId defaultId = new P4ChangelistIdImpl(0, clientConfig.getClientServerRef()); final int[] committedChangelistId = { 0, 0 }; setupClient(clientConfig, tmpDir, clientRoot) .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 SubmitChangelistAction( new P4ChangelistIdImpl(0, clientConfig.getClientServerRef()), Collections.singletonList(newFile), null, "add file", null))) .whenCompleted(res -> committedChangelistId[0] = res.getChangelistId().getChangelistId()) .mapActionAsync((res) -> runner.perform( clientConfig, new AddEditAction(newFile, null, defaultId, clientConfig.getCharSetName()))) .mapActionAsync((res) -> runner.perform( clientConfig, new SubmitChangelistAction( new P4ChangelistIdImpl(0, clientConfig.getClientServerRef()), Collections.singletonList(newFile), null, "add file", null))) .whenCompleted(res -> committedChangelistId[1] = res.getChangelistId().getChangelistId()) .mapActionAsync(res -> runner.perform( clientConfig, new FetchFilesAction(Collections.singletonList(newFile), "@" + committedChangelistId[0], false))) .mapQueryAsync((res) -> runner.listFilesDetails( clientConfig, new ListFilesDetailsQuery( Collections.singletonList(newFile.getParentPath()), ListFilesDetailsQuery.RevState.HEAD, 100))) .whenCompleted(sink::resolve) .whenServerError(sink::reject) ) .whenCompleted((r) -> { assertNotNull(r); assertThat(r, instanceOf(ListFilesDetailsResult.class)); ListFilesDetailsResult res = (ListFilesDetailsResult) r; assertSame(clientConfig, res.getClientConfig()); assertSize(1, res.getFiles()); assertEquals(1, res.getFiles().size()); P4FileRevision details = res.getFiles().get(0); assertNotNull(details.getDate()); assertNotNull(details.getChangelistId()); assertEquals(committedChangelistId[1], details.getChangelistId().getChangelistId()); assertEquals(2, details.getRevision().getLongRevisionNumber()); assertEquals(P4FileAction.EDIT, details.getFileAction()); assertEquals(P4FileType.BaseType.TEXT, details.getFileType().getBaseType()); assertNull(details.getIntegratedFrom()); P4RemoteFile file = details.getFile(); assertNotNull(file); assertEquals(" assertEquals(" }) .whenFailed(Assertions::fail); }