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);
}
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();
}
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);
}
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);
}
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);
}
Aggregations