org.assertj.core.api.AbstractCharSequenceAssert.containsSequence()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中org.assertj.core.api.AbstractCharSequenceAssert.containsSequence()方法的一些代码示例,展示了AbstractCharSequenceAssert.containsSequence()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractCharSequenceAssert.containsSequence()方法的具体详情如下:
包路径:org.assertj.core.api.AbstractCharSequenceAssert
类名称:AbstractCharSequenceAssert
方法名:containsSequence

AbstractCharSequenceAssert.containsSequence介绍

[英]Verifies that the actual CharSequence contains all the values of the given Iterable in the Iterable iteration order without any other values between them.

Breaking change since 2.9.0: in previous versions this assertion behaved like #containsSubsequence(Iterable)and allowed other values between the sequence values.

Example:

String book = "{ 'title':'A Game of Thrones', 'author':'George Martin'}"; 
// this assertion succeeds 
assertThat(book).containsSequence(asList("'title'", ":", "'A Game of Thrones'")); 
// this assertion will fail because there are values between the expected sequence (e.g "'title':'") 
assertThat(book).containsSequence(asList("{", "A Game of Thrones", "George Martin", "}")); 
// this one fails as "author" must come after "A Game of Thrones" 
assertThat(book).containsSequence(asList("author", "A Game of Thrones"));

[中]验证实际CharSequence是否包含Iterable迭代顺序中给定Iterable的所有值,且它们之间没有任何其他值。
打破2.9.0以来的变化:在以前的版本中,此断言的行为类似于#containsSubsequence(Iterable),并允许序列值之间存在其他值。
例子:

String book = "{ 'title':'A Game of Thrones', 'author':'George Martin'}"; 
// this assertion succeeds 
assertThat(book).containsSequence(asList("'title'", ":", "'A Game of Thrones'")); 
// this assertion will fail because there are values between the expected sequence (e.g "'title':'") 
assertThat(book).containsSequence(asList("{", "A Game of Thrones", "George Martin", "}")); 
// this one fails as "author" must come after "A Game of Thrones" 
assertThat(book).containsSequence(asList("author", "A Game of Thrones"));

代码示例

代码示例来源:origin: HubSpot/jinjava

@Test
public void itAvoidsNestedIncludeCycles() throws IOException {
 String result = jinjava.render(Resources.toString(Resources.getResource("tags/includetag/a-includes-b.jinja"), StandardCharsets.UTF_8),
   new HashMap<String, Object>());
 assertThat(result).containsSequence("A", "B");
}

代码示例来源:origin: HubSpot/jinjava

@Test
public void itAvoidsSimpleIncludeCycles() throws IOException {
 String result = jinjava.render(Resources.toString(Resources.getResource("tags/includetag/includes-self.jinja"), StandardCharsets.UTF_8),
   new HashMap<String, Object>());
 assertThat(result).containsSequence("hello world", "hello world");
}

代码示例来源:origin: com.hubspot.jinjava/jinjava

@Test
public void itAvoidsSimpleIncludeCycles() throws IOException {
 String result = jinjava.render(Resources.toString(Resources.getResource("tags/includetag/includes-self.jinja"), StandardCharsets.UTF_8),
   new HashMap<String, Object>());
 assertThat(result).containsSequence("hello world", "hello world");
}

代码示例来源:origin: neueda/jetbrains-plugin-graph-database-support

@Test
public void tooltipNoMoreThanThreeProperties() {
  properties.put(FIRST_KEY, FIRST_VALUE);
  properties.put(SECOND_KEY, SECOND_VALUE);
  properties.put(THIRD_KEY, THIRD_VALUE);
  properties.put(FOURTH_KEY, FOURTH_VALUE);
  assertThat(DisplayUtil.getTooltipText(node))
      .containsSequence(FIRST_KEY, FIRST_VALUE,
          SECOND_KEY, SECOND_VALUE,
          THIRD_KEY, THIRD_VALUE);
}

代码示例来源:origin: org.apache.james/james-server-jmap

@Test
public void fromShouldCombinePlainTextAndHtml() throws Exception {
  String htmlText = "<p>HTML text</p>";
  String plainText = "Plain text";
  String rowContent = IOUtils.toString(
    mimeMessageBodyGenerator.from(original,
      Optional.of(plainText),
      Optional.of(htmlText))
      .getInputStream(), StandardCharsets.UTF_8);
  assertThat(rowContent).containsSequence(htmlText);
  assertThat(rowContent).containsSequence(plainText);
  verifyZeroInteractions(htmlTextExtractor);
}

代码示例来源:origin: neueda/jetbrains-plugin-graph-database-support

@Test
public void tooltipPrioritizeStrings() {
  properties.put(FIRST_KEY, FIRST_VALUE);
  properties.put(SECOND_KEY, SECOND_VALUE);
  properties.put(THIRD_KEY, THIRD_VALUE_INT);
  properties.put(FOURTH_KEY, FOURTH_VALUE);
  assertThat(DisplayUtil.getTooltipText(node))
      .containsSequence(FIRST_KEY, FIRST_VALUE,
          SECOND_KEY, SECOND_VALUE,
          FOURTH_KEY, FOURTH_VALUE);
}

代码示例来源:origin: com.hubspot.jinjava/jinjava

@Test
public void itAvoidsNestedIncludeCycles() throws IOException {
 String result = jinjava.render(Resources.toString(Resources.getResource("tags/includetag/a-includes-b.jinja"), StandardCharsets.UTF_8),
   new HashMap<String, Object>());
 assertThat(result).containsSequence("A", "B");
}

代码示例来源:origin: org.apache.james/james-server-jmap

@Test
public void fromShouldProvideAPlainTextVersionWhenOnlyHtml() throws Exception {
  String htmlText = "<p>HTML text</p>";
  String plainText = "Plain text";
  when(htmlTextExtractor.toPlainText(htmlText)).thenReturn(plainText);
  String rowContent = IOUtils.toString(
    mimeMessageBodyGenerator.from(original,
      Optional.empty(),
      Optional.of(htmlText))
      .getInputStream(), StandardCharsets.UTF_8);
  assertThat(rowContent).containsSequence(htmlText);
  assertThat(rowContent).containsSequence(plainText);
}

代码示例来源:origin: neueda/jetbrains-plugin-graph-database-support

@Test
public void tooltip() {
  properties.put(FIRST_KEY, FIRST_VALUE);
  assertThat(DisplayUtil.getTooltipText(node))
      .containsSequence(FIRST_KEY, FIRST_VALUE);
}

代码示例来源:origin: neueda/jetbrains-plugin-graph-database-support

@Test
  public void tooltipTypesAndProperties() {
    types.add(FIRST_TYPE);
    types.add(SECOND_TYPE);
    properties.put(FIRST_KEY, FIRST_VALUE);
    properties.put(SECOND_KEY, SECOND_VALUE);
    properties.put(THIRD_KEY, THIRD_VALUE);
    properties.put(FOURTH_KEY, FOURTH_VALUE);

    assertThat(DisplayUtil.getTooltipText(node))
        .containsSequence(types.toString(),
            FIRST_KEY, FIRST_VALUE,
            SECOND_KEY, SECOND_VALUE,
            THIRD_KEY, THIRD_VALUE);
  }
}

代码示例来源:origin: org.drools/drools-decisiontables

@Test
public void testMultilineCommentsInDescription() {
  final SpreadsheetCompiler converter = new SpreadsheetCompiler();
  final InputStream stream = this.getClass().getResourceAsStream("/data/Multiline comment example.xls");
  final String drl = converter.compile(stream,
                     InputType.XLS);
  Assertions.assertThat(drl).containsSequence("/* Say", "Hello */", "/* Say", "Goobye */");
  Assertions.assertThat(drl).doesNotContain("// Say");
}

代码示例来源:origin: org.drools/drools-decisiontables

@Test
public void testMultilineComplexCommentsInDescription() {
  final SpreadsheetCompiler converter = new SpreadsheetCompiler();
  final InputStream stream = this.getClass().getResourceAsStream("/data/Multiline comment example complex.xls");
  final String drl = converter.compile(stream,
                     InputType.XLS);
  Assertions.assertThat(drl).containsSequence("/* Do these actions:",
                        "- Print Greeting",
                        "- Set params: {message:'bye cruel world', status:'bye'} */",
                        "/* Print message: \"Bye!\"",
                        "Author: james@company.org */");
  Assertions.assertThat(drl).doesNotContain("* - Print Greeting");
  Assertions.assertThat(drl).doesNotContain("* - Set params: {message:'bye cruel world', status:'bye'}");
  Assertions.assertThat(drl).doesNotContain("* Author: james@company.org");
}

代码示例来源:origin: arquillian/arquillian-cube

@Test
public void should_return_ok_as_pong() throws IOException {
  String response = ping(pingpong.getIpAddress(), pingpong.getBindPort(8080));
  assertThat(response).containsSequence("OK");
}

代码示例来源:origin: net.rakugakibox.spring.boot/logback-access-spring-boot-starter

/**
 * Tests a Logback-access event.
 */
@Test
public void logbackAccessEvent() {
  ResponseEntity<String> response = rest.getForEntity("/test/text", String.class);
  LogbackAccessEventQueuingListener.appendedEventQueue.pop();
  assertThat(response).hasStatusCode(HttpStatus.OK);
  assertThat(outputCapture.toString()).containsSequence("127.0.0.1", "GET", "/test/text", "HTTP/1.1", "200");
}

代码示例来源:origin: net.rakugakibox.spring.boot/logback-access-spring-boot-starter

/**
 * Tests a Logback-access event.
 */
@Test
public void logbackAccessEvent() {
  ResponseEntity<String> response = rest.getForEntity("/test/text", String.class);
  LogbackAccessEventQueuingListener.appendedEventQueue.pop();
  assertThat(response).hasStatusCode(HttpStatus.OK);
  assertThat(outputCapture.toString())
      .containsSequence(">>>", "127.0.0.1", "GET", "/test/text", "HTTP/1.1", "200", "<<<");
}

代码示例来源:origin: net.rakugakibox.spring.boot/logback-access-spring-boot-starter

/**
 * Tests a Logback-access event.
 */
@Test
public void logbackAccessEvent() {
  ResponseEntity<String> response = rest.getForEntity("/test/text", String.class);
  LogbackAccessEventQueuingListener.appendedEventQueue.pop();
  assertThat(response).hasStatusCode(HttpStatus.OK);
  assertThat(outputCapture.toString())
      .doesNotContain("UNUSED_CONSOLE")
      .doesNotContain("DEFAULT_CONSOLE")
      .doesNotContain("DEFAULT_NESTED_CONSOLE")
      .containsSequence(
          "ADDITIONAL_CONSOLE", "127.0.0.1", "GET", "/test/text", "HTTP/1.1", "200",
          "ADDITIONAL_NESTED_CONSOLE", "127.0.0.1", "GET", "/test/text", "HTTP/1.1", "200"
      );
}

相关文章

微信公众号

最新文章

更多