コード例 #1
0
  @Test
  public void faillIfNoFilterFound() throws Exception {
    JiraSoapService jiraSoapService = mock(JiraSoapService.class);

    JiraSoapSession soapSession = mock(JiraSoapSession.class);
    when(soapSession.getJiraSoapService()).thenReturn(jiraSoapService);

    JiraSoapServiceWrapper wrapper = new JiraSoapServiceWrapper(jiraSoapService, null, settings);
    when(soapSession.getJiraService(Matchers.<RuleFinder>any(), Matchers.<Settings>any()))
        .thenReturn(wrapper);

    when(jiraSoapService.getFavouriteFilters("token")).thenReturn(new RemoteFilter[0]);

    thrown.expect(IllegalStateException.class);
    thrown.expectMessage("Unable to find filter 'myFilter' in JIRA");

    sensor.findJiraFilter(wrapper, "token");
  }
コード例 #2
0
  @Test
  public void shouldFindFiltersWithPreviousJiraVersions() throws Exception {
    JiraSoapService jiraSoapService = mock(JiraSoapService.class);

    JiraSoapSession soapSession = mock(JiraSoapSession.class);
    when(soapSession.getJiraSoapService()).thenReturn(jiraSoapService);

    JiraSoapServiceWrapper wrapper = new JiraSoapServiceWrapper(jiraSoapService, null, settings);
    when(soapSession.getJiraService(Matchers.<RuleFinder>any(), Matchers.<Settings>any()))
        .thenReturn(wrapper);

    RemoteFilter myFilter = new RemoteFilter();
    myFilter.setName("myFilter");
    myFilter.setId("1");
    when(jiraSoapService.getSavedFilters("token")).thenReturn(new RemoteFilter[] {myFilter});
    when(jiraSoapService.getFavouriteFilters("token")).thenThrow(RemoteException.class);

    Filter foundFilter = sensor.findJiraFilter(wrapper, "token");
    assertThat(foundFilter.getName()).isEqualTo(myFilter.getName());
  }