Search in sources :

Example 46 with CommandParameters

use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.

the class AccuRevExportCommandTest method testExportToVersionPre490.

@Test
public void testExportToVersionPre490() throws Exception {
    // info defaults to no workspace...
    info.setWorkSpace(null);
    when(accurev.info(basedir)).thenReturn(info);
    // A version that does not support pop -t
    when(accurev.getClientVersion()).thenReturn("4.7.4b");
    List<File> poppedFiles = Collections.singletonList(new File("exported/file"));
    when(accurev.popExternal(eq(basedir), eq("mySnapShot"), eq("now"), (Collection<File>) argThat(hasItem(new File("/./project/dir"))))).thenReturn(poppedFiles);
    AccuRevExportCommand command = new AccuRevExportCommand(getLogger());
    CommandParameters params = new CommandParameters();
    params.setScmVersion(CommandParameter.SCM_VERSION, new ScmTag("mySnapShot/676"));
    ExportScmResult result = command.export(repo, new ScmFileSet(basedir), params);
    assertTrue(result.isSuccess());
    assertHasScmFile(result.getExportedFiles(), "exported/file", ScmFileStatus.CHECKED_OUT);
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmTag(org.apache.maven.scm.ScmTag) ExportScmResult(org.apache.maven.scm.command.export.ExportScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) File(java.io.File) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 47 with CommandParameters

use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.

the class AccuRevExportCommandTest method testExportToVersion490.

@Test
public void testExportToVersion490() throws Exception {
    // info defaults to no workspace...
    info.setWorkSpace(null);
    when(accurev.info(basedir)).thenReturn(info);
    // A version that does not support pop -t
    when(accurev.getClientVersion()).thenReturn("4.9.0");
    List<File> poppedFiles = Collections.singletonList(new File("exported/file"));
    when(accurev.popExternal(eq(basedir), eq("mySnapShot"), eq("676"), (Collection<File>) argThat(hasItem(new File("/./project/dir"))))).thenReturn(poppedFiles);
    AccuRevExportCommand command = new AccuRevExportCommand(getLogger());
    CommandParameters params = new CommandParameters();
    params.setScmVersion(CommandParameter.SCM_VERSION, new ScmTag("mySnapShot/676"));
    ExportScmResult result = command.export(repo, new ScmFileSet(basedir), params);
    assertTrue(result.isSuccess());
    assertHasScmFile(result.getExportedFiles(), "exported/file", ScmFileStatus.CHECKED_OUT);
    verify(accurev).syncReplica();
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmTag(org.apache.maven.scm.ScmTag) ExportScmResult(org.apache.maven.scm.command.export.ExportScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) File(java.io.File) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 48 with CommandParameters

use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.

the class AccuRevExportCommandTest method testExportVersionOutSideWorkspace.

@Test
public void testExportVersionOutSideWorkspace() throws Exception {
    // info defaults to no workspace...
    info.setWorkSpace(null);
    when(accurev.info(basedir)).thenReturn(info);
    List<File> poppedFiles = Collections.singletonList(new File("exported/file"));
    when(accurev.popExternal(eq(basedir), eq("mySnapShot"), eq((String) null), (Collection<File>) argThat(hasItem(new File("/./project/dir"))))).thenReturn(poppedFiles);
    AccuRevExportCommand command = new AccuRevExportCommand(getLogger());
    CommandParameters params = new CommandParameters();
    params.setScmVersion(CommandParameter.SCM_VERSION, new ScmTag("mySnapShot"));
    ExportScmResult result = command.export(repo, new ScmFileSet(basedir), params);
    assertTrue(result.isSuccess());
    assertHasScmFile(result.getExportedFiles(), "exported/file", ScmFileStatus.CHECKED_OUT);
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmTag(org.apache.maven.scm.ScmTag) ExportScmResult(org.apache.maven.scm.command.export.ExportScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) File(java.io.File) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 49 with CommandParameters

use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.

the class AccuRevRemoveCommandTest method testRemove.

@Test
public void testRemove() throws Exception {
    final ScmFileSet testFileSet = new ScmFileSet(basedir, new File("src/main/java/Foo.java"));
    List<File> removedFiles = Collections.singletonList(new File("removed/file"));
    when(accurev.defunct(basedir, testFileSet.getFileList(), "A deleted file")).thenReturn(removedFiles);
    AccuRevRemoveCommand command = new AccuRevRemoveCommand(getLogger());
    CommandParameters commandParameters = new CommandParameters();
    commandParameters.setString(CommandParameter.MESSAGE, "A deleted file");
    RemoveScmResult result = command.remove(repo, testFileSet, commandParameters);
    assertThat(result.isSuccess(), is(true));
    assertThat(result.getRemovedFiles().size(), is(1));
    assertHasScmFile(result.getRemovedFiles(), "removed/file", ScmFileStatus.DELETED);
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) CommandParameters(org.apache.maven.scm.CommandParameters) File(java.io.File) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 50 with CommandParameters

use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.

the class AccuRevStatusCommandTest method testStatus.

@Test
public void testStatus() throws Exception {
    final ScmFileSet testFileSet = getScmFileSet();
    File keptFile = new File("kept/file");
    File keptAdded = new File("kept/added");
    // this is the special one, it is returned by both the kept and defunct stat calls, so the command
    // needs to filter it out.
    File keptDefunct = new File("kept/defunct");
    File modifiedFile = new File("modified/file");
    File modifiedAdded = new File("modified/added");
    File missingFile = new File("missing/file");
    File externalFile = new File("external/file");
    when(accurev.stat(eq(basedir), anyListOf(File.class), eq(AccuRevStat.DEFUNCT))).thenReturn(Arrays.asList(keptDefunct));
    when(accurev.stat(eq(basedir), anyListOf(File.class), eq(AccuRevStat.MODIFIED))).thenReturn(Arrays.asList(modifiedFile, modifiedAdded));
    when(accurev.stat(eq(basedir), anyListOf(File.class), eq(AccuRevStat.KEPT))).thenReturn(Arrays.asList(keptDefunct, keptFile, keptAdded));
    when(accurev.stat(eq(basedir), anyListOf(File.class), eq(AccuRevStat.MISSING))).thenReturn(Arrays.asList(missingFile));
    when(accurev.stat(eq(basedir), anyListOf(File.class), eq(AccuRevStat.EXTERNAL))).thenReturn(Arrays.asList(externalFile));
    CategorisedElements catElems = new CategorisedElements();
    catElems.getMemberElements().addAll(Arrays.asList(modifiedFile, keptFile));
    catElems.getNonMemberElements().addAll(Arrays.asList(modifiedAdded, keptAdded));
    when(accurev.statBackingStream(eq(basedir), (Collection<File>) argThat(hasItems(modifiedFile, modifiedAdded, keptFile, keptAdded)))).thenReturn(catElems);
    AccuRevStatusCommand command = new AccuRevStatusCommand(getLogger());
    CommandParameters commandParameters = new CommandParameters();
    StatusScmResult result = command.status(repo, testFileSet, commandParameters);
    assertThat(result.isSuccess(), is(true));
    assertThat(result.getChangedFiles().size(), is(7));
    assertThat((List<ScmFile>) result.getChangedFiles(), not(Matchers.<ScmFile>hasItem(scmFile("kept/defunct", ScmFileStatus.MODIFIED))));
    assertHasScmFile(result.getChangedFiles(), "kept/file", ScmFileStatus.MODIFIED);
    assertHasScmFile(result.getChangedFiles(), "kept/added", ScmFileStatus.ADDED);
    assertHasScmFile(result.getChangedFiles(), "kept/defunct", ScmFileStatus.DELETED);
    assertHasScmFile(result.getChangedFiles(), "modified/file", ScmFileStatus.MODIFIED);
    assertHasScmFile(result.getChangedFiles(), "modified/added", ScmFileStatus.ADDED);
    assertHasScmFile(result.getChangedFiles(), "missing/file", ScmFileStatus.MISSING);
    assertHasScmFile(result.getChangedFiles(), "external/file", ScmFileStatus.UNKNOWN);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmFileSet(org.apache.maven.scm.ScmFileSet) CategorisedElements(org.apache.maven.scm.provider.accurev.CategorisedElements) CommandParameters(org.apache.maven.scm.CommandParameters) ScmFile(org.apache.maven.scm.ScmFile) ScmFileMatcher.scmFile(org.apache.maven.scm.ScmFileMatcher.scmFile) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Aggregations

CommandParameters (org.apache.maven.scm.CommandParameters)68 ScmFileSet (org.apache.maven.scm.ScmFileSet)44 File (java.io.File)39 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)38 Test (org.junit.Test)38 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)23 ScmFile (org.apache.maven.scm.ScmFile)8 ScmTag (org.apache.maven.scm.ScmTag)7 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)7 Date (java.util.Date)6 ChangeFile (org.apache.maven.scm.ChangeFile)5 ChangeFileMatcher.changeFile (org.apache.maven.scm.ChangeFileMatcher.changeFile)5 ScmRevision (org.apache.maven.scm.ScmRevision)5 ExportScmResult (org.apache.maven.scm.command.export.ExportScmResult)5 InfoScmResult (org.apache.maven.scm.command.info.InfoScmResult)5 LoginScmResult (org.apache.maven.scm.command.login.LoginScmResult)5 AccuRevInfo (org.apache.maven.scm.provider.accurev.AccuRevInfo)5 Transaction (org.apache.maven.scm.provider.accurev.Transaction)5 ArrayList (java.util.ArrayList)4 ScmException (org.apache.maven.scm.ScmException)4