本文整理了Java中org.assertj.core.api.AbstractCharSequenceAssert.describedAs()
方法的一些代码示例,展示了AbstractCharSequenceAssert.describedAs()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractCharSequenceAssert.describedAs()
方法的具体详情如下:
包路径:org.assertj.core.api.AbstractCharSequenceAssert
类名称:AbstractCharSequenceAssert
方法名:describedAs
暂无
代码示例来源:origin: SonarSource/sonarqube
@Test
public void generate_returns_unique_values_without_common_initial_letter_given_more_than_one_millisecond_between_generate_calls() throws InterruptedException {
Base64.Encoder encoder = Base64.getEncoder();
int count = 30;
Set<String> uuids = new HashSet<>(count);
for (int i = 0; i < count; i++) {
Thread.sleep(5);
uuids.add(encoder.encodeToString(underTest.generate()));
}
assertThat(uuids).hasSize(count);
Iterator<String> iterator = uuids.iterator();
String firstUuid = iterator.next();
String base = firstUuid.substring(0, firstUuid.length() - 4);
for (int i = 1; i < count; i++) {
assertThat(iterator.next()).describedAs("i=" + i).doesNotStartWith(base);
}
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testFallback() throws Exception {
setupStub(400);
final String result = testService.greeting();
assertThat(result).describedAs("Result").isNotEqualTo("Hello, world!");
assertThat(result).describedAs("Result").isEqualTo("fallback");
verify(testServiceFallback, times(1)).greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void verify_toString() {
assertThat(Health.GREEN.toString()).isEqualTo("Health{GREEN, causes=[]}");
Health.Builder builder = newHealthCheckBuilder().setStatus(anyStatus);
randomCauses.forEach(builder::addCause);
String underTest = builder.build().toString();
AbstractCharSequenceAssert<?, String> a = assertThat(underTest)
.describedAs("toString for status %s and causes %s", anyStatus, randomCauses);
if (randomCauses.isEmpty()) {
a.isEqualTo("Health{" + anyStatus + ", causes=[]}");
} else if (randomCauses.size() == 1) {
a.isEqualTo("Health{" + anyStatus + ", causes=[" + randomCauses.iterator().next() + "]}");
} else {
a.startsWith("Health{" + anyStatus + ", causes=[")
.endsWith("]}")
.contains(randomCauses);
}
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testSuccessful() throws Exception {
setupStub(200);
final String result = testService.greeting();
assertThat(result).describedAs("Result").isEqualTo("Hello, world!");
verify(testServiceFallback, times(0)).greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testFallbackExceptionFilterNotCalled() throws Exception {
final TestService testServiceExceptionFallback = mock(TestService.class);
when(testServiceExceptionFallback.greeting()).thenReturn("exception fallback");
final FeignDecorators decorators = FeignDecorators.builder()
.withFallback(testServiceExceptionFallback, CircuitBreakerOpenException.class)
.withFallback(testServiceFallback)
.build();
testService = Resilience4jFeign.builder(decorators).target(TestService.class, MOCK_URL);
setupStub(400);
final String result = testService.greeting();
assertThat(result).describedAs("Result").isNotEqualTo("Hello, world!");
assertThat(result).describedAs("Result").isEqualTo("fallback");
verify(testServiceFallback, times(1)).greeting();
verify(testServiceExceptionFallback, times(0)).greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testRevertFallback() throws Exception {
setupStub(400);
testService.greeting();
setupStub(200);
final String result = testService.greeting();
assertThat(result).describedAs("Result").isEqualTo("Hello, world!");
verify(testServiceFallback, times(1)).greeting();
verify(2, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testFallbackFilterNotCalled() throws Exception {
final TestService testServiceFilterFallback = mock(TestService.class);
when(testServiceFilterFallback.greeting()).thenReturn("filter fallback");
final FeignDecorators decorators = FeignDecorators.builder()
.withFallback(testServiceFilterFallback, ex -> false)
.withFallback(testServiceFallback)
.build();
testService = Resilience4jFeign.builder(decorators).target(TestService.class, MOCK_URL);
setupStub(400);
final String result = testService.greeting();
assertThat(result).describedAs("Result").isNotEqualTo("Hello, world!");
assertThat(result).describedAs("Result").isEqualTo("fallback");
verify(testServiceFallback, times(1)).greeting();
verify(testServiceFilterFallback, times(0)).greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testFallbackExceptionFilter() throws Exception {
final TestService testServiceExceptionFallback = mock(TestService.class);
when(testServiceExceptionFallback.greeting()).thenReturn("exception fallback");
final FeignDecorators decorators = FeignDecorators.builder()
.withFallback(testServiceExceptionFallback, FeignException.class)
.withFallback(testServiceFallback)
.build();
testService = Resilience4jFeign.builder(decorators).target(TestService.class, MOCK_URL);
setupStub(400);
final String result = testService.greeting();
assertThat(result).describedAs("Result").isNotEqualTo("Hello, world!");
assertThat(result).describedAs("Result").isEqualTo("exception fallback");
verify(testServiceFallback, times(0)).greeting();
verify(testServiceExceptionFallback, times(1)).greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: resilience4j/resilience4j
@Test
public void testFallbackFilter() throws Exception {
final TestService testServiceFilterFallback = mock(TestService.class);
when(testServiceFilterFallback.greeting()).thenReturn("filter fallback");
final FeignDecorators decorators = FeignDecorators.builder()
.withFallback(testServiceFilterFallback, ex -> true)
.withFallback(testServiceFallback)
.build();
testService = Resilience4jFeign.builder(decorators).target(TestService.class, MOCK_URL);
setupStub(400);
final String result = testService.greeting();
assertThat(result).describedAs("Result").isNotEqualTo("Hello, world!");
assertThat(result).describedAs("Result").isEqualTo("filter fallback");
verify(testServiceFallback, times(0)).greeting();
verify(testServiceFilterFallback, times(1)).greeting();
verify(1, getRequestedFor(urlPathEqualTo("/greeting")));
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void get_trims_key_before_looking_for_replacement() {
Random random = new Random();
String key = RandomStringUtils.randomAlphanumeric(4);
String deprecatedKey = RandomStringUtils.randomAlphanumeric(4);
PropertyDefinitions underTest = new PropertyDefinitions(singletonList(
PropertyDefinition.builder(key)
.deprecatedKey(deprecatedKey)
.build()));
String untrimmedKey = blank(random) + deprecatedKey + blank(random);
assertThat(underTest.get(untrimmedKey).key())
.describedAs("expecting key %s being returned for get(%s)", key, untrimmedKey)
.isEqualTo(key);
}
代码示例来源:origin: io.syndesis.integration-runtime/model
public static Function assertFunctionStep(Flow flow, int index, String expectedName) {
Function step = assertFlowHasStep(flow, index, Function.class);
assertThat(step.getName()).describedAs("flow " + flow + " step " + index + " endpoint " + step + " name").isEqualTo(expectedName);
assertThat(step.getKind()).describedAs("flow " + flow + " step " + index + " endpoint " + step + " kind").isEqualTo(Function.KIND);
return step;
}
代码示例来源:origin: io.syndesis.integration-runtime/model
public static Endpoint assertEndpointStep(Flow flow, int index, String expectedUri) {
Endpoint step = assertFlowHasStep(flow, index, Endpoint.class);
assertThat(step.getUri()).describedAs("flow " + flow + " step " + index + " endpoint " + step + " URI").isEqualTo(expectedUri);
assertThat(step.getKind()).describedAs("flow " + flow + " step " + index + " endpoint " + step + " kind").isEqualTo(Endpoint.KIND);
return step;
}
代码示例来源:origin: org.apache.james.protocols/protocols-imap
private void dateDecode(String in, TimeZone zone) throws Exception {
Date date = DecoderUtils.decodeDateTime(in);
String out = formatAsImap(date, zone);
assertThat(out).describedAs("Round trip").isEqualTo(in);
}
代码示例来源:origin: HubSpot/slack-client
@Test
public void itDoesElideAuthTokensInUrl() throws Exception {
assertThat(
HttpFormatter.urlWithRedactedToken(
"https://slack.com/api/channels.info?token=xoxb-000000000000-AAAAAAoM5xCesZ1d9HDFhKMG"
)
)
.describedAs("If it looks like a URL with only the raw token, we should redact the full token, providing just a fingerprint")
.isEqualTo("https://slack.com/api/channels.info?token=xox...hKMG");
assertThat(
HttpFormatter.urlWithRedactedToken(
"https://slack.com/api/channels.info?foo=bar&token=xoxb-000000000000-AAAAAAoM5xCesZ1d9HDFhKMG&baz=why"
)
)
.describedAs("If it looks like a URL with the raw token and other query params, we should redact the full token, providing just a fingerprint")
.isEqualTo("https://slack.com/api/channels.info?foo=bar&token=xox...hKMG&baz=why");
}
}
代码示例来源:origin: org.apache.james.protocols/protocols-imap
@Test
public void testResponseCodeExtension() {
assertThat(StatusResponse.ResponseCode.createExtension("XEXTENSION")
.getCode()).describedAs("Preserve names beginning with X").isEqualTo("XEXTENSION");
assertThat(StatusResponse.ResponseCode.createExtension("EXTENSION")
.getCode()).describedAs("Correct other names").isEqualTo("XEXTENSION");
}
代码示例来源:origin: TNG/junit-dataprovider
protected void assertDataProviderFrameworkMethods(List<FrameworkMethod> actuals, List<Object[]> expecteds,
String expectedNameFormat) {
assertThat(actuals).hasSameSizeAs(expecteds);
for (int idx = 0; idx < actuals.size(); idx++) {
assertThat(actuals.get(idx)).describedAs("at idx " + idx).isInstanceOf(DataProviderFrameworkMethod.class);
DataProviderFrameworkMethod actual = (DataProviderFrameworkMethod) actuals.get(idx);
assertThat(actual.idx).describedAs("at idx " + idx).isEqualTo(idx);
assertThat(actual.parameters).describedAs("at idx " + idx).isEqualTo(expecteds.get(idx));
assertThat(actual.nameFormat).describedAs("at idx " + idx).isEqualTo(expectedNameFormat);
}
}
代码示例来源:origin: dhleong/intellivim
public ResultAssert hasErrorContaining(String expected) {
isNotNull();
isNotSuccess();
assertThat(asSimpleResult().error)
.describedAs("Error Message")
.contains(expected);
return myself;
}
代码示例来源:origin: HubSpot/slack-client
@Test
public void itDoesElideAuthTokensInHeader() throws Exception {
assertThat(
HttpFormatter.safeHeaderString(
"Authorization",
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2V4YW1wbGUuYXV0aDAuY29tLyIsImF1ZCI6Imh0dHBzOi8vYXBpLmV4YW1wbGUuY29tL2NhbGFuZGFyL3YxLyIsInN1YiI6InVzcl8xMjMiLCJpYXQiOjE0NTg3ODU3OTYsImV4cCI6MTQ1ODg3MjE5Nn0.CA7eaHjIHz5NxeIJoFK9krqaeZrPLwmMmgI_XiQiIkQ"
)
)
.describedAs("If it looks like a bearer HTTP auth token, we should redact the full token, providing just a fingerprint")
.contains("Authorization = Bearer eyJ...iIkQ");
assertThat(
HttpFormatter.safeHeaderString(
"Authorization",
"Bearer eiQiIkQ"
)
)
.describedAs("If it looks like a short HTTP auth token, we should redact the full token, providing just a fingerprint")
.contains("Authorization = Bearer e...Q");
assertThat(
HttpFormatter.safeHeaderString(
"Authorization",
"Basic YWxhZGRpbjpvcGVuc2VzYW1l"
)
)
.describedAs("If it looks like a basic HTTP auth token, we should redact the full token, providing just a fingerprint")
.contains("Authorization = Basic YWx...YW1l");
}
代码示例来源:origin: spring-projects/spring-ldap
@Test
public void testFindByDn() {
Person person = tested.findByDn(LdapUtils.newLdapName("cn=Some Person3,ou=company1,ou=Sweden"), Person.class);
assertThat(person).isNotNull();
assertThat(person.getCommonName()).isEqualTo("Some Person3");
assertThat(person.getSurname()).isEqualTo("Person3");
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
assertThat(person.getEntryUuid()).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty();
}
代码示例来源:origin: bsideup/graphql-java-reactive
protected Consumer<Change> matchChange(String path, Object value) {
return change -> assertThat(change)
.describedAs("change")
.isNotNull()
.satisfies(it -> assertThat(ChangesTestSubscriber.getPathString(it)).describedAs("path").isEqualTo(path))
.satisfies(it -> assertThat(it.getData()).describedAs("data").isEqualTo(value));
}
内容来源于网络,如有侵权,请联系作者删除!