コード例 #1
0
ファイル: ViewsTest.java プロジェクト: ricesorry/sonar
 @Test
 public void getWidgets() {
   final Views views = new Views(VIEWS);
   List<ViewProxy<Widget>> widgets = views.getWidgets(null, null, null);
   assertThat(widgets.size(), is(1));
   assertThat(widgets.get(0).getTarget(), is(FakeWidget.class));
 }
コード例 #2
0
ファイル: ViewsTest.java プロジェクト: jorispz/sonar
 @Test
 public void should_get_widgets() {
   final Views views = new Views(VIEWS);
   List<ViewProxy<Widget>> widgets = views.getWidgets(null, null, null, null);
   assertThat(widgets.size()).isEqualTo(1);
   assertThat(widgets.get(0).getTarget().getClass()).isEqualTo(FakeWidget.class);
 }
コード例 #3
0
ファイル: ViewsTest.java プロジェクト: ricesorry/sonar
 @Test
 public void getResourceViewers() {
   final Views views = new Views(VIEWS);
   List resourceViewers = views.getPages(NavigationSection.RESOURCE_TAB);
   assertThat(resourceViewers.size(), is(1 + 4 /* default */));
   assertThat(resourceViewers.contains(new ViewProxy((View) FAKE_TAB)), is(true));
 }
コード例 #4
0
ファイル: ViewsTest.java プロジェクト: jorispz/sonar
 @Test
 public void should_get_resource_viewers() {
   final Views views = new Views(VIEWS);
   List resourceViewers = views.getPages(NavigationSection.RESOURCE_TAB);
   assertThat(resourceViewers.size()).isEqualTo(1 + 4 /* default */);
   assertThat(resourceViewers.contains(new ViewProxy<FakeResourceViewer>(FAKE_TAB)))
       .isEqualTo(true);
 }
コード例 #5
0
ファイル: ViewsTest.java プロジェクト: ricesorry/sonar
 @Test
 public void getPageById() {
   final Views views = new Views(VIEWS);
   assertThat(views.getPage("fake-page").getTarget(), is(FakePage.class));
   assertThat(views.getPage("fake-widget"), nullValue());
   assertThat(views.getPage("foo"), nullValue());
   assertThat(views.getPage("fake-resourceviewer").getTarget(), is(FakeResourceViewer.class));
 }
コード例 #6
0
ファイル: ViewsTest.java プロジェクト: jorispz/sonar
  @Test
  public void should_check_resource_scope() {
    ViewProxy proxy = mock(ViewProxy.class);
    assertThat(Views.acceptResourceScope(proxy, Scopes.FILE)).isEqualTo(true);

    when(proxy.getResourceScopes()).thenReturn(new String[] {Scopes.PROJECT, Scopes.FILE});
    assertThat(Views.acceptResourceScope(proxy, Scopes.FILE)).isEqualTo(true);
    assertThat(Views.acceptResourceScope(proxy, Scopes.DIRECTORY)).isEqualTo(false);
  }
コード例 #7
0
ファイル: ViewsTest.java プロジェクト: jorispz/sonar
 @Test
 public void should_get_page_by_id() {
   final Views views = new Views(VIEWS);
   assertThat(views.getPage("fake-page").getTarget().getClass()).isEqualTo(FakePage.class);
   assertThat(views.getPage("fake-widget")).isNull();
   assertThat(views.getPage("foo")).isNull();
   assertThat(views.getPage("fake-resourceviewer").getTarget().getClass())
       .isEqualTo(FakeResourceViewer.class);
 }
コード例 #8
0
ファイル: ViewsTest.java プロジェクト: ricesorry/sonar
  @Test
  public void checkResourceScope() {
    ViewProxy proxy = mock(ViewProxy.class);
    assertThat(Views.acceptResourceScope(proxy, Scopes.FILE), is(true));

    when(proxy.getResourceScopes()).thenReturn(new String[] {Scopes.PROJECT, Scopes.FILE});
    assertThat(Views.acceptResourceScope(proxy, Scopes.FILE), is(true));
    assertThat(Views.acceptResourceScope(proxy, Scopes.DIRECTORY), is(false));
  }
コード例 #9
0
ファイル: ViewsTest.java プロジェクト: ricesorry/sonar
  @Test
  public void checkResourceLanguage() {
    ViewProxy proxy = mock(ViewProxy.class);
    assertThat(Views.acceptResourceLanguage(proxy, Java.KEY), is(true));

    when(proxy.getResourceLanguages()).thenReturn(new String[] {"foo"});
    assertThat(Views.acceptResourceLanguage(proxy, Java.KEY), is(false));
    assertThat(Views.acceptResourceLanguage(proxy, "foo"), is(true));
  }
コード例 #10
0
ファイル: ViewsTest.java プロジェクト: jorispz/sonar
  @Test
  public void should_check_resource_language() {
    ViewProxy proxy = mock(ViewProxy.class);
    assertThat(Views.acceptResourceLanguage(proxy, Java.KEY)).isEqualTo(true);

    when(proxy.getResourceLanguages()).thenReturn(new String[] {"foo"});
    assertThat(Views.acceptResourceLanguage(proxy, Java.KEY)).isEqualTo(false);
    assertThat(Views.acceptResourceLanguage(proxy, "foo")).isEqualTo(true);
  }
コード例 #11
0
ファイル: ViewsTest.java プロジェクト: ricesorry/sonar
  @Test
  public void doNotCheckNavigationSectionOnWidgets() {
    ViewProxy proxy = mock(ViewProxy.class);
    when(proxy.isWidget()).thenReturn(true);

    assertThat(Views.acceptNavigationSection(proxy, NavigationSection.RESOURCE), is(true));
    assertThat(Views.acceptNavigationSection(proxy, NavigationSection.HOME), is(true));
    assertThat(Views.acceptNavigationSection(proxy, NavigationSection.CONFIGURATION), is(true));
    assertThat(Views.acceptNavigationSection(proxy, null), is(true));
  }
コード例 #12
0
ファイル: ViewsTest.java プロジェクト: jorispz/sonar
  @Test
  public void should_check_resource_qualifier() {
    ViewProxy proxy = mock(ViewProxy.class);
    assertThat(Views.acceptResourceQualifier(proxy, Scopes.FILE)).isEqualTo(true);

    when(proxy.getResourceQualifiers())
        .thenReturn(new String[] {Qualifiers.CLASS, Qualifiers.FILE});
    assertThat(Views.acceptResourceQualifier(proxy, Qualifiers.FILE)).isEqualTo(true);
    assertThat(Views.acceptResourceQualifier(proxy, Qualifiers.PACKAGE)).isEqualTo(false);
  }
コード例 #13
0
ファイル: ViewsTest.java プロジェクト: ricesorry/sonar
  @Test
  public void getPagesBySection() {
    final Views views = new Views(VIEWS);

    List<ViewProxy<Page>> pages = views.getPages(NavigationSection.RESOURCE);
    assertThat(pages.size(), is(1));
    assertThat(pages.get(0).getTarget(), is(FakePage.class));

    pages = views.getPages(NavigationSection.CONFIGURATION);
    assertThat(pages.size(), is(0));
  }
コード例 #14
0
ファイル: ViewsTest.java プロジェクト: ricesorry/sonar
  @Test
  public void acceptNavigationSection() {
    ViewProxy proxy = mock(ViewProxy.class);
    when(proxy.getSections()).thenReturn(new String[] {NavigationSection.RESOURCE});
    when(proxy.isWidget()).thenReturn(false);

    assertThat(Views.acceptNavigationSection(proxy, NavigationSection.RESOURCE), is(true));
    assertThat(Views.acceptNavigationSection(proxy, NavigationSection.HOME), is(false));
    assertThat(Views.acceptNavigationSection(proxy, NavigationSection.CONFIGURATION), is(false));
    assertThat(Views.acceptNavigationSection(proxy, null), is(true));
  }
コード例 #15
0
ファイル: ViewsTest.java プロジェクト: jorispz/sonar
  @Test
  public void should_get_pages_by_section() {
    final Views views = new Views(VIEWS);

    List<ViewProxy<Page>> pages = views.getPages(NavigationSection.RESOURCE);
    assertThat(pages.size()).isEqualTo(1);
    assertThat(pages.get(0).getTarget().getClass()).isEqualTo(FakePage.class);

    pages = views.getPages(NavigationSection.CONFIGURATION);
    assertThat(pages.size()).isEqualTo(0);
  }
コード例 #16
0
ファイル: ViewsTest.java プロジェクト: jorispz/sonar
  @Test
  public void should_not_check_navigation_section_on_widgets() {
    ViewProxy proxy = mock(ViewProxy.class);
    when(proxy.isWidget()).thenReturn(true);

    assertThat(Views.acceptNavigationSection(proxy, NavigationSection.RESOURCE)).isEqualTo(true);
    assertThat(Views.acceptNavigationSection(proxy, NavigationSection.HOME)).isEqualTo(true);
    assertThat(Views.acceptNavigationSection(proxy, NavigationSection.CONFIGURATION))
        .isEqualTo(true);
    assertThat(Views.acceptNavigationSection(proxy, NavigationSection.RESOURCE_CONFIGURATION))
        .isEqualTo(true);
    assertThat(Views.acceptNavigationSection(proxy, null)).isEqualTo(true);
  }
コード例 #17
0
ファイル: ViewsTest.java プロジェクト: jorispz/sonar
  @Test
  public void should_accept_navigation_section() {
    ViewProxy proxy = mock(ViewProxy.class);
    when(proxy.getSections()).thenReturn(new String[] {NavigationSection.RESOURCE});
    when(proxy.isWidget()).thenReturn(false);

    assertThat(Views.acceptNavigationSection(proxy, NavigationSection.RESOURCE)).isEqualTo(true);
    assertThat(Views.acceptNavigationSection(proxy, NavigationSection.HOME)).isEqualTo(false);
    assertThat(Views.acceptNavigationSection(proxy, NavigationSection.CONFIGURATION))
        .isEqualTo(false);
    assertThat(Views.acceptNavigationSection(proxy, NavigationSection.RESOURCE_CONFIGURATION))
        .isEqualTo(false);
    assertThat(Views.acceptNavigationSection(proxy, null)).isEqualTo(true);
  }
コード例 #18
0
ファイル: ViewsTest.java プロジェクト: ricesorry/sonar
 @Test
 public void sortViewsByTitle() {
   final Views views =
       new Views(
           new View[] {
             new FakeWidget("ccc", "ccc"),
             new FakeWidget("aaa", "aaa"),
             new FakeWidget("bbb", "bbb")
           });
   List<ViewProxy<Widget>> widgets = views.getWidgets(null, null, null);
   assertThat(widgets.size(), is(3));
   assertThat(widgets.get(0).getId(), is("aaa"));
   assertThat(widgets.get(1).getId(), is("bbb"));
   assertThat(widgets.get(2).getId(), is("ccc"));
 }
コード例 #19
0
ファイル: ViewsTest.java プロジェクト: ricesorry/sonar
 @Test
 public void prefixTitleByNumberToDisplayFirst() {
   final Views views =
       new Views(
           new View[] {
             new FakeWidget("other", "Other"),
             new FakeWidget("1id", "1widget"),
             new FakeWidget("2id", "2widget")
           });
   List<ViewProxy<Widget>> widgets = views.getWidgets(null, null, null);
   assertThat(widgets.size(), is(3));
   assertThat(widgets.get(0).getId(), is("1id"));
   assertThat(widgets.get(1).getId(), is("2id"));
   assertThat(widgets.get(2).getId(), is("other"));
 }
コード例 #20
0
ファイル: ViewsTest.java プロジェクト: jorispz/sonar
 @Test
 public void should_sort_views_by_title() {
   final Views views =
       new Views(
           new View[] {
             new FakeWidget("ccc", "ccc"),
             new FakeWidget("aaa", "aaa"),
             new FakeWidget("bbb", "bbb")
           });
   List<ViewProxy<Widget>> widgets = views.getWidgets(null, null, null, null);
   assertThat(widgets.size()).isEqualTo(3);
   assertThat(widgets.get(0).getId()).isEqualTo("aaa");
   assertThat(widgets.get(1).getId()).isEqualTo("bbb");
   assertThat(widgets.get(2).getId()).isEqualTo("ccc");
 }
コード例 #21
0
ファイル: ViewsTest.java プロジェクト: jorispz/sonar
 @Test
 public void should_prefix_title_by_number_to_display_first() {
   final Views views =
       new Views(
           new View[] {
             new FakeWidget("other", "Other"),
             new FakeWidget("1id", "1widget"),
             new FakeWidget("2id", "2widget")
           });
   List<ViewProxy<Widget>> widgets = views.getWidgets(null, null, null, null);
   assertThat(widgets.size()).isEqualTo(3);
   assertThat(widgets.get(0).getId()).isEqualTo("1id");
   assertThat(widgets.get(1).getId()).isEqualTo("2id");
   assertThat(widgets.get(2).getId()).isEqualTo("other");
 }
コード例 #22
0
ファイル: ViewsTest.java プロジェクト: jorispz/sonar
  @Test
  public void should_accept_available_measures() {
    ViewProxy proxy = mock(ViewProxy.class);
    when(proxy.acceptsAvailableMeasures(new String[] {"lines"})).thenReturn(true);
    when(proxy.acceptsAvailableMeasures(new String[] {"ncloc"})).thenReturn(false);

    assertThat(Views.acceptAvailableMeasures(proxy, null)).isEqualTo(true);
    assertThat(Views.acceptAvailableMeasures(proxy, new String[] {"lines"})).isEqualTo(true);
    assertThat(Views.acceptAvailableMeasures(proxy, new String[] {"ncloc"})).isEqualTo(false);

    assertThat(Views.accept(proxy, null, null, null, null, null)).isEqualTo(true);
    assertThat(Views.accept(proxy, null, null, null, null, new String[] {"lines"})).isEqualTo(true);
    assertThat(Views.accept(proxy, null, null, null, null, new String[] {"ncloc"}))
        .isEqualTo(false);
  }