IssueTrackerUrlUtil { public static String getUrl(Effort e){ IssueTracker tracker = e.getIssueTTask().getIsstProject().getIssueTracker(); String url = tracker.getUrl(); String projectname = e.getIssueTTask().getIsstProject().getProjectName(); Long taskno = e.getIssueTTask().getIsstTaskId(); if(tracker.getId().equals(C_MANTIS)){ return url + "/view.php?id="+taskno; } throw new RuntimeException("IssueTrackerId " + tracker.getId() + " not specified "+ "for URL-Generation."); }  static String getUrl(Effort e);  }
@Test public void testGetManitsUrl(){ IssueTracker issueTracker = mock(IssueTracker.class); when(issueTracker.getUrl()).thenReturn("www.mantis.com"); when(issueTracker.getId()).thenReturn(1L); IssueTrackerProject project = mock(IssueTrackerProject.class); when(project.getIssueTracker()).thenReturn(issueTracker); when(project.getProjectName()).thenReturn("unused"); IssueTrackerTask task = mock(IssueTrackerTask.class); when(task.getIsstProject()).thenReturn(project); when(task.getIsstTaskId()).thenReturn(2L); Effort e = mock(Effort.class); when(e.getIssueTTask()).thenReturn(task); assertEquals("www.mantis.com/view.php?id=2", IssueTrackerUrlUtil.getUrl(e)); }