X-Git-Url: http://jaekl.net/gitweb/?p=cfb.git;a=blobdiff_plain;f=test%2Fnet%2Fjaekl%2Fcfb%2Fanalyze%2FNotifierTest.java;fp=test%2Fnet%2Fjaekl%2Fcfb%2Fanalyze%2FNotifierTest.java;h=e6cee95f30e23ecdf952be72b06941be2facfcc0;hp=0000000000000000000000000000000000000000;hb=7ef6c36cd147216c5354082b11aa33cf6b5c6f49;hpb=59715b74a1ef7cb3fcdb48544b6f4f2cf8208805 diff --git a/test/net/jaekl/cfb/analyze/NotifierTest.java b/test/net/jaekl/cfb/analyze/NotifierTest.java new file mode 100644 index 0000000..e6cee95 --- /dev/null +++ b/test/net/jaekl/cfb/analyze/NotifierTest.java @@ -0,0 +1,78 @@ +package net.jaekl.cfb.analyze; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; + +import net.jaekl.cfb.CfbBundleMock; +import net.jaekl.cfb.Config; + +import org.junit.Before; +import org.junit.Test; + +public class NotifierTest { + private CfbBundleMock m_bundle; + private Config m_config; + private MessageMapMock m_msgMap; + private NotifierMock m_notifier; + + @Before + public void setUp() { + m_bundle = new CfbBundleMock(); + m_config = new Config(); + m_msgMap = new MessageMapMock(); + m_notifier = new NotifierMock(m_bundle, m_config); + } + + @Test + public void testConstructSubject_noPrior() throws IOException { + String[][] data = { + { + "ProjectNameGoesHere", + "0.7.42-SNAPSHOT", + "[cfb.mail.subject][[no.earlier.run]][[version.num][", + "][0.7.42-SNAPSHOT]]" + }, + { + "ProjectNameGoesHere", + null, + "[cfb.mail.subject][[no.earlier.run]][[analyzed.at][", + "]]" + }, + { + null, + "0.7.42-SNAPSHOT", + "[cfb.mail.subject][[no.earlier.run]][[version.num][", + "][0.7.42-SNAPSHOT]]" + }, + { + null, + null, + "[cfb.mail.subject][[no.earlier.run]][[analyzed.at][", + "]]" + } + }; + + for (String[] datum : data) { + String projectName = datum[0]; + String buildNumber = datum[1]; + String expectedPart1 = datum[2]; + String expectedPart2 = datum[3]; + + Analysis first = null; + Analysis second = new Analysis(projectName, buildNumber); + + Delta delta = new Delta(first, second); + HtmlReport htmlReport = new HtmlReport(m_bundle, m_msgMap.getColl(), delta); + + String actual = m_notifier.constructSubject(htmlReport); + boolean pass = (actual.startsWith(expectedPart1)) && (actual.endsWith(expectedPart2)); + if (!pass) { + System.out.println("ProjectName:\n" + projectName + "\nVersion:\n" + buildNumber + + "\nExpected:\n" + expectedPart1 + "{date}" + expectedPart2 + "\nActual:\n" + actual); + } + assertTrue(pass); + } + } + +}