@Test public void shouldGetEmptyHolderWhenExceptionIsThrown() throws ScmException { DateRange dateRange = new DateRange(datefrom, dateTo); when(scmFacade.getChangeLog(projectBaseDir, datefrom.toDate(), dateTo.toDate())) .thenThrow(ScmException.class); GenericScmAdapter genericScmAdapter = new GenericScmAdapter(scmFacade, config, fileExclusions, moduleFileSystem); ChangeLogHandler changeLogHandler = genericScmAdapter.getChangeLog(dateRange); assertThat(changeLogHandler.getChangeLogs()).isEmpty(); }
@Test public void shouldGetEmptyHolderWhenIsNotSuccesful() { DateRange dateRange = new DateRange(datefrom, dateTo); when(changeLog.isSuccess()).thenReturn(Boolean.FALSE); GenericScmAdapter genericScmAdapter = new GenericScmAdapter(scmFacade, config, fileExclusions, moduleFileSystem); ChangeLogHandler changeLogHandler = genericScmAdapter.getChangeLog(dateRange); assertThat(changeLogHandler.getChangeLogs()).isEmpty(); }
@Test public void shouldGetChangeLog() { DateTime date1 = new DateTime(); DateTime date2 = new DateTime(); List<ChangeFile> files = createChangeFilesList(); changeSets.add(new ChangeSet(date2.toDate(), null, "user2", files)); changeSets.add(new ChangeSet(date1.toDate(), null, "user1", files)); when(changeLog.isSuccess()).thenReturn(Boolean.TRUE); DateRange dateRange = new DateRange(datefrom, dateTo); GenericScmAdapter genericScmAdapter = new GenericScmAdapter(scmFacade, config, fileExclusions, moduleFileSystem); Map<String, Integer> activity = createActivityMap(); ChangeLogInfo changeLogInfo1 = new ChangeLogInfo("user1", date1.toDate(), activity); ChangeLogInfo changeLogInfo2 = new ChangeLogInfo("user2", date2.toDate(), activity); ChangeLogHandler result = genericScmAdapter.getChangeLog(dateRange); assertThat(result.getChangeLogs().get(0).getAuthor()).isEqualTo(changeLogInfo2.getAuthor()); assertThat(result.getChangeLogs().get(0).getCommitDate()) .isEqualTo(changeLogInfo2.getCommitDate()); assertThat(result.getChangeLogs().get(0).getActivity()).hasSize(3); assertThat(result.getChangeLogs().get(0).getActivity().get(ScmStatsConstants.ACTIVITY_ADD)) .isEqualTo(1); assertThat(result.getChangeLogs().get(0).getActivity().get(ScmStatsConstants.ACTIVITY_MODIFY)) .isEqualTo(1); assertThat(result.getChangeLogs().get(0).getActivity().get(ScmStatsConstants.ACTIVITY_DELETE)) .isEqualTo(2); assertThat(result.getChangeLogs().get(1).getAuthor()).isEqualTo(changeLogInfo1.getAuthor()); assertThat(result.getChangeLogs().get(1).getCommitDate()) .isEqualTo(changeLogInfo1.getCommitDate()); assertThat(result.getChangeLogs().get(1).getActivity()).hasSize(3); assertThat(result.getChangeLogs().get(1).getActivity().get(ScmStatsConstants.ACTIVITY_ADD)) .isEqualTo(1); assertThat(result.getChangeLogs().get(1).getActivity().get(ScmStatsConstants.ACTIVITY_MODIFY)) .isEqualTo(1); assertThat(result.getChangeLogs().get(1).getActivity().get(ScmStatsConstants.ACTIVITY_DELETE)) .isEqualTo(2); }
@Test public void shouldNotBeResponsible() { GenericScmAdapter genericScmAdapter = new GenericScmAdapter(scmFacade, config, fileExclusions, moduleFileSystem); assertThat(genericScmAdapter.isResponsible("hg")).isFalse(); }