コード例 #1
0
 @Test
 public void forHTMLBodyShouldReturnStringContainingEmptyWhenEmptyString() {
   // Given
   String body = "";
   String expected = "(Empty)";
   // When
   when(htmlTextExtractor.toPlainText(body)).thenReturn(expected);
   String actual = testee.forHTMLBody(Optional.of(body));
   // Then
   assertThat(actual).isEqualTo(expected);
 }
コード例 #2
0
 @Test
 public void asTextShouldReturnEmptyStringWhenEmptyString() {
   // Given
   String body = "";
   String expected = "";
   // When
   when(htmlTextExtractor.toPlainText(body)).thenReturn(expected);
   String actual = testee.asText(body);
   // Then
   assertThat(actual).isEqualTo(expected);
 }
コード例 #3
0
 @Test
 public void asTextShouldReturnStringWithoutHtmlTag() {
   // Given
   String body = "This is a <b>HTML</b> mail";
   String expected = "This is a HTML mail";
   // When
   when(htmlTextExtractor.toPlainText(body)).thenReturn(expected);
   String actual = testee.asText(body);
   // Then
   assertThat(actual).isEqualTo(expected);
 }
コード例 #4
0
 @Test
 public void
     forHTMLBodyShouldReturnTruncatedStringWithoutHtmlTagWhenStringContainTagsAndIsLongerThan256Characters() {
   // Given
   String body =
       "This is a <b>HTML</b> mail containing <u>underlined part</u>, <i>italic part</i> and <u><i>underlined AND italic part</i></u>9999999999"
           + "0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"
           + "0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"
           + "000000000011111111112222222222333333333344444444445555555";
   String bodyWithoutTags =
       "This is a HTML mail containing underlined part, italic part and underlined AND italic part9999999999"
           + "0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"
           + "0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"
           + "000000000011111111112222222222333333333344444444445555555";
   String expected =
       "This is a HTML mail containing underlined part, italic part and underlined AND italic part9999999999"
           + "0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"
           + "00000000001111111111222222222233333333334444444444555...";
   // When
   when(htmlTextExtractor.toPlainText(body)).thenReturn(bodyWithoutTags);
   String actual = testee.forHTMLBody(Optional.of(body));
   // Then
   assertThat(actual).isEqualTo(expected);
 }