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

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

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

Assertions.assertThatIllegalStateException介绍

[英]Alias for #assertThatExceptionOfType(Class) for IllegalStateException.
[中]IllegalStateException的类型(类)的#AssertThatException的别名。

代码示例

代码示例来源:origin: spring-io/initializr

@Test
void noRangeAvailable() {
  BillOfMaterials bom = BillOfMaterials.create("com.example", "bom");
  bom.getMappings().add(Mapping.create("[1.2.0.RELEASE,1.3.0.M1)", "1.1.0"));
  bom.getMappings().add(Mapping.create("[1.3.0.M1, 1.4.0.M1)", "1.2.0"));
  bom.validate();
  assertThatIllegalStateException()
      .isThrownBy(() -> bom.resolve(Version.parse("1.4.1.RELEASE")))
      .withMessageContaining("1.4.1.RELEASE");
}

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

@Test
public void queuePollError() {
  //prepare registry with mock clock
  MockClock clock = new MockClock();
  removeRegistry();
  registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock);
  Metrics.globalRegistry.add(registry);
  AssertSubscriber<Integer> testSubscriber = AssertSubscriber.create();
  MicrometerMonoMetricsFuseableSubscriber<Integer> fuseableSubscriber =
      new MicrometerMonoMetricsFuseableSubscriber<>(testSubscriber,
          registry, clock, "foo", Collections.emptyList());
  FluxPeekFuseableTest.AssertQueueSubscription<Integer> testQueue = new FluxPeekFuseableTest.AssertQueueSubscription<>();
  testQueue.setCompleteWithError(true);
  testQueue.offer(1);
  fuseableSubscriber.onSubscribe(testQueue);
  fuseableSubscriber.requestFusion(Fuseable.SYNC);
  clock.add(Duration.ofMillis(200));
  Integer val1 = fuseableSubscriber.poll();
  assertThat(val1).isEqualTo(1);
  clock.add(Duration.ofMillis(123));
  assertThatIllegalStateException().isThrownBy(fuseableSubscriber::poll)
                   .withMessage("AssertQueueSubscriber poll error");
  //test meters
  Timer terminationTimer = registry.find(METER_FLOW_DURATION)
               .tag(TAG_STATUS, TAGVALUE_ON_ERROR)
               .timer();
  assertThat(terminationTimer).isNotNull();
  assertThat(terminationTimer.max(TimeUnit.MILLISECONDS)).as("terminate max delay").isEqualTo(323);
}

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

@Test
public void queuePollError() {
  //prepare registry with mock clock
  MockClock clock = new MockClock();
  removeRegistry();
  registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock);
  Metrics.globalRegistry.add(registry);
  AssertSubscriber<Integer> testSubscriber = AssertSubscriber.create();
  MicrometerFluxMetricsFuseableSubscriber<Integer> fuseableSubscriber =
      new MicrometerFluxMetricsFuseableSubscriber<>(testSubscriber,
          registry, clock, "foo", Collections.emptyList());
  FluxPeekFuseableTest.AssertQueueSubscription<Integer> testQueue = new FluxPeekFuseableTest.AssertQueueSubscription<>();
  testQueue.setCompleteWithError(true);
  testQueue.offer(1);
  fuseableSubscriber.onSubscribe(testQueue);
  fuseableSubscriber.requestFusion(Fuseable.SYNC);
  clock.add(Duration.ofMillis(200));
  Integer val1 = fuseableSubscriber.poll();
  assertThat(val1).isEqualTo(1);
  clock.add(Duration.ofMillis(123));
  assertThatIllegalStateException().isThrownBy(fuseableSubscriber::poll)
                   .withMessage("AssertQueueSubscriber poll error");
  //test meters
  Timer terminationTimer = registry.find(METER_FLOW_DURATION)
               .tag(TAG_STATUS, TAGVALUE_ON_ERROR)
               .timer();
  assertThat(terminationTimer).isNotNull();
  assertThat(terminationTimer.max(TimeUnit.MILLISECONDS)).as("terminate max delay").isEqualTo(323);
}

代码示例来源:origin: apache/james-project

@Test
void fromJsonStringShouldThrowOnMalformedFormattedJson() {
  assertThatIllegalStateException()
    .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"IntSerializer\",\"value\": []}"));
}

代码示例来源:origin: apache/james-project

@Test
void fromJsonStringShouldThrowOnMissingSerializerField() {
  assertThatIllegalStateException()
    .isThrownBy(() -> AttributeValue.fromJsonString("{\"value\": \"value\"}"));
}

代码示例来源:origin: apache/james-project

@Test
void fromJsonStringShouldThrowOnMissingValueField() {
  assertThatIllegalStateException()
    .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"MapSerializer\"}"));
}

代码示例来源:origin: apache/james-project

@Test
  void fromJsonStringShouldThrowOnFloatJson() {
    assertThatIllegalStateException()
      .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"LongSerializer\",\"value\": 42.0}"));
  }
}

代码示例来源:origin: apache/james-project

@Test
  void fromJsonStringShouldThrowOnIntNode() {
    assertThatIllegalStateException()
      .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"DoubleSerializer\",\"value\": 1}"));
  }
}

代码示例来源:origin: apache/james-project

@Test
  void fromJsonStringShouldThrowOnMalformedFormattedJson() {
    assertThatIllegalStateException()
      .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"CollectionSerializer\",\"value\": {}}"));
  }
}

代码示例来源:origin: apache/james-project

@Test
  void fromJsonStringShouldThrowOnMalformedFormattedJson() {
    assertThatIllegalStateException()
      .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"StringSerializer\",\"value\": []}"));
  }
}

代码示例来源:origin: apache/james-project

@Test
void fromJsonStringShouldThrowOnMalformedFormattedJson() {
  assertThatIllegalStateException()
    .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"LongSerializer\",\"value\": []}"));
}

代码示例来源:origin: apache/james-project

@Test
void fromJsonStringShouldThrowOnMalformedFormattedJson() {
  assertThatIllegalStateException()
    .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"FloatSerializer\",\"value\": []}"));
}

代码示例来源:origin: apache/james-project

@Test
  void fromJsonStringShouldThrowOnMalformedFormattedJson() {
    assertThatIllegalStateException()
      .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"OptionalSerializer\",\"value\": []}"));
  }
}

代码示例来源:origin: apache/james-project

@Test
  void fromJsonStringShouldThrowOnMalformedFormattedJson() {
    assertThatIllegalStateException()
      .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"BooleanSerializer\",\"value\": []}"));
  }
}

代码示例来源:origin: apache/james-project

@Test
void fromJsonStringShouldThrowOnFloatJson() {
  assertThatIllegalStateException()
    .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"IntSerializer\",\"value\": 42.0}"));
}

代码示例来源:origin: apache/james-project

@Test
void fromJsonStringShouldThrowOnMalformedFormattedJson() {
  assertThatIllegalStateException()
    .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"DoubleSerializer\",\"value\": []}"));
}

代码示例来源:origin: apache/james-project

@Test
  void fromJsonStringShouldThrowOnMalformedFormattedJson() {
    assertThatIllegalStateException()
      .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"UrlSerializer\",\"value\": {}}"));
  }
}

代码示例来源:origin: apache/james-project

@Test
  void fromJsonStringShouldThrowOnMalformedFormattedJson() {
    assertThatIllegalStateException()
      .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"MessageIdDtoSerializer\",\"value\": {}}"));
  }
}

代码示例来源:origin: apache/james-project

@Test
  void fromJsonStringShouldThrowOnMalformedFormattedJson() {
    assertThatIllegalStateException()
      .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"MapSerializer\",\"value\": []}"));
  }
}

代码示例来源:origin: apache/james-project

@Test
  void fromJsonStringShouldThrowOnIntNode() {
    assertThatIllegalStateException()
      .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"FloatSerializer\",\"value\": 1}"));
  }
}

相关文章