本文整理了Java中org.assertj.core.api.AbstractCharSequenceAssert.as()
方法的一些代码示例,展示了AbstractCharSequenceAssert.as()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractCharSequenceAssert.as()
方法的具体详情如下:
包路径:org.assertj.core.api.AbstractCharSequenceAssert
类名称:AbstractCharSequenceAssert
方法名:as
暂无
代码示例来源:origin: SonarSource/sonarqube
private void assertNoParam(String... keys) {
Arrays.stream(keys).forEach(key -> {
assertThat(servletRequestCaptor.getValue().hasParam(key)).as(key).isFalse();
assertThat(servletRequestCaptor.getValue().readParam(key)).as(key).isNull();
});
}
代码示例来源:origin: stagemonitor/stagemonitor
private void validateSpanJson(JsonNode spanJson) {
assertThat(spanJson.get("error").booleanValue()).as(spanJson.toString()).isFalse();
assertThat(spanJson.get("foo.bar").asText()).as(spanJson.toString()).isEqualTo("baz");
assertThat(spanJson.get("parameters")).as(spanJson.toString()).isNotNull();
assertThat(spanJson.get("parameters").size()).as(spanJson.toString()).isEqualTo(3);
assertThat(spanJson.get("parameters").get(0).get("key")).as(spanJson.toString()).isNotNull();
assertThat(spanJson.get("parameters").get(0).get("value")).as(spanJson.toString()).isNotNull();
}
代码示例来源:origin: stagemonitor/stagemonitor
@Test
public void reportSpan() throws Exception {
reporter.report(mock(SpanContextInformation.class), getSpan(100));
elasticsearchClient.waitForCompletion();
refresh();
final JsonNode hits = elasticsearchClient.getJson("/stagemonitor-spans*/_search").get("hits");
assertThat(hits.get("total").intValue()).as(hits.toString()).isEqualTo(1);
final JsonNode spanJson = hits.get("hits").elements().next().get("_source");
assertThat(spanJson.get("type").asText()).as(spanJson.toString()).isEqualTo("jdbc");
assertThat(spanJson.get("method").asText()).as(spanJson.toString()).isEqualTo("SELECT");
assertThat(spanJson.get("db.statement")).as(spanJson.toString()).isNotNull();
assertThat(spanJson.get("db.statement").asText()).as(spanJson.toString()).isEqualTo("SELECT * from STAGEMONITOR where 1 < 2");
assertThat(spanJson.get("duration_ms").asInt()).as(spanJson.toString()).isEqualTo(100);
assertThat(spanJson.get("name").asText()).as(spanJson.toString()).isEqualTo("ElasticsearchExternalSpanReporterIntegrationTest#test");
}
代码示例来源:origin: SonarSource/sonarqube
@CheckForNull
private PK pkOf(Connection connection, String tableName) throws SQLException {
try (ResultSet resultSet = connection.getMetaData().getPrimaryKeys(null, null, tableName)) {
String pkName = null;
List<PkColumn> columnNames = null;
while (resultSet.next()) {
if (columnNames == null) {
pkName = resultSet.getString("PK_NAME");
columnNames = new ArrayList<>(1);
} else {
assertThat(pkName).as("Multiple primary keys found").isEqualTo(resultSet.getString("PK_NAME"));
}
columnNames.add(new PkColumn(resultSet.getInt("KEY_SEQ") - 1, resultSet.getString("COLUMN_NAME")));
}
if (columnNames == null) {
return null;
}
return new PK(
pkName,
columnNames.stream()
.sorted(PkColumn.ORDERING_BY_INDEX)
.map(PkColumn::getName)
.collect(MoreCollectors.toList()));
}
}
代码示例来源:origin: kiegroup/jbpm
protected void assertActualOwner(Task task, String expectedActualOwner) {
User actualOwner = task.getTaskData().getActualOwner();
assertThat(actualOwner).as("No actual owner when expected").isNotNull();
assertThat(actualOwner.getId()).as("Not matching actual owner").isEqualTo(expectedActualOwner);
}
代码示例来源:origin: stagemonitor/stagemonitor
@Test
public void testUpdateSpan() throws Exception {
final Span span = tracer.buildSpan("Test#test")
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER)
.start();
span.finish();
elasticsearchClient.waitForCompletion();
refresh();
reporter.updateSpan(B3HeaderFormat.getB3Identifiers(tracer, span), null, Collections.singletonMap("foo", "bar"));
refresh();
final JsonNode hits = elasticsearchClient.getJson("/stagemonitor-spans*/_search").get("hits");
assertThat(hits.get("total").intValue()).as(hits.toString()).isEqualTo(1);
final JsonNode spanJson = hits.get("hits").elements().next().get("_source");
assertThat(spanJson.get("foo").asText()).as(spanJson.toString()).isEqualTo("bar");
}
代码示例来源:origin: stagemonitor/stagemonitor
@Test
public void testUpdateNotYetExistentSpan_eventuallyUpdates() throws Exception {
final Span span = tracer.buildSpan("Test#test")
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER)
.start();
reporter.updateSpan(B3HeaderFormat.getB3Identifiers(tracer, span), null, Collections.singletonMap("foo", "bar"));
span.finish();
elasticsearchClient.waitForCompletion();
refresh();
reporter.getUpdateReporter().flush();
refresh();
final JsonNode hits = elasticsearchClient.getJson("/stagemonitor-spans*/_search").get("hits");
assertThat(hits.get("total").intValue()).as(hits.toString()).isEqualTo(1);
final JsonNode spanJson = hits.get("hits").elements().next().get("_source");
assertThat(spanJson.get("foo").asText()).as(spanJson.toString()).isEqualTo("bar");
}
代码示例来源:origin: grandcentrix/ThirtyInch
@Override
public void call(final TiView tiView) {
// Then the work gets executed on the ui thread
final Thread currentThread = Thread.currentThread();
assertThat(testThread).isNotSameAs(currentThread);
assertThat("test ui thread")
.as("executed on wrong thread")
.isEqualTo(currentThread.getName());
latch.countDown();
}
});
代码示例来源:origin: grandcentrix/ThirtyInch
@Override
public void run() {
// Then the work gets executed on the correct thread
final Thread currentThread = Thread.currentThread();
assertThat(testThread).isNotSameAs(currentThread);
assertThat("test ui thread")
.as("executed on wrong thread")
.isEqualTo(currentThread.getName());
latch.countDown();
}
});
代码示例来源:origin: blox/blox
.getEnvironment();
assertThat(environment.getEnvironmentName()).as("environment name").isEqualTo(environmentName);
assertThat(environment.getActiveEnvironmentRevisionId()).isNull();
代码示例来源:origin: diffplug/spotless
/**
* Check that configuration change is supported by all WTP formatters.
* Some of the formatters only support static workspace configuration.
* Hence separated class loaders are required for different configurations.
*/
@Test
public void multipleConfigurations() throws Exception {
FormatterStep tabFormatter = createStepForDefaultVersion(config -> {
config.setProperty("indentationChar", "tab");
config.setProperty("indentationSize", "1");
});
FormatterStep spaceFormatter = createStepForDefaultVersion(config -> {
config.setProperty("indentationChar", "space");
config.setProperty("indentationSize", "5");
});
assertThat(formatWith(tabFormatter)).as("Tab formatting output unexpected").isEqualTo(wtp.expectation); //This is the default configuration
assertThat(formatWith(spaceFormatter)).as("Space formatting output unexpected").isEqualTo(wtp.expectation.replace("\t", " "));
}
代码示例来源:origin: diffplug/spotless
@Test
public void invalidPropertyFiles() throws IOException {
for (String settingsResource : INVALID_SETTINGS_RESOURCES) {
File settingsFile = createTestFile(settingsResource);
boolean exceptionCaught = false;
try {
FormatterProperties.from(settingsFile);
} catch (IllegalArgumentException ex) {
exceptionCaught = true;
assertThat(ex.getMessage())
.as("IllegalArgumentException does not contain absolute path of file '%s'", settingsFile.getName())
.contains(settingsFile.getAbsolutePath());
}
assertThat(exceptionCaught)
.as("No IllegalArgumentException thrown when parsing '%s'", settingsFile.getName())
.isTrue();
}
}
代码示例来源:origin: diffplug/spotless
@Test
public void nonExistingFile() throws IOException {
boolean exceptionCaught = false;
String filePath = "does/not/exist.properties";
boolean isWin = LineEnding.PLATFORM_NATIVE.str().equals(LineEnding.WINDOWS.str());
if (isWin) {
filePath = filePath.replace('/', '\\');
}
try {
FormatterProperties.from(new File(filePath));
} catch (IllegalArgumentException ex) {
exceptionCaught = true;
assertThat(ex.getMessage())
.as("IllegalArgumentException does not contain path of non-existing file.").contains(filePath);
}
assertThat(exceptionCaught)
.as("No IllegalArgumentException thrown for non-existing file.").isTrue();
}
代码示例来源:origin: diffplug/spotless
@Test
public void testDelimiterExpr() throws Exception {
final String header = "<!--My tests header-->";
FormatterStep step = LicenseHeaderStep.createFromHeader(header, XmlDefaults.DELIMITER_EXPR);
final File dummyFile = setFile("src/main/file.dummy").toContent("");
for (String testSource : Arrays.asList(
"<!--XML starts with element-->@\n<a></a>",
"<!--XML starts with processing instruction -->@\n<?></a>")) {
String output = null;
try {
output = step.format(testSource, dummyFile);
} catch (IllegalArgumentException e) {
throw new AssertionError(String.format("No delimiter found in '%s'", testSource), e);
}
String expected = testSource.replaceAll("(.*?)\\@", header);
assertThat(output).isEqualTo(expected).as("Unexpected header insertion for '$s'.", testSource);
}
}
代码示例来源:origin: diffplug/spotless
@Test
public void testDelimiterExpr() throws Exception {
final String header = "/*My tests header*/";
FormatterStep step = LicenseHeaderStep.createFromHeader(header, CssDefaults.DELIMITER_EXPR);
final File dummyFile = setFile("src/main/cpp/file1.dummy").toContent("");
for (String testSource : Arrays.asList(
"/* Starts with element selector */@\np {",
"/* Starts with ID selector */@\n#i {",
"/* Starts with class selector */@\n.i {")) {
String output = null;
try {
output = step.format(testSource, dummyFile);
} catch (IllegalArgumentException e) {
throw new AssertionError(String.format("No delimiter found in '%s'", testSource), e);
}
String expected = testSource.replaceAll("(.*?)\\@", header);
assertThat(output).isEqualTo(expected).as("Unexpected header insertion for '$s'.", testSource);
}
}
代码示例来源:origin: diffplug/spotless
@Test
public void testDelimiterExpr() throws Exception {
final String header = "/*My tests header*/";
FormatterStep step = LicenseHeaderStep.createFromHeader(header, CppDefaults.DELIMITER_EXPR);
final File dummyFile = setFile("src/main/cpp/file1.dummy").toContent("");
for (String testSource : Arrays.asList(
"//Accpet multiple spaces between composed term.@using namespace std;",
"//Accpet line delimiters between composed term.@using\n namespace std;",
"//Detecting 'namespace' without 'using'.@namespace foo {}",
"//Assure key is beginning of word. along foo; @long foo;",
"//Detecting pre-processor statements.@#include <stdio.h>\nint i;",
"//Primitive C headers@void foo();",
"//Pointer in C headers@int* foo();",
"//Microsoft C headers@__int8_t foo();")) {
String output = null;
try {
output = step.format(testSource, dummyFile);
} catch (IllegalArgumentException e) {
throw new AssertionError(String.format("No delimiter found in '%s'", testSource), e);
}
String expected = testSource.replaceAll("(.*?)\\@", header + '\n');
assertThat(output).isEqualTo(expected).as("Unexpected header insertion for '$s'.", testSource);
}
}
代码示例来源:origin: twitter/Serial
@Test
public void testGetTypeName() throws IllegalAccessException {
assertThat(SerializerDefs.getTypeName(SerializerDefs.TYPE_UNKNOWN))
.contains("unknown");
for (Field field : SerializerDefs.class.getFields()) {
if (field.getName().startsWith("TYPE_")) {
final byte type = field.getByte(null);
if (type != SerializerDefs.TYPE_UNKNOWN) {
assertThat(SerializerDefs.getTypeName(type))
.as("Type name is unknown: " + field.getName())
.doesNotContain("unknown");
}
}
}
}
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "unit")
public void formatNativeTest() {
for (DataType dt : DataType.allPrimitiveTypes()) {
if (exclude(dt)) continue;
for (TestValue value : primitiveTestValues(dt))
assertThat(codecRegistry.codecFor(dt).format(value.javaObject))
.as("Formatting a %s expecting %s", dt, value.cqlOutputString)
.isEqualTo(value.cqlOutputString);
}
}
代码示例来源:origin: diffplug/spotless
@Test
public void testSupportedVersions() throws Exception {
String[] versions = getSupportedVersions();
for (String version : versions) {
String input = getTestInput(version);
String expected = getTestExpectation(version);
File inputFile = setFile("someInputFile").toContent(input);
FormatterStep step = null;
try {
step = createStep(version);
} catch (Exception e) {
fail("Exception occured when instantiating step for version: " + version, e);
}
String output = null;
try {
output = LineEnding.toUnix(step.format(input, inputFile));
} catch (Exception e) {
fail("Exception occured when formatting input with version: " + version, e);
}
assertThat(output).as("Formatting output unexpected with version: " + version).isEqualTo(expected);
}
}
代码示例来源:origin: hibernate/hibernate-search
private static void assertDelete(DeleteLuceneWork work, DeleteLuceneWork copy) {
assertThat( work.getEntityType() ).as( "Delete.getEntityClass is not copied" )
.isEqualTo( copy.getEntityType() );
assertThat( work.getId() ).as( "Delete.getId is not copied" ).isEqualTo( copy.getId() );
assertThat( (Object) work.getDocument() ).as( "Delete.getDocument is not the same" )
.isEqualTo( copy.getDocument() );
assertThat( work.getIdInString() ).as( "Delete.getIdInString is not the same" )
.isEqualTo( copy.getIdInString() );
assertThat( work.getFieldToAnalyzerMap() ).as( "Delete.getFieldToAnalyzerMap is not the same" )
.isEqualTo( copy.getFieldToAnalyzerMap() );
}
内容来源于网络,如有侵权,请联系作者删除!