use of org.junit.experimental.theories.Theory in project k-9 by k9mail.
the class TextBodyBuilderTest method testBuildTextPlain.
@Theory
public void testBuildTextPlain(boolean includeQuotedText, QuoteStyle quoteStyle, boolean isReplyAfterQuote, boolean isSignatureUse, boolean isSignatureBeforeQuotedText, boolean isDraft) {
String expectedText;
int expectedMessageLength;
int expectedMessagePosition;
// 3.signature
if (quoteStyle == QuoteStyle.PREFIX && isReplyAfterQuote) {
String expectedQuotedText = "";
if (isDraft || includeQuotedText) {
expectedQuotedText = "quoted text" + "\r\n";
}
expectedText = expectedQuotedText;
expectedText += "message content";
if (!isDraft && isSignatureUse) {
expectedText += "\r\n" + "signature";
}
expectedMessageLength = "message content".length();
expectedMessagePosition = expectedQuotedText.length();
} else // 3.quoted text
if (isSignatureBeforeQuotedText) {
expectedText = "message content";
if (!isDraft && isSignatureUse) {
expectedText += "\r\n" + "signature";
}
if (isDraft || includeQuotedText) {
expectedText += "\r\n\r\nquoted text";
}
expectedMessageLength = "message content".length();
expectedMessagePosition = 0;
} else // 1.message content
// 2.quoted text
// 3.signature
{
expectedText = "message content";
if (isDraft || includeQuotedText) {
expectedText += "\r\n\r\nquoted text";
}
if (!isDraft && isSignatureUse) {
expectedText += "\r\n" + "signature";
}
expectedMessageLength = "message content".length();
expectedMessagePosition = 0;
}
String quotedText = "quoted text";
String messageText = "message content";
String signatureText = "signature";
TestingTextBodyBuilder textBodyBuilder = new TestingTextBodyBuilder(includeQuotedText, isDraft, quoteStyle, isReplyAfterQuote, isSignatureBeforeQuotedText, isSignatureUse, messageText, signatureText);
textBodyBuilder.setQuotedText(quotedText);
TextBody textBody = textBodyBuilder.buildTextPlain();
assertThat(textBody, instanceOf(TextBody.class));
assertThat(textBody.getRawText(), is(expectedText));
assertThat(textBody.getComposedMessageLength(), is(expectedMessageLength));
assertThat(textBody.getComposedMessageOffset(), is(expectedMessagePosition));
assertThat(textBody.getRawText().substring(expectedMessagePosition, expectedMessagePosition + expectedMessageLength), is("message content"));
}
use of org.junit.experimental.theories.Theory in project k-9 by k9mail.
the class TextBodyBuilderTest method testBuildTextHtml.
@Theory
public void testBuildTextHtml(boolean includeQuotedText, QuoteStyle quoteStyle, boolean isReplyAfterQuote, boolean isSignatureUse, boolean isSignatureBeforeQuotedText, boolean isDraft) {
String expectedText;
int expectedMessageLength;
int expectedMessagePosition = 0;
String expectedHtmlContent;
String expectedPrefix = "";
if (includeQuotedText && quoteStyle == QuoteStyle.PREFIX && isReplyAfterQuote && !isDraft) {
expectedPrefix = "<br clear=\"all\">";
}
String expectedPostfix = "";
if (!isDraft && includeQuotedText) {
expectedPostfix = "<br><br>";
}
// 3.signature
if (quoteStyle == QuoteStyle.PREFIX && isReplyAfterQuote) {
expectedText = expectedPrefix + "<html>message content";
if (!isDraft && isSignatureUse) {
expectedText += "\r\n" + "signature";
}
expectedText += "</html>";
expectedMessageLength = expectedText.length();
String quotedContent = "quoted text";
if (isDraft || includeQuotedText) {
expectedHtmlContent = makeExpectedHtmlContent(expectedText, quotedContent, 0, false, expectedText, expectedText + quotedContent);
expectedText += quotedContent;
} else {
expectedHtmlContent = makeExpectedHtmlContent(expectedText, quotedContent, 0, true, "", quotedContent);
// expectedText += quotedContent;
}
} else // 3.quoted text
if (isSignatureBeforeQuotedText) {
expectedText = expectedPrefix + "<html>message content";
if (!isDraft && isSignatureUse) {
expectedText += "\r\n" + "signature";
}
expectedText += "</html>";
expectedText += expectedPostfix;
expectedMessageLength = expectedText.length();
String quotedContent = "quoted text";
if (isDraft || includeQuotedText) {
expectedHtmlContent = makeExpectedHtmlContent(expectedText, quotedContent, 0, true, expectedText, expectedText + quotedContent);
expectedText += quotedContent;
} else {
expectedHtmlContent = makeExpectedHtmlContent(expectedText, quotedContent, 0, true, "", quotedContent);
// expectedText += quotedContent;
}
} else // 1.message content
// 2.quoted text
// 3.signature
{
String expectedSignature = "";
expectedText = expectedPrefix + "<html>message content";
if (!isDraft && isSignatureUse) {
if (!includeQuotedText) {
expectedText += "\r\n" + "signature";
} else {
expectedSignature = "<html>\r\nsignature</html>";
}
}
expectedText += "</html>";
expectedText += expectedPostfix;
expectedMessageLength = expectedText.length();
String quotedContent = "quoted text";
if (isDraft || includeQuotedText) {
expectedHtmlContent = makeExpectedHtmlContent(expectedText, expectedSignature + quotedContent, expectedSignature.length(), true, expectedText, expectedText + expectedSignature + quotedContent);
expectedText += expectedSignature + quotedContent;
} else {
expectedHtmlContent = makeExpectedHtmlContent(expectedText, quotedContent, 0, true, "", quotedContent);
// expectedText += quotedContent;
}
}
InsertableHtmlContent insertableHtmlContent = new InsertableHtmlContent();
String quotedText = "quoted text";
insertableHtmlContent.setQuotedContent(new StringBuilder(quotedText));
String messageText = "message content";
String signatureText = "signature";
TestingTextBodyBuilder textBodyBuilder = new TestingTextBodyBuilder(includeQuotedText, isDraft, quoteStyle, isReplyAfterQuote, isSignatureBeforeQuotedText, isSignatureUse, messageText, signatureText);
textBodyBuilder.setQuotedTextHtml(insertableHtmlContent);
TextBody textBody = textBodyBuilder.buildTextHtml();
assertThat(textBody, instanceOf(TextBody.class));
assertThat(textBody.getRawText(), is(expectedText));
assertThat(textBody.getComposedMessageLength(), is(expectedMessageLength));
assertThat(textBody.getComposedMessageOffset(), is(expectedMessagePosition));
assertThat(insertableHtmlContent.toDebugString(), is(expectedHtmlContent));
}
use of org.junit.experimental.theories.Theory in project GCViewer by chewiebug.
the class ModelChartImplTest method shouldShowOrNotDateStampAccordingToModelAndSettings.
@Theory
public void shouldShowOrNotDateStampAccordingToModelAndSettings(TestCase testCase) throws Exception {
//given
ModelChartImpl modelChart = new ModelChartImpl();
GCPreferences preferences = new GCPreferences();
GCModel gcModel = Mockito.mock(GCModel.class);
Mockito.when(gcModel.hasDateStamp()).thenReturn(testCase.hasDateStamp());
Mockito.when(gcModel.getFirstDateStamp()).thenReturn(ZonedDateTime.now());
Mockito.when(gcModel.getPause()).thenReturn(new DoubleData());
preferences.setShowDateStamp(testCase.isShowDateStamp());
//when
modelChart.setModel(gcModel, preferences);
//then
assertThat(modelChart.isShowDateStamp(), equalTo(testCase.isExpectedShowDateStamp()));
}
use of org.junit.experimental.theories.Theory in project zeppelin by apache.
the class ElasticsearchInterpreterTest method testMisc.
@Theory
public void testMisc(ElasticsearchInterpreter interpreter) {
InterpreterResult res = interpreter.interpret(null, null);
assertEquals(Code.SUCCESS, res.code());
res = interpreter.interpret(" \n \n ", null);
assertEquals(Code.SUCCESS, res.code());
}
use of org.junit.experimental.theories.Theory in project zeppelin by apache.
the class ElasticsearchInterpreterTest method testCompletion.
@Theory
public void testCompletion(ElasticsearchInterpreter interpreter) {
final List<InterpreterCompletion> expectedResultOne = Arrays.asList(new InterpreterCompletion("count", "count"));
final List<InterpreterCompletion> expectedResultTwo = Arrays.asList(new InterpreterCompletion("help", "help"));
final List<InterpreterCompletion> resultOne = interpreter.completion("co", 0);
final List<InterpreterCompletion> resultTwo = interpreter.completion("he", 0);
final List<InterpreterCompletion> resultAll = interpreter.completion("", 0);
Assert.assertEquals(expectedResultOne, resultOne);
Assert.assertEquals(expectedResultTwo, resultTwo);
final List<String> allCompletionList = new ArrayList<>();
for (final InterpreterCompletion ic : resultAll) {
allCompletionList.add(ic.getName());
}
Assert.assertEquals(ElasticsearchInterpreter.COMMANDS, allCompletionList);
}
Aggregations