Search in sources :

Example 11 with CommandParameters

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

the class AccuRevChangeLogCommandTest method testChangeLogFailed.

@Test
public void testChangeLogFailed() throws Exception {
    // Workspace to root stream, keeps and promotes
    // Setup test data so that the checkin area is the repo's project path.
    final ScmFileSet testFileSet = new ScmFileSet(new File(basedir, "project/dir"));
    final Date dateFrom = getDate(2009, 0, 01, 10, 00, 00, null);
    final Date dateTo = getDate(2009, 0, 12, 13, 00, 00, null);
    // start tran (35)
    List<Transaction> startTransaction = Collections.singletonList(new Transaction(35L, new Date(), "sometran", "anyone"));
    when(accurev.history("myStream", "2009/01/01 10:00:00", null, 1, true, true)).thenReturn(startTransaction);
    // end tran (42)
    List<Transaction> endTransaction = Collections.singletonList(new Transaction(42L, new Date(), "sometran", "anyone"));
    when(accurev.history("myStream", "2009/01/12 13:00:00", null, 1, true, true)).thenReturn(endTransaction);
    when(accurev.history(eq("myStream"), any(String.class), any(String.class), eq(0), eq(false), eq(false))).thenReturn(null);
    AccuRevChangeLogCommand command = new AccuRevChangeLogCommand(getLogger());
    CommandParameters commandParameters = new CommandParameters();
    commandParameters.setString(CommandParameter.MESSAGE, "A commit message");
    commandParameters.setDate(CommandParameter.START_DATE, dateFrom);
    commandParameters.setDate(CommandParameter.END_DATE, dateTo);
    ChangeLogScmResult result = command.changelog(repo, testFileSet, commandParameters);
    assertThat(result.isSuccess(), is(false));
    assertThat(result.getProviderMessage(), notNullValue());
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) Transaction(org.apache.maven.scm.provider.accurev.Transaction) ChangeLogScmResult(org.apache.maven.scm.command.changelog.ChangeLogScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) ChangeFile(org.apache.maven.scm.ChangeFile) ChangeFileMatcher.changeFile(org.apache.maven.scm.ChangeFileMatcher.changeFile) File(java.io.File) Date(java.util.Date) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 12 with CommandParameters

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

the class AccuRevCheckInCommandTest method testCheckInFailure.

@Test
public void testCheckInFailure() throws Exception {
    // Setup test data so that the checkin area is the repo's project path.
    final ScmFileSet testFileSet = new ScmFileSet(new File(basedir, "project/dir"));
    final File basedir = testFileSet.getBasedir();
    final AccuRevInfo info = new AccuRevInfo(basedir);
    info.setTop(basedir.getAbsolutePath());
    when(accurev.info(basedir)).thenReturn(info);
    when(accurev.promoteAll(basedir, "A commit message")).thenReturn(null);
    AccuRevCheckInCommand command = new AccuRevCheckInCommand(getLogger());
    CommandParameters commandParameters = new CommandParameters();
    commandParameters.setString(CommandParameter.MESSAGE, "A commit message");
    CheckInScmResult result = command.checkIn(repo, testFileSet, commandParameters);
    assertThat(result.isSuccess(), is(false));
    assertThat(result.getProviderMessage(), notNullValue());
}
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) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 13 with CommandParameters

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

the class AccuRevLoginCommandTest method testWhenAlreadyLoggedInAsRequiredUser.

@Test
public void testWhenAlreadyLoggedInAsRequiredUser() throws Exception {
    repo.setUser("myUser");
    repo.setPassword("aPassword");
    info.setUser("myUser");
    when(accurev.info(any(File.class))).thenReturn(info);
    AccuRevLoginCommand command = new AccuRevLoginCommand(getLogger());
    LoginScmResult result = command.login(repo, new ScmFileSet(basedir), new CommandParameters());
    assertThat(result.isSuccess(), is(true));
    // This is an important case as logging in will start an expiry timer
    // that might be shorter than the current expiry timer!
    verify(accurev, never()).login(eq("myUser"), anyString());
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) LoginScmResult(org.apache.maven.scm.command.login.LoginScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) File(java.io.File) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 14 with CommandParameters

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

the class AccuRevLoginCommandTest method testWhenAlreadyLoggedInAsSomeoneElse.

@Test
public void testWhenAlreadyLoggedInAsSomeoneElse() throws Exception {
    repo.setUser("myUser");
    repo.setPassword("aPassword");
    info.setUser("A.N.Other");
    when(accurev.info(any(File.class))).thenReturn(info);
    when(accurev.login("myUser", "aPassword")).thenReturn(true);
    AccuRevLoginCommand command = new AccuRevLoginCommand(getLogger());
    LoginScmResult result = command.login(repo, new ScmFileSet(basedir), new CommandParameters());
    assertThat(result.isSuccess(), is(true));
    verify(accurev).login("myUser", "aPassword");
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) LoginScmResult(org.apache.maven.scm.command.login.LoginScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) File(java.io.File) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 15 with CommandParameters

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

the class AccuRevAddCommandTest method testAdd.

@Test
public void testAdd() 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(Collections.singletonList(new File("added/file")));
    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(true));
    assertThat(result.getAddedFiles().size(), is(1));
    assertHasScmFile(result.getAddedFiles(), "added/file", ScmFileStatus.ADDED);
}
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)

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