use of org.apache.maven.scm.provider.accurev.Stream in project maven-scm by apache.
the class AccuRevChangeLogCommandTest method testStandardCase.
@Test
public void testStandardCase() 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"));
// stream 1 only => not found
// stream 2 only => created
// stream 1 and 2 => version or moved
// comment to contain all the changes eg file moved from to
// files to contain all the referenced files
// NOTE: The version specs, and stream numbers used in this test are
// important!!
// 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"));
Stream basisStream = new Stream("myStream", 10, "myDepot", 1, "myDepot", getDate(2008, 1, 1), "normal");
when(accurev.showStream("myStream")).thenReturn(basisStream);
when(accurev.history("myStream", "2009/01/12 13:00:00", null, 1, true, true)).thenReturn(endTransaction);
// now we call diff between the tran ids - 35 to 42
FileDifference promoted = new FileDifference(10L, "/promoted/file", "4/2", "/promoted/file", "6/1");
FileDifference removed = new FileDifference(20L, null, null, "/removed/file", "6/1");
FileDifference created = new FileDifference(30L, "/created/file", "6/1", null, null);
FileDifference moved = new FileDifference(40L, "/moved/to", "4/2", "/moved/from", "6/1");
when(accurev.diff("myStream", "35", "42")).thenReturn(Arrays.asList(promoted, removed, created, moved));
// and we call hist for tranid + 1 to end trand id
// getDate uses calendar's zero indexed months
final Date dateFrom = getDate(2009, 0, 1, 10, 0, 0, null);
final Date dateTo = getDate(2009, 0, 12, 13, 0, 0, null);
final Date keepWhen = getDate(2009, 0, 2, 9, 0, 0, null);
final Date promoteWhen = getDate(2009, 0, 4, 23, 0, 0, null);
final Transaction promoteOne = new Transaction(10L, keepWhen, "promote", "aUser");
promoteOne.addVersion(5L, "/./kept/file", "10/5", "5/5", "3/2");
promoteOne.setComment("a Comment");
final Transaction promoteTwo = new Transaction(12L, promoteWhen, "promote", "anOther");
promoteTwo.addVersion(10L, "/./promoted/file", "10/5", "4/2", null);
promoteTwo.setComment("my Promotion");
when(accurev.history("myStream", "36", "42", 0, false, false)).thenReturn(Arrays.asList(promoteOne, promoteTwo));
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(true));
List<ChangeSet> changeSets = result.getChangeLog().getChangeSets();
assertThat(changeSets.size(), is(3));
ChangeSet cs = (ChangeSet) changeSets.get(0);
assertThat(cs.getAuthor(), is("aUser"));
assertThat(cs.getComment(), is("a Comment"));
assertThat(cs.getDate(), is(keepWhen));
assertThat(cs.getFiles().size(), is(1));
ChangeFile cf = (ChangeFile) cs.getFiles().get(0);
assertThat(cf.getName(), is("/./kept/file"));
assertThat(cf.getRevision(), is("10/5 (5/5)"));
cs = (ChangeSet) changeSets.get(2);
assertThat(cs.getAuthor(), is("various"));
// created/removed/moved but not the file that was in the promoted
// set...
assertThat(cs.getComment(), is("Upstream changes"));
assertThat(cs.getFiles().size(), is(3));
assertThat(cs.containsFilename("created/file"), is(true));
}
use of org.apache.maven.scm.provider.accurev.Stream in project maven-scm by apache.
the class StreamsConsumer method startTag.
@Override
protected void startTag(List<String> tagPath, Map<String, String> attributes) {
String tagName = getTagName(tagPath);
if ("stream".equals(tagName)) {
String name = attributes.get("name");
long streamId = Long.parseLong(attributes.get("streamNumber"));
String basis = attributes.get("basis");
String basisStreamNumber = attributes.get("basisStreamNumber");
long basisStreamId = basisStreamNumber == null ? 0 : Long.parseLong(basisStreamNumber);
String depot = attributes.get("depotName");
Date startTime = new Date(Long.parseLong(attributes.get("startTime")) * 1000);
String streamType = attributes.get("type");
streams.add(new Stream(name, streamId, basis, basisStreamId, depot, startTime, streamType));
}
}
Aggregations