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

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

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

AbstractBooleanAssert.withFailMessage介绍

暂无

代码示例

代码示例来源:origin: openzipkin/brave

/**
 * Tests that the span propagates between under asynchronous callbacks (even if explicitly)
 */
@Test
public void async() throws Exception {
 Response response = get("/async");
 assertThat(response.isSuccessful()).withFailMessage("not successful: " + response).isTrue();
 takeSpan();
}

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

private void testGetGrantedAuthorities(
      MapBasedAttributes2GrantedAuthoritiesMapper mapper, String[] roles,
      String[] expectedGas) {
    List<GrantedAuthority> result = mapper
        .getGrantedAuthorities(Arrays.asList(roles));
    Collection resultColl = new ArrayList(result.size());
    for (GrantedAuthority auth : result) {
      resultColl.add(auth.getAuthority());
    }
    Collection expectedColl = Arrays.asList(expectedGas);
    assertThat(resultColl.containsAll(expectedColl)).withFailMessage("Role collections should match; result: " + resultColl
        + ", expected: " + expectedColl).isTrue();
  }
}

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

private void assertNotFound(
  final Map<Integer, Pair<ExecutionReference, ExecutableFlow>> activeFlows,
  final ExecutableFlow flow, final String failMessage) {
 assertThat(activeFlows.containsKey(flow.getExecutionId())).withFailMessage(failMessage)
   .isFalse();
}

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

private void testGetGrantedAuthorities(
    SimpleAttributes2GrantedAuthoritiesMapper mapper, String[] roles,
    String[] expectedGas) {
  List<GrantedAuthority> result = mapper
      .getGrantedAuthorities(Arrays.asList(roles));
  Collection<String> resultColl = new ArrayList<>(result.size());
  for (int i = 0; i < result.size(); i++) {
    resultColl.add(result.get(i).getAuthority());
  }
  Collection<String> expectedColl = Arrays.asList(expectedGas);
  assertThat(expectedColl.containsAll(resultColl)
      && resultColl.containsAll(expectedColl)).withFailMessage("Role collections do not match; result: " + resultColl
      + ", expected: " + expectedColl).isTrue();
}

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

@Test
public void testLoginSuccess() throws Exception {
  SecurityContextHolder.getContext().setAuthentication(this.auth);
  assertThat(this.module.login())
      .as("Login should succeed, there is an authentication set").isTrue();
  assertThat(this.module.commit())
      .withFailMessage(
          "The authentication is not null, this should return true")
      .isTrue();
  assertThat(this.subject.getPrincipals().contains(this.auth))
      .withFailMessage("Principals should contain the authentication").isTrue();
}

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

@After
public void doTearDown() {
  assertThat(h.isClosed()).isTrue().withFailMessage("Handle was not closed correctly!");
}

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

@Test
public void testLogout() throws Exception {
  SecurityContextHolder.getContext().setAuthentication(this.auth);
  this.module.login();
  assertThat(this.module.logout()).as("Should return true as it succeeds").isTrue();
  assertThat(this.module.getAuthentication()).as("Authentication should be null")
      .isNull();
  assertThat(this.subject.getPrincipals().contains(this.auth))
      .withFailMessage(
          "Principals should not contain the authentication after logout")
      .isFalse();
}

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

@Test
public final void testGetSetMappableRoles() {
  Set<String> roles = StringUtils.commaDelimitedListToSet("Role1,Role2");
  SimpleMappableAttributesRetriever r = new SimpleMappableAttributesRetriever();
  r.setMappableAttributes(roles);
  Set<String> result = r.getMappableAttributes();
  assertThat(
      roles.containsAll(result) && result.containsAll(roles)).withFailMessage(
          "Role collections do not match; result: " + result
              + ", expected: " + roles).isTrue();
}

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

@Test
public void testRespectsRolePrefix() throws Exception {
  UsernamePasswordAuthenticationToken inputToken = new UsernamePasswordAuthenticationToken(
      "Test", "Password", AuthorityUtils.createAuthorityList("ONE", "TWO"));
  RunAsManagerImpl runAs = new RunAsManagerImpl();
  runAs.setKey("my_password");
  runAs.setRolePrefix("FOOBAR_");
  Authentication result = runAs.buildRunAs(inputToken, new Object(),
      SecurityConfig.createList("RUN_AS_SOMETHING"));
  assertThat(result instanceof RunAsUserToken).withFailMessage(
      "Should have returned a RunAsUserToken").isTrue();
  assertThat(result.getPrincipal()).isEqualTo(inputToken.getPrincipal());
  assertThat(result.getCredentials()).isEqualTo(inputToken.getCredentials());
  Set<String> authorities = AuthorityUtils.authorityListToSet(
      result.getAuthorities());
  assertThat(authorities.contains("FOOBAR_RUN_AS_SOMETHING")).isTrue();
  assertThat(authorities.contains("ONE")).isTrue();
  assertThat(authorities.contains("TWO")).isTrue();
  RunAsUserToken resultCast = (RunAsUserToken) result;
  assertThat(resultCast.getKeyHash()).isEqualTo("my_password".hashCode());
}

代码示例来源:origin: reactor/reactor-core

@Test
public void syncPollAfterTerminateCalled() {
  AtomicBoolean onAfterTerminate = new AtomicBoolean();
  ConnectableFlux<Integer> f = Flux.just(1)
                  .doAfterTerminate(() -> onAfterTerminate.set(true))
                  .publish();
  StepVerifier.create(f)
        .then(f::connect)
        .expectNext(1)
        .verifyComplete();
  assertThat(onAfterTerminate.get()).withFailMessage("onAfterTerminate not called back").isTrue();
}

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

@Test
public void testFull() throws Exception {
  UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
      "user", "password", AuthorityUtils.createAuthorityList("ROLE_ONE"));
  assertThat(jaasProvider.supports(UsernamePasswordAuthenticationToken.class)).isTrue();
  Authentication auth = jaasProvider.authenticate(token);
  assertThat(jaasProvider.getAuthorityGranters()).isNotNull();
  assertThat(jaasProvider.getCallbackHandlers()).isNotNull();
  assertThat(jaasProvider.getLoginConfig()).isNotNull();
  assertThat(jaasProvider.getLoginContextName()).isNotNull();
  Collection<? extends GrantedAuthority> list = auth.getAuthorities();
  Set<String> set = AuthorityUtils.authorityListToSet(list);
  assertThat(set.contains("ROLE_ONE")).withFailMessage("GrantedAuthorities should not contain ROLE_ONE").isFalse();
  assertThat(set.contains("ROLE_TEST1")).withFailMessage("GrantedAuthorities should contain ROLE_TEST1").isTrue();
  assertThat(set.contains("ROLE_TEST2")).withFailMessage("GrantedAuthorities should contain ROLE_TEST2").isTrue();
  boolean foundit = false;
  for (GrantedAuthority a : list) {
    if (a instanceof JaasGrantedAuthority) {
      JaasGrantedAuthority grant = (JaasGrantedAuthority) a;
      assertThat(grant.getPrincipal()).withFailMessage("Principal was null on JaasGrantedAuthority").isNotNull();
      foundit = true;
    }
  }
  assertThat(foundit).as("Could not find a JaasGrantedAuthority").isTrue();
  assertThat(eventCheck.successEvent).as("Success event should be fired").isNotNull();
  assertThat(eventCheck.successEvent.getAuthentication()).withFailMessage("Auth objects should be equal").isEqualTo(auth);
  assertThat(eventCheck.failedEvent).as("Failure event should not be fired").isNull();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void syncPollCompleteCalled() {
  AtomicBoolean onComplete = new AtomicBoolean();
  ConnectableFlux<Integer> f = Flux.just(1)
                  .doOnComplete(() -> onComplete.set(true))
                  .publish();
  StepVerifier.create(f)
        .then(f::connect)
        .expectNext(1)
        .verifyComplete();
  assertThat(onComplete.get()).withFailMessage("onComplete not called back").isTrue();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void syncPollConditionalCompleteCalled() {
  AtomicBoolean onComplete = new AtomicBoolean();
  ConnectableFlux<Integer> f = Flux.just(1)
                  .doOnComplete(() -> onComplete.set(true))
                  .filter(v -> true)
                  .publish();
  StepVerifier.create(f)
        .then(f::connect)
        .expectNext(1)
        .verifyComplete();
  assertThat(onComplete.get()).withFailMessage("onComplete not called back").isTrue();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void syncPollConditionalAfterTerminateCalled() {
  AtomicBoolean onAfterTerminate = new AtomicBoolean();
  ConnectableFlux<Integer> f = Flux.just(1)
                  .doAfterTerminate(() -> onAfterTerminate.set(true))
                  .filter(v -> true)
                  .publish();
  StepVerifier.create(f)
        .then(f::connect)
        .expectNext(1)
        .verifyComplete();
  assertThat(onAfterTerminate.get()).withFailMessage("onAfterTerminate not called back").isTrue();
}

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

assertThat(Math.abs(userNotFoundAvg - userFoundAvg) <= 3).withFailMessage(
    "User not found average " + userNotFoundAvg
        + " should be within 3ms of user found average "

代码示例来源:origin: kiegroup/jbpm

assertThat(caughtEventObjectHolder[0] != null && caughtEventObjectHolder[0] instanceof WorkItem).isTrue().withFailMessage("Event was not passed to Event Subprocess.");
workItem = (WorkItem) caughtEventObjectHolder[0];
Object throwObj = workItem.getParameter(ExceptionService.exceptionParameterName);
assertThat(throwObj instanceof Throwable).isTrue().withFailMessage("WorkItem doesn't contain Throwable.");
assertThat(((Throwable) throwObj).getMessage().endsWith(input)).isTrue().withFailMessage("Exception message does not match service input.");
assertThat(processInstance == null || processInstance.getState() == ProcessInstance.STATE_ABORTED).isTrue().withFailMessage("Process instance has not been aborted.");

代码示例来源:origin: kiegroup/jbpm

assertThat(caughtEventObjectHolder[0] != null && caughtEventObjectHolder[0] instanceof WorkItem).isTrue().withFailMessage("Event was not passed to Event Subprocess.");
WorkItem workItem = (WorkItem) caughtEventObjectHolder[0];
Object throwObj = workItem.getParameter(ExceptionService.exceptionParameterName);
assertThat(throwObj instanceof Throwable).isTrue().withFailMessage("WorkItem doesn't contain Throwable.");
assertThat(((Throwable) throwObj).getMessage().endsWith(input)).isTrue().withFailMessage("Exception message does not match service input.");

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

assertThat(componentTree.getMainThreadLayoutState().isForComponentId(newComponent.getId()))
  .isTrue()
  .withFailMessage(
    "The main thread should calculate a new layout synchronously because the async layout will not have compatible size specs");

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

@Test
public void testMeasureWithIncompatibleSetRootAsyncThatFinishes() {
 ComponentTree componentTree = ComponentTree.create(mContext, mComponent).build();
 componentTree.setLithoView(new LithoView(mContext));
 int widthSpec1 = SizeSpec.makeSizeSpec(1000, SizeSpec.EXACTLY);
 int heightSpec1 = SizeSpec.makeSizeSpec(1000, SizeSpec.AT_MOST);
 int widthSpec2 = SizeSpec.makeSizeSpec(1000, SizeSpec.EXACTLY);
 int heightSpec2 = SizeSpec.makeSizeSpec(0, SizeSpec.UNSPECIFIED);
 componentTree.measure(widthSpec2, heightSpec2, new int[2], false);
 componentTree.attach();
 componentTree.measure(widthSpec1, heightSpec1, new int[2], false);
 Component newComponent = TestDrawableComponent.create(mContext).color(1234).build();
 componentTree.setRootAsync(newComponent);
 runOnBackgroundThreadSync(
   new Runnable() {
    @Override
    public void run() {
     // "Commit" layout (it will fail since it doesn't have compatible size specs)
     mLayoutThreadShadowLooper.runToEndOfTasks();
    }
   });
 componentTree.measure(widthSpec2, heightSpec2, new int[2], false);
 assertThat(componentTree.getRoot()).isEqualTo(newComponent);
 assertThat(componentTree.hasCompatibleLayout(widthSpec2, heightSpec2)).isTrue();
 assertThat(componentTree.getMainThreadLayoutState().isForComponentId(newComponent.getId()))
   .isTrue()
   .withFailMessage(
     "The main thread should calculate a new layout synchronously because the async layout will not be used once it completes");
}

代码示例来源:origin: com.pragmaticobjects.oo.data/data-core

@Override
  public final synchronized void check() throws Exception {
    file.generate();
    Assertions.assertThat(Files.exists(path)).withFailMessage("source file <%s> was not created", path).isTrue();
    final String contents = new String(Files.readAllBytes(path));
    Assertions.assertThat(contents).isEqualToNormalizingNewlines(this.contents);
  }
}

相关文章