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

x33g5p2x  于2022-01-25 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(165)

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

ObjectArrayAssert.hasSize介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

private File getCreatedTempDir(File workingDir) {
 assertThat(workingDir).isDirectory();
 assertThat(workingDir.listFiles()).hasSize(1);
 return workingDir.listFiles()[0];
}

代码示例来源:origin: SonarSource/sonarqube

@Test
 public void create_array_of_patterns() {
  PathPattern[] patterns = PathPattern.create(new String[] {
   "**/src/main/**Foo.java",
   "file:**/src/main/**Bar.java"
  });
  assertThat(patterns).hasSize(2);
  assertThat(patterns[0].toString()).isEqualTo("**/src/main/**Foo.java");
  assertThat(patterns[1].toString()).isEqualTo("file:**/src/main/**Bar.java");
 }
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void clean_temporary_files_at_startup() throws Exception {
 touch(new File(downloadDir, "sonar-php.jar"));
 touch(new File(downloadDir, "sonar-js.jar.tmp"));
 assertThat(downloadDir.listFiles()).hasSize(2);
 pluginDownloader.start();
 File[] files = downloadDir.listFiles();
 assertThat(files).hasSize(1);
 assertThat(files[0].getName()).isEqualTo("sonar-php.jar");
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void methodWithRolesAllowedHasCorrectAttribute() throws Exception {
  ConfigAttribute[] accessAttributes = findAttributes("adminMethod");
  assertThat(accessAttributes).hasSize(1);
  assertThat(accessAttributes[0].toString()).isEqualTo("ROLE_ADMIN");
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void permitAllMethodHasPermitAllAttribute() throws Exception {
  ConfigAttribute[] accessAttributes = findAttributes("permitAllMethod");
  assertThat(accessAttributes).hasSize(1);
  assertThat(accessAttributes[0].toString())
      .isEqualTo("javax.annotation.security.PermitAll");
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void alreadyHasDefaultPrefix() throws Exception {
  ConfigAttribute[] accessAttributes = findAttributes("roleAdminMethod");
  assertThat(accessAttributes).hasSize(1);
  assertThat(accessAttributes[0].toString()).isEqualTo("ROLE_ADMIN");
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void customAnnotationAtClassLevelIsDetected() throws Exception {
  ConfigAttribute[] attrs = mds.getAttributes(annotatedAtClassLevel).toArray(
      new ConfigAttribute[0]);
  assertThat(attrs).hasSize(1);
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void customAnnotationAtInterfaceLevelIsDetected() throws Exception {
  ConfigAttribute[] attrs = mds.getAttributes(annotatedAtInterfaceLevel).toArray(
      new ConfigAttribute[0]);
  assertThat(attrs).hasSize(1);
}

代码示例来源:origin: gocd/gocd

@Test
public void shouldGenerateEncryptedText() throws CryptoException {
  String encrypt = aesEncrypter.encrypt("p@ssw0rd");
  assertThat(encrypt).startsWith("AES");
  assertThat(encrypt.split(":")).hasSize(3);
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void nullDefaultRolePrefix() throws Exception {
  this.mds.setDefaultRolePrefix(null);
  ConfigAttribute[] accessAttributes = findAttributes("adminMethod");
  assertThat(accessAttributes).hasSize(1);
  assertThat(accessAttributes[0].toString()).isEqualTo("ADMIN");
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void mixedClassAndMethodPreAnnotationsAreBothIncluded() {
  ConfigAttribute[] attrs = mds.getAttributes(voidImpl2).toArray(
      new ConfigAttribute[0]);
  assertThat(attrs).hasSize(1);
  assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
  PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
  assertThat(pre.getAuthorizeExpression().getExpressionString()).isEqualTo("someExpression");
  assertThat(pre.getFilterExpression()).isNotNull();
  assertThat(pre.getFilterExpression().getExpressionString()).isEqualTo("somePreFilterExpression");
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void classLevelPreAnnotationIsPickedUpWhenNoMethodLevelExists()
    throws Exception {
  ConfigAttribute[] attrs = mds.getAttributes(voidImpl1).toArray(
      new ConfigAttribute[0]);
  assertThat(attrs).hasSize(1);
  assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
  PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
  assertThat(pre.getAuthorizeExpression()).isNotNull();
  assertThat(pre.getAuthorizeExpression().getExpressionString()).isEqualTo("someExpression");
  assertThat(pre.getFilterExpression()).isNull();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void unzip_stream() throws Exception {
 InputStream zip = urlToZip().openStream();
 File toDir = temp.newFolder();
 ZipUtils.unzip(zip, toDir);
 assertThat(toDir.list()).hasSize(3);
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void targetDoesntLoseApplicationListenerInterface() {
  assertThat(appContext.getBeansOfType(ApplicationListener.class)).hasSize(1);
  assertThat(appContext.getBeanNamesForType(ApplicationListener.class)).hasSize(1);
  appContext.publishEvent(new AuthenticationSuccessEvent(
      new TestingAuthenticationToken("user", "")));
  assertThat(target).isInstanceOf(ApplicationListener.class);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void translate_offset_for_each_line() {
 Component component = createComponent(1);
 List<ScannerReport.LineSgnificantCode> significantCode = new ArrayList<>();
 significantCode.add(createLineSignificantCode(1, 1, 2));
 reportReader.putSignificantCode(component.getReportAttributes().getRef(), significantCode);
 assertThat(underTest.getRangesPerLine(component)).isNotEmpty();
 LineRange[] lines = underTest.getRangesPerLine(component).get();
 assertThat(lines).hasSize(1);
 assertThat(lines[0].startOffset()).isEqualTo(1);
 assertThat(lines[0].endOffset()).isEqualTo(2);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void createTempFolderProps() throws Exception {
 File workingDir = temp.newFolder();
 workingDir.delete();
 TempFolder tempFolder = tempFolderProvider.provide(new ScannerProperties(ImmutableMap.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, workingDir.getAbsolutePath())));
 tempFolder.newDir();
 tempFolder.newFile();
 assertThat(getCreatedTempDir(workingDir)).exists();
 assertThat(getCreatedTempDir(workingDir).list()).hasSize(2);
 FileUtils.deleteQuietly(workingDir);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void unzipping_creates_target_directory_if_it_does_not_exist() throws IOException {
 File zip = FileUtils.toFile(urlToZip());
 File tempDir = temp.newFolder();
 Files.delete(tempDir);
 File subDir = new File(tempDir, "subDir");
 ZipUtils.unzip(zip, subDir);
 assertThat(subDir.list()).hasSize(3);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void unzip_file() throws IOException {
 File zip = FileUtils.toFile(urlToZip());
 File toDir = temp.newFolder();
 ZipUtils.unzip(zip, toDir);
 assertThat(toDir.list()).hasSize(3);
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void annotatedAnnotationAtInterfaceLevelIsDetected() throws Exception {
  MockMethodInvocation annotatedAtInterfaceLevel = new MockMethodInvocation(
      new AnnotatedAnnotationAtInterfaceLevel(), ReturnVoid2.class,
      "doSomething", List.class);
  ConfigAttribute[] attrs = mds.getAttributes(annotatedAtInterfaceLevel).toArray(
      new ConfigAttribute[0]);
  assertThat(attrs).hasSize(1);
  assertThat(attrs).extracting("attribute").containsOnly("CUSTOM");
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void annotatedAnnotationAtMethodLevelIsDetected() throws Exception {
  MockMethodInvocation annotatedAtMethodLevel = new MockMethodInvocation(
      new AnnotatedAnnotationAtMethodLevel(), ReturnVoid.class, "doSomething",
      List.class);
  ConfigAttribute[] attrs = mds.getAttributes(annotatedAtMethodLevel).toArray(
      new ConfigAttribute[0]);
  assertThat(attrs).hasSize(1);
  assertThat(attrs).extracting("attribute").containsOnly("CUSTOM");
}

相关文章