### Question:
SpacewalkChannelRepository extends RPMRepository<SpacewalkPackage> { public void setCredentials(final Credentials credentials, final boolean isPersistingCredentials) { if (null == credentials) { throw new NullPointerException("must provide credentials"); } if (StringUtils.isEmpty(credentials.getUserName())) { throw new IllegalArgumentException("must provide a user name"); } if (StringUtils.isEmpty(credentials.getPassword())) { throw new IllegalArgumentException("must provide a password"); } this.credentials = credentials; this.isPersistingCredentials = isPersistingCredentials; if (this.isPersistingCredentials) { userName = credentials.getUserName(); password = credentials.getPassword(); } else { userName = null; password = null; } } SpacewalkChannelRepository(final String name, final URL baseUrl,
            final String channelLabel);  SpacewalkChannelRepository(final String name); protected  SpacewalkChannelRepository(); boolean isPersistingCredentials(); Credentials getCredentials(); void setCredentials(final Credentials credentials,
            final boolean isPersistingCredentials); void setChannelLabel(final String channelLabel); String getChannelLabel();  }### Answer:
@Test(expectedExceptions = NullPointerException.class) public void exceptionWithNullAuthentication() { SpacewalkChannelRepository repo = new SpacewalkChannelRepository(NAME, baseUrl, CHANNEL_LABEL); repo.setCredentials(null, true); }
@Test(expectedExceptions = IllegalArgumentException.class) public void exceptionWithNullUserName() { SpacewalkChannelRepository repo = new SpacewalkChannelRepository(NAME, baseUrl, CHANNEL_LABEL); Credentials auth = new Credentials(null, TEST_PASSWORD); repo.setCredentials(auth, true); }
@Test(expectedExceptions = IllegalArgumentException.class) public void exceptionWithEmptyPassword() { SpacewalkChannelRepository repo = new SpacewalkChannelRepository(NAME, baseUrl, CHANNEL_LABEL); Credentials auth = new Credentials(TEST_USER_NAME, ""); repo.setCredentials(auth, true); }
@Test public void setCredentials() { SpacewalkChannelRepository repo = new SpacewalkChannelRepository(NAME, baseUrl, CHANNEL_LABEL); Credentials auth = new Credentials(TEST_USER_NAME, TEST_PASSWORD); repo.setCredentials(auth, true); Credentials retrievedAuth = repo.getCredentials(); Assert.assertEquals(retrievedAuth, auth); }