### Question:
SpacewalkService { @SuppressWarnings("unchecked") public static List<SpacewalkPackage> getPackages(final Credentials credentials, final URL spacewalkBaseUrl, final String channelLabel, final Repository sourceRepository) throws SpacewalkException { if (null == sourceRepository) { throw new SpacewalkException("must provide sourceRepository"); } if (StringUtils.isEmpty(channelLabel)) { throw new SpacewalkException("must provide channelLabel"); } validateParameters(credentials, spacewalkBaseUrl); URL queryUrl = getQueryUrl(spacewalkBaseUrl); Object sessionKey = getSessionKey(credentials, queryUrl); XmlRpcClient client = createXmlRpcClient(queryUrl); List<SpacewalkPackage> packageList = new ArrayList<>(); Object[] rawPackages; try { rawPackages = (Object[]) client.execute("channel.software.listAllPackages", new Object[] { sessionKey, channelLabel}); for (Object packagObj : rawPackages) { Map<String, Object> packageMap = (Map<String, Object>) packagObj; packageList.add(SpacewalkPackage .buildSpacewalkPackage(packageMap, sourceRepository)); } } catch (XmlRpcException e) { String message = "Error getting list of spacewalk packages for channel : " + channelLabel + " - " + e.getMessage(); LOGGER.error(message, e); throw new SpacewalkException(message, e); } catch (IllegalArgumentException iae) { String message = "Error processing channel map returned from Spacewalk for channel: " + channelLabel; LOGGER.error(message, iae); throw new SpacewalkException(message, iae); } finally { closeSession(sessionKey, queryUrl); } return packageList; } private  SpacewalkService(); @SuppressWarnings("unchecked") static List<SpacewalkChannel> getChannels(final Credentials credentials,
            final URL spacewalkBaseUrl); @SuppressWarnings("unchecked") static List<SpacewalkPackage> getPackages(final Credentials credentials,
            final URL spacewalkBaseUrl, final String channelLabel,
            final Repository sourceRepository); static URL getPackageDownloadUrl(final Credentials credentials,
            final URL spacewalkBaseUrl, final SpacewalkPackage spacewalkPackage); static void testConnection(final Credentials credentials,
            final URL spacewalkBaseUrl);  }### Answer:
@Test( expectedExceptions = SpacewalkException.class, expectedExceptionsMessageRegExp = ".*credentials.*") public void exceptionWithNullAuthenticationPackages() throws SpacewalkException { SpacewalkService.getPackages(null, spacewalkBaseUrl, CHANNEL_LABEL, REPOSITORY); }
@Test( expectedExceptions = SpacewalkException.class, expectedExceptionsMessageRegExp = ".*Spacewalk URL.*") public void exceptionWithNullUrlPackages() throws SpacewalkException { SpacewalkService.getPackages(authentication, null, CHANNEL_LABEL, REPOSITORY); }
@Test( expectedExceptions = SpacewalkException.class, expectedExceptionsMessageRegExp = ".*channelLabel.*") public void exceptionWithNullChannelLabelPackages() throws SpacewalkException { SpacewalkService.getPackages(authentication, spacewalkBaseUrl, null, REPOSITORY); }
@Test( expectedExceptions = SpacewalkException.class, expectedExceptionsMessageRegExp = ".*sourceRepository.*") public void exceptionWithNullRepositoryPackages() throws SpacewalkException { SpacewalkService.getPackages(authentication, spacewalkBaseUrl, CHANNEL_LABEL, null); }
@Test( expectedExceptions = SpacewalkException.class, expectedExceptionsMessageRegExp = ".*Spacewalk session for " + SPACEWALK_BASE_URL_STRING + "/rpc/api.*") public void exceptionWithUnreachableSpacewalkPackages() throws SpacewalkException { SpacewalkService.getPackages(authentication, spacewalkBaseUrl, CHANNEL_LABEL, REPOSITORY); }