ConflictingRepositoriesPopup implements ConflictingRepositoriesPopupView.Presenter { public void setContent(final GAV gav, final Set<MavenRepositoryMetadata> repositories, final Command overrideCommand) { setContent(gav, repositories, null, overrideCommand); } ConflictingRepositoriesPopup(); @Inject  ConflictingRepositoriesPopup(final User identity,
                                        final ConflictingRepositoriesPopupView view); void setContent(final GAV gav,
                           final Set<MavenRepositoryMetadata> repositories,
                           final Command overrideCommand); void setContent(final GAV gav,
                           final Set<MavenRepositoryMetadata> metadata,
                           final Command okCommand,
                           final Command overrideCommand); @Override void show(); @Override void override(); @Override void hide();  }
@Test public void testSetContent_Administrator() { final GAV gav = mock(GAV.class); final Command command = mock(Command.class); final Set<MavenRepositoryMetadata> metadata = new HashSet<MavenRepositoryMetadata>(); final Set<Role> roles = new HashSet<Role>() {{ add(new RoleImpl(AppRoles.ADMIN.getName())); }}; when(user.getRoles()).thenReturn(roles); presenter.setContent(gav, metadata, command); verify(view).clear(); verify(view).setContent(eq(gav), eq(metadata)); verify(view).addOKButton(); verify(view).addOverrideButton(); }
@Test public void testSetContent_NotAdministrator() { final GAV gav = mock(GAV.class); final Command command = mock(Command.class); final Set<MavenRepositoryMetadata> metadata = new HashSet<MavenRepositoryMetadata>(); final Set<Role> roles = new HashSet<Role>(); when(user.getRoles()).thenReturn(roles); presenter.setContent(gav, metadata, command); verify(view).clear(); verify(view).setContent(eq(gav), eq(metadata)); verify(view).addOKButton(); verify(view, never()).addOverrideButton(); }
@Test public void testSetContent_Reuse() { final GAV gav = mock(GAV.class); final Command command = mock(Command.class); final Set<MavenRepositoryMetadata> metadata = new HashSet<MavenRepositoryMetadata>(); final Set<Role> roles = new HashSet<Role>() {{ add(new RoleImpl(AppRoles.ADMIN.getName())); }}; when(user.getRoles()).thenReturn(roles); presenter.setContent(gav, metadata, command); verify(view).clear(); verify(view).setContent(eq(gav), eq(metadata)); verify(view).addOKButton(); verify(view).addOverrideButton(); presenter.setContent(gav, metadata, command); verify(view, times(2)).clear(); verify(view, times(2)).setContent(eq(gav), eq(metadata)); verify(view, times(2)).addOKButton(); verify(view, times(2)).addOverrideButton(); }