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

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

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

AbstractObjectArrayAssert.hasSize介绍

暂无

代码示例

代码示例来源:origin: springside/springside4

@Test
public void fromCsvString() {
  assertThat(CsvUtil.fromCsvString("1,2")).hasSize(2).contains("1").contains("2");
  assertThat(CsvUtil.fromCsvString("1,A BC")).hasSize(2).contains("1").contains("A BC");
  assertThat(CsvUtil.fromCsvString("1,\"A,BC\"")).hasSize(2).contains("1").contains("A,BC");
  assertThat(CsvUtil.fromCsvString("1,\"A,\"\"a\"\"BC\"")).hasSize(2).contains("1").contains("A,\"a\"BC");
  // wrong format still work
  assertThat(CsvUtil.fromCsvString("1,\"A,\"a\"\"BC\"")).hasSize(2).contains("1").contains("A,\"a\"BC");
  assertThat(CsvUtil.fromCsvString("1,ABC\"")).hasSize(2).contains("1").contains("ABC\"");
}

代码示例来源:origin: hidroh/materialistic

@Test
public void testGetStoriesSuccess() {
  AlgoliaClient.AlgoliaHits hits = new GsonBuilder().create().fromJson(
      "{\"hits\":[{\"objectID\":\"1\"}]}",
      AlgoliaClient.AlgoliaHits.class);
  when(TestRestServiceFactory.algoliaRestService.searchByDate(eq("filter")))
      .thenReturn(Observable.just(hits));
  client.getStories("filter", ItemManager.MODE_DEFAULT, storiesListener);
  verify(TestRestServiceFactory.algoliaRestService).searchByDate(eq("filter"));
  verify(storiesListener).onResponse(getStoriesResponse.capture());
  assertThat(getStoriesResponse.getValue()).hasSize(1);
}

代码示例来源:origin: Swagger2Markup/swagger2markup

@Test
public void testFromResourceURI() throws IOException, URISyntaxException {
  //Given
  Path outputDirectory = Paths.get("build/test/asciidoc/fileUri");
  FileUtils.deleteQuietly(outputDirectory.toFile());
  //When
  Swagger2MarkupConverter.from(GeneralConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI()).build()
      .toFolder(outputDirectory);
  //Then
  String[] files = outputDirectory.toFile().list();
  assertThat(files).hasSize(4).containsAll(expectedFiles);
}

代码示例来源:origin: Swagger2Markup/swagger2markup

@Test
public void testFromPathURI() throws IOException, URISyntaxException {
  //Given
  Path outputDirectory = Paths.get("build/test/asciidoc/pathUri");
  FileUtils.deleteQuietly(outputDirectory.toFile());
  //When
  Swagger2MarkupConverter.from(Paths.get("src/test/resources/yaml/swagger_petstore.yaml").toUri()).build()
      .toFolder(outputDirectory);
  //Then
  String[] files = outputDirectory.toFile().list();
  assertThat(files).hasSize(4).containsAll(expectedFiles);
}

代码示例来源:origin: Swagger2Markup/swagger2markup

@Test
public void testFromHttpURI() throws IOException, URISyntaxException {
  //Given
  Path outputDirectory = Paths.get("build/test/asciidoc/fromUri");
  FileUtils.deleteQuietly(outputDirectory.toFile());
  //When
  Swagger2MarkupConverter.from(URI.create("http://petstore.swagger.io/v2/swagger.json")).build()
      .toFolder(outputDirectory);
  //Then
  String[] files = outputDirectory.toFile().list();
  assertThat(files).hasSize(4).containsAll(expectedFiles);
}

代码示例来源:origin: Swagger2Markup/swagger2markup

@Test
public void testFromStringURIWithoutScheme() throws IOException, URISyntaxException {
  //Given
  Path outputDirectory = Paths.get("build/test/asciidoc/pathUri");
  FileUtils.deleteQuietly(outputDirectory.toFile());
  //When
  Swagger2MarkupConverter.from(URI.create("src/test/resources/yaml/swagger_petstore.yaml")).build()
      .toFolder(outputDirectory);
  //Then
  String[] files = outputDirectory.toFile().list();
  assertThat(files).hasSize(4).containsAll(expectedFiles);
}

代码示例来源:origin: Swagger2Markup/swagger2markup

@Test
public void testFromURL() throws IOException, URISyntaxException {
  //Given
  Path outputDirectory = Paths.get("build/test/asciidoc/fromUrl");
  FileUtils.deleteQuietly(outputDirectory.toFile());
  //When
  Swagger2MarkupConverter.from(new URL("http://petstore.swagger.io/v2/swagger.json")).build()
      .toFolder(outputDirectory);
  //Then
  String[] files = outputDirectory.toFile().list();
  assertThat(files).hasSize(4).containsAll(expectedFiles);
}

代码示例来源:origin: hidroh/materialistic

@Test
public void testGetTopStoriesSuccess() {
  when(TestRestServiceFactory.hnRestService.topStoriesRx())
      .thenReturn(Observable.just(new int[]{1, 2}));
  client.getStories(ItemManager.TOP_FETCH_MODE, ItemManager.MODE_DEFAULT, storiesListener);
  verify(TestRestServiceFactory.hnRestService).topStoriesRx();
  verify(storiesListener).onResponse(getStoriesResponse.capture());
  assertThat(getStoriesResponse.getValue()).hasSize(2);
}

代码示例来源:origin: Swagger2Markup/swagger2markup

@Test
public void testSwagger2AsciiDocConversionFromString() throws IOException, URISyntaxException {
  //Given
  String swaggerJsonString = IOUtils.toString(getClass().getResourceAsStream("/yaml/swagger_petstore.yaml"));
  Path outputDirectory = Paths.get("build/test/asciidoc/to_folder");
  FileUtils.deleteQuietly(outputDirectory.toFile());
  //When
  Swagger2MarkupConverter.from(swaggerJsonString).build()
      .toFolder(outputDirectory);
  //Then
  String[] files = outputDirectory.toFile().list();
  assertThat(files).hasSize(4).containsAll(expectedFiles);
  Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/to_folder").toURI());
  DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocConversion.html");
}

代码示例来源:origin: hidroh/materialistic

@Test
public void testParcelable() {
  assertThat(HackerNewsItem.CREATOR.newArray(1)).hasSize(1);
  assertEquals(0, item.describeContents());
}

代码示例来源:origin: Swagger2Markup/swagger2markup

@Test
public void testContainsUriScheme() throws IOException, URISyntaxException {
  //Given
  Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_should_contain_uri_scheme.yaml").toURI());
  Path outputDirectory = Paths.get("build/test/asciidoc/generated");
  FileUtils.deleteQuietly(outputDirectory.toFile());
  //When
  Swagger2MarkupConverter.from(file).build()
      .toFolder(outputDirectory);
  //Then
  String[] files = outputDirectory.toFile().list();
  assertThat(files).hasSize(4).containsAll(expectedFiles);
  assertThat(new String(Files.readAllBytes(outputDirectory.resolve("overview.adoc"))))
      .contains("=== URI scheme");
}

代码示例来源:origin: Swagger2Markup/swagger2markup

@Test
public void testToFolder() throws IOException, URISyntaxException {
  //Given
  Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
  Path outputDirectory = Paths.get("build/test/asciidoc/to_folder");
  FileUtils.deleteQuietly(outputDirectory.toFile());
  //When
  Swagger2MarkupConverter.from(file).build()
      .toFolder(outputDirectory);
  //Then
  String[] files = outputDirectory.toFile().list();
  assertThat(files).hasSize(4).containsAll(expectedFiles);
  Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/to_folder").toURI());
  DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testToFolder.html");
}

代码示例来源:origin: Swagger2Markup/swagger2markup

@Test
public void tesDoesNotContainUriScheme() throws IOException, URISyntaxException {
  //Given
  Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_should_not_contain_uri_scheme.yaml").toURI());
  Path outputDirectory = Paths.get("build/test/asciidoc/generated");
  FileUtils.deleteQuietly(outputDirectory.toFile());
  //When
  Swagger2MarkupConverter.from(file).build()
      .toFolder(outputDirectory);
  //Then
  String[] files = outputDirectory.toFile().list();
  assertThat(files).hasSize(4).containsAll(expectedFiles);
  assertThat(new String(Files.readAllBytes(outputDirectory.resolve("overview.adoc"))))
      .doesNotContain("=== URI scheme");
}

代码示例来源:origin: Swagger2Markup/swagger2markup

@Test
public void testWithGeneratedRecursiveExamples() throws IOException, URISyntaxException {
  // Given
  String swaggerJsonString = IOUtils.toString(getClass().getResourceAsStream("/json/swagger_recursion.json"));
  Path outputDirectory = Paths.get("build/test/asciidoc/generated_recursion_examples");
  FileUtils.deleteQuietly(outputDirectory.toFile());
  // When
  Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder().withoutInlineSchema().withGeneratedExamples().build();
  Swagger2MarkupConverter.from(swaggerJsonString).withConfig(config).build().toFolder(outputDirectory);
  // Then
  String[] files = outputDirectory.toFile().list();
  assertThat(files).hasSize(4).containsAll(expectedFiles);
  Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/generated_recursion_examples").toURI());
  DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testWithGeneratedRecursiveExamples.html");
}

代码示例来源:origin: Swagger2Markup/swagger2markup

@Test
public void testWithAsciidocContentInTables() throws URISyntaxException {
  //Given
  Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore_with_adoc_content.yaml").toURI());
  Path outputDirectory = Paths.get("build/test/asciidoc/generated");
  FileUtils.deleteQuietly(outputDirectory.toFile());
  //When
  Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
      .withSwaggerMarkupLanguage(MarkupLanguage.ASCIIDOC)
      .build();
  Swagger2MarkupConverter.from(file).withConfig(config).build()
      .toFolder(outputDirectory);
  //Then
  String[] files = outputDirectory.toFile().list();
  assertThat(files).hasSize(4).containsAll(expectedFiles);
}

代码示例来源:origin: springside/springside4

@Test
public void copyArrayObject() {
  Student student1 = new Student("zhang3", 20, new Teacher("li4"), ListUtil.newArrayList("chinese", "english"));
  Student student2 = new Student("zhang4", 30, new Teacher("li5"), ListUtil.newArrayList("chinese2", "english4"));
  Student student3 = new Student("zhang5", 40, new Teacher("li6"), ListUtil.newArrayList("chinese3", "english5"));
  Student[] studentList = new Student[] { student1, student2, student3 };
  StudentVO[] studentVoList = BeanMapper.mapArray(studentList, StudentVO.class);
  assertThat(studentVoList).hasSize(3);
  StudentVO studentVo = studentVoList[0];
  assertThat(studentVo.name).isEqualTo("zhang3");
  assertThat(studentVo.getAge()).isEqualTo(20);
  assertThat(studentVo.getTeacher().getName()).isEqualTo("li4");
  assertThat(studentVo.getCourse()).containsExactly("chinese", "english");
}

代码示例来源:origin: hidroh/materialistic

@Test
public void testGetKidItems() {
  assertThat(item.getKidItems()).isEmpty();
  item.populate(new TestItem() {
    @Override
    public long[] getKids() {
      return new long[]{1l, 2l};
    }
  });
  assertThat(item.getKidItems()).hasSize(2);
  assertEquals(1, item.getKidItems()[0].getRank());
  assertEquals(2, item.getKidItems()[1].getRank());
}

代码示例来源:origin: facebook/litho

@Test
public void testSpannableWithoutClickableSpans() {
 Spannable nonClickableText = Spannable.Factory.getInstance().newSpannable("Some text.");
 TextDrawable drawable = getMountedDrawableForText(nonClickableText);
 assertThat(drawable.getClickableSpans()).isNotNull().hasSize(0);
}

代码示例来源:origin: facebook/litho

@Test
public void testSpannableWithClickableSpans() {
 Spannable clickableText = Spannable.Factory.getInstance().newSpannable("Some text.");
 clickableText.setSpan(new ClickableSpan() {
  @Override
  public void onClick(View widget) {
  }
 }, 0, 1, 0);
 TextDrawable drawable = getMountedDrawableForText(clickableText);
 assertThat(drawable.getClickableSpans()).isNotNull().hasSize(1);
}

代码示例来源:origin: evernote/android-job

@Test
  public void testNullInStringArray() {
    PersistableBundleCompat bundle = new PersistableBundleCompat();

    String[] array = {"111", null, "333"};
    bundle.putStringArray("array", array);

    bundle = PersistableBundleCompat.fromXml(bundle.saveToXml());

    String[] inflated = bundle.getStringArray("array");
    assertThat(inflated).isNotNull().hasSize(3).containsExactly("111", null, "333");
  }
}

相关文章