Search in sources :

Example 51 with CommandParameters

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

the class AccuRevTagCommandTest method testTag.

@Test
public void testTag() throws Exception {
    final ScmFileSet testFileSet = new ScmFileSet(new File("/my/workspace/project/dir"));
    final File basedir = testFileSet.getBasedir();
    final String basisStream = "basisStream";
    final AccuRevInfo info = new AccuRevInfo(basedir);
    info.setBasis(basisStream);
    AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
    repo.setStreamName("myStream");
    repo.setAccuRev(accurev);
    repo.setProjectPath("/project/dir");
    when(accurev.info(basedir)).thenReturn(info);
    when(accurev.mksnap("theTagName", basisStream)).thenReturn(Boolean.TRUE);
    List<File> taggedFiles = Collections.singletonList(new File("tagged/file"));
    when(accurev.statTag("theTagName")).thenReturn(taggedFiles);
    AccuRevTagCommand command = new AccuRevTagCommand(getLogger());
    CommandParameters commandParameters = new CommandParameters();
    commandParameters.setString(CommandParameter.TAG_NAME, "theTagName");
    TagScmResult result = command.tag(repo, testFileSet, commandParameters);
    assertThat(result.isSuccess(), is(true));
    assertThat(result.getTaggedFiles().size(), is(1));
    assertHasScmFile(result.getTaggedFiles(), "tagged/file", ScmFileStatus.TAGGED);
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) AccuRevScmProviderRepository(org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository) CommandParameters(org.apache.maven.scm.CommandParameters) TagScmResult(org.apache.maven.scm.command.tag.TagScmResult) File(java.io.File) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 52 with CommandParameters

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

the class AccurevUpdateCommandTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    final File keptFile = new File("updated/file");
    final File keptAdded = new File("new/file");
    List<File> files = Arrays.asList(keptFile, keptAdded);
    when(accurev.update(eq(basedir), any(String.class))).thenReturn(files);
    AccuRevUpdateCommand command = new AccuRevUpdateCommand(getLogger());
    CommandParameters commandParameters = new CommandParameters();
    commandParameters.setString(CommandParameter.RUN_CHANGELOG_WITH_UPDATE, Boolean.toString(false));
    UpdateScmResult result = command.update(repo, testFileSet, commandParameters);
    assertThat(result.isSuccess(), is(true));
    assertThat(result.getUpdatedFiles().size(), is(2));
    assertHasScmFile(result.getUpdatedFiles(), "updated/file", ScmFileStatus.UPDATED);
    assertHasScmFile(result.getUpdatedFiles(), "new/file", ScmFileStatus.UPDATED);
}
Also used : UpdateScmResult(org.apache.maven.scm.command.update.UpdateScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) File(java.io.File) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 53 with CommandParameters

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

the class AccurevUpdateCommandTest method testUpdateWithChangeLog.

@Test
public void testUpdateWithChangeLog() throws Exception {
    final WorkSpace wsBefore = new WorkSpace("theWorkSpace", 123);
    Map<String, WorkSpace> workspaces = Collections.singletonMap("theWorkSpace", wsBefore);
    when(accurev.showWorkSpaces()).thenReturn(workspaces);
    List<File> emptyList = Collections.emptyList();
    when(accurev.update(eq(basedir), any(String.class))).thenReturn(emptyList);
    final Date currentDate = new Date();
    List<Transaction> transactions = Collections.singletonList(new Transaction(197L, currentDate, "type", "user"));
    when(accurev.history(any(String.class), any(String.class), any(String.class), eq(1), eq(true), eq(true))).thenReturn(transactions);
    AccuRevUpdateCommand command = new AccuRevUpdateCommand(getLogger());
    CommandParameters commandParameters = new CommandParameters();
    commandParameters.setString(CommandParameter.RUN_CHANGELOG_WITH_UPDATE, Boolean.toString(true));
    UpdateScmResult result = command.update(repo, testFileSet, commandParameters);
    assertThat(result.isSuccess(), is(true));
    assertThat(result, IsInstanceOf.instanceOf(AccuRevUpdateScmResult.class));
    AccuRevUpdateScmResult accuRevResult = (AccuRevUpdateScmResult) result;
    assertThat(accuRevResult.getFromRevision(), is("theWorkSpace/123"));
    assertThat(accuRevResult.getToRevision(), is("theWorkSpace/197"));
}
Also used : WorkSpace(org.apache.maven.scm.provider.accurev.WorkSpace) Transaction(org.apache.maven.scm.provider.accurev.Transaction) UpdateScmResult(org.apache.maven.scm.command.update.UpdateScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) File(java.io.File) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) Date(java.util.Date) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 54 with CommandParameters

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

the class AccuRevAddCommandTest method testAddFailed.

@Test
public void testAddFailed() throws Exception {
    final ScmFileSet testFileSet = new ScmFileSet(basedir, new File("src/main/java/Foo.java"));
    final List<File> files = testFileSet.getFileList();
    when(accurev.add(basedir, files, "A new file")).thenReturn(null);
    AccuRevAddCommand command = new AccuRevAddCommand(getLogger());
    CommandParameters commandParameters = new CommandParameters();
    commandParameters.setString(CommandParameter.MESSAGE, "A new file");
    AddScmResult result = command.add(repo, testFileSet, commandParameters);
    assertThat(result.isSuccess(), is(false));
    assertThat(result.getProviderMessage(), notNullValue());
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) AddScmResult(org.apache.maven.scm.command.add.AddScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) File(java.io.File) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 55 with CommandParameters

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

the class AccuRevBlameCommandTest method testBlame.

@Test
public void testBlame() throws Exception {
    final File file = new File("src/main/java/Foo.java");
    final ScmFileSet testFileSet = new ScmFileSet(basedir, file);
    final Date date = new Date();
    final BlameLine blameLine = new BlameLine(date, "12", "theAuthor");
    when(accurev.annotate(basedir, file)).thenReturn(Collections.singletonList(blameLine));
    AccuRevBlameCommand command = new AccuRevBlameCommand(getLogger());
    CommandParameters commandParameters = new CommandParameters();
    commandParameters.setString(CommandParameter.FILE, file.getPath());
    BlameScmResult result = command.blame(repo, testFileSet, commandParameters);
    assertThat(result.isSuccess(), is(true));
    assertThat(result.getLines().size(), is(1));
    assertThat(((BlameLine) result.getLines().get(0)), is(blameLine));
}
Also used : BlameLine(org.apache.maven.scm.command.blame.BlameLine) ScmFileSet(org.apache.maven.scm.ScmFileSet) BlameScmResult(org.apache.maven.scm.command.blame.BlameScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) File(java.io.File) Date(java.util.Date) 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