* tests building a skip days object.
*/
@Test
public void testBuildSkipDays() {
try {
SkipDays skipDays = rssDoc.buildSkipDays(null);
assertNotNull(skipDays);
fail("we should have thrown an exception above.");
} catch (RSSpectException r) {
assertEquals(r.getMessage(),
"skipDays elements should contain at least one <day> sub element.");
}
try {
SkipDays skipDays = rssDoc.buildSkipDays(new LinkedList<Day>());
assertNotNull(skipDays);
fail("we should have thrown an exception above.");
} catch (RSSpectException r) {
assertEquals(r.getMessage(),
"skipDays elements should contain at least one <day> sub element.");
}
try {
List<Day> days = new LinkedList<Day>();
days.add(rssDoc.buildDay("yes"));
SkipDays skipDays = rssDoc.buildSkipDays(days);
assertNotNull(skipDays);
fail("we should have thrown an exception above.");
} catch (RSSpectException r) {
assertEquals(
r.getMessage(),
"day elements must have a value of Monday, Tuesday, Wednesday, Thursday, Friday, Saturday or Sunday.");
}
try {
List<Day> days = new LinkedList<Day>();
days.add(rssDoc.buildDay("Thursday"));
days.add(rssDoc.buildDay("Friday"));
days.add(rssDoc.buildDay("Saturday"));
days.add(rssDoc.buildDay("Sunday"));
SkipDays skipDays = rssDoc.buildSkipDays(days);
assertNotNull(skipDays);
assertNotNull(skipDays.getSkipDays());
} catch (Exception e) {
fail("should not fail here.");
}
try {
rss1 = rssDoc.readRSSToBean(expectedRSS1);
SkipDays sd = rss1.getChannel().getSkipDays();
assertNotNull(sd);
assertNotNull(sd.getSkipDay("Monday"));
assertEquals(sd.getSkipDay("Monday").getDay(), "Monday");
assertNull(sd.getSkipDay("Bunky"));
} catch (Exception e) {
fail("should not fail here.");
}
}