本文整理汇总了Java中org.assertj.core.api.SoftAssertions类的典型用法代码示例。如果您正苦于以下问题:Java SoftAssertions类的具体用法?Java SoftAssertions怎么用?Java SoftAssertions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SoftAssertions类属于org.assertj.core.api包,在下文中一共展示了SoftAssertions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldAddTags
import org.assertj.core.api.SoftAssertions; //导入依赖的package包/类
@Test
void shouldAddTags() {
runClasses(TaggedTests.class);
final List<TestResult> testResults = results.getTestResults();
SoftAssertions softly = new SoftAssertions();
softly.assertThat(testResults)
.hasSize(1);
softly.assertThat(testResults)
.flatExtracting(TestResult::getLabels)
.filteredOn(label -> "tag".equals(label.getName()))
.flatExtracting(Label::getValue)
.containsExactlyInAnyOrder(CLASS_TAG, METHOD_TAG);
softly.assertAll();
}
示例2: applyCollectionTypes
import org.assertj.core.api.SoftAssertions; //导入依赖的package包/类
@Test
public void applyCollectionTypes() throws Exception {
SoftAssertions softly = new SoftAssertions();
softly.assertThat(lookup.apply(
CollectionFields.class.getDeclaredField("stringList").getGenericType())
).isEqualTo(IndexType.TEXT);
softly.assertThat(lookup.apply(
CollectionFields.class.getDeclaredField("integerSet").getGenericType())
).isEqualTo(IndexType.NUMBER);
softly.assertThat(lookup.apply(
CollectionFields.class.getDeclaredField("stringArray").getGenericType())
).isEqualTo(IndexType.TEXT);
softly.assertThat(lookup.apply(
CollectionFields.class.getDeclaredField("intArray").getGenericType())
).isEqualTo(IndexType.NUMBER);
softly.assertAll();
}
示例3: verifyTestEntityCollectionSaved
import org.assertj.core.api.SoftAssertions; //导入依赖的package包/类
@SuppressWarnings("Duplicates")
protected void verifyTestEntityCollectionSaved() {
SoftAssertions softly = new SoftAssertions();
TestLongEntity loaded1 = load(1L);
softly.assertThat(loaded1.getId()).isEqualTo(1L);
softly.assertThat(loaded1.getName()).isEqualTo("entity1");
TestLongEntity loaded2 = load(2L);
softly.assertThat(loaded2.getId()).isEqualTo(2L);
softly.assertThat(loaded2.getName()).isEqualTo("entity2");
TestLongEntity loaded3 = load(3L);
softly.assertThat(loaded3.getId()).isEqualTo(3L);
softly.assertThat(loaded3.getName()).isEqualTo("entity3");
softly.assertAll();
}
示例4: verifyTestEntityCollectionSaved
import org.assertj.core.api.SoftAssertions; //导入依赖的package包/类
@SuppressWarnings("Duplicates")
protected void verifyTestEntityCollectionSaved() {
SoftAssertions softly = new SoftAssertions();
TestStringEntity loaded1 = load("id1");
softly.assertThat(loaded1.getId()).isEqualTo("id1");
softly.assertThat(loaded1.getName()).isEqualTo("entity1");
TestStringEntity loaded2 = load("id2");
softly.assertThat(loaded2.getId()).isEqualTo("id2");
softly.assertThat(loaded2.getName()).isEqualTo("entity2");
TestStringEntity loaded3 = load("id3");
softly.assertThat(loaded3.getId()).isEqualTo("id3");
softly.assertThat(loaded3.getName()).isEqualTo("entity3");
softly.assertAll();
}
示例5: verifyTestEntityCollectionSaved
import org.assertj.core.api.SoftAssertions; //导入依赖的package包/类
protected void verifyTestEntityCollectionSaved() {
SoftAssertions softly = new SoftAssertions();
TestLongEntity loaded1 = load(1L);
softly.assertThat(loaded1.getId()).isEqualTo(1L);
softly.assertThat(loaded1.getName()).isEqualTo("entity1");
TestLongEntity loaded2 = load(2L);
softly.assertThat(loaded2.getId()).isEqualTo(2L);
softly.assertThat(loaded2.getName()).isEqualTo("entity2");
TestLongEntity loaded3 = load(3L);
softly.assertThat(loaded3.getId()).isEqualTo(3L);
softly.assertThat(loaded3.getName()).isEqualTo("entity3");
softly.assertAll();
}
示例6: test_lineSeparator_suffix
import org.assertj.core.api.SoftAssertions; //导入依赖的package包/类
@Test
public void test_lineSeparator_suffix() {
// Create the log event.
SimpleMessage message = new SimpleMessage("Hello, World!");
LogEvent logEvent = Log4jLogEvent
.newBuilder()
.setLoggerName(LogstashLayoutTest.class.getSimpleName())
.setLevel(Level.INFO)
.setMessage(message)
.build();
// Check line separators.
SoftAssertions assertions = new SoftAssertions();
test_lineSeparator_suffix(logEvent, true, assertions);
test_lineSeparator_suffix(logEvent, false, assertions);
assertions.assertAll();
}
示例7: equals
import org.assertj.core.api.SoftAssertions; //导入依赖的package包/类
@Test
public void equals() {
final Participation p = mock();
final ParticipationDescriptor d = new ParticipationDescriptor(p);
final RecommendedParticipation r = new RecommendedParticipation(d);
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(r).isNotEqualTo(null);
softly.assertThat(r).isNotEqualTo(UUID.randomUUID().toString());
softly.assertThat(r).isEqualTo(r);
});
final RecommendedParticipation r2 = new RecommendedParticipation(d);
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(r).isEqualTo(r2);
softly.assertThat(r2).isEqualTo(r);
});
final RecommendedParticipation r3 = new RecommendedParticipation(new ParticipationDescriptor(mock()));
Assertions.assertThat(r).isNotEqualTo(r3);
}
示例8: coreWithTweaks
import org.assertj.core.api.SoftAssertions; //导入依赖的package包/类
@Test
public void coreWithTweaks() {
// prepare
final InstallData localData = RoboZonkyInstallerListenerTest.mockData();
Mockito.when(localData.getVariable(Variables.IS_DRY_RUN.getKey())).thenReturn("true");
Mockito.when(localData.getVariable(Variables.IS_ZONKOID_ENABLED.getKey())).thenReturn("true");
Mockito.when(localData.getVariable(Variables.ZONKOID_TOKEN.getKey())).thenReturn("123456");
RoboZonkyInstallerListener.setInstallData(localData);
// execute SUT
final CommandLinePart clp = new RoboZonkyInstallerListener().prepareCore();
// test
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(clp.getOptions())
.containsKey("-d")
.containsKey("-x");
softly.assertThat(clp.getOptions().get("-p"))
.containsOnly(String.valueOf(RoboZonkyInstallerListener.KEYSTORE_PASSWORD));
});
}
示例9: equals
import org.assertj.core.api.SoftAssertions; //导入依赖的package包/类
@Test
public void equals() {
final Investment i = mock();
final InvestmentDescriptor d = new InvestmentDescriptor(i);
final RecommendedInvestment r = new RecommendedInvestment(d);
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(r).isNotEqualTo(null);
softly.assertThat(r).isNotEqualTo(UUID.randomUUID().toString());
softly.assertThat(r).isEqualTo(r);
});
final RecommendedInvestment r2 = new RecommendedInvestment(d);
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(r).isEqualTo(r2);
softly.assertThat(r2).isEqualTo(r);
});
final RecommendedInvestment r3 = new RecommendedInvestment(new InvestmentDescriptor(mock()));
Assertions.assertThat(r).isNotEqualTo(r3);
}
示例10: testAliasWithIgnore
import org.assertj.core.api.SoftAssertions; //导入依赖的package包/类
@Test
public void testAliasWithIgnore() {
SqlTable table = SqlTable.of("foo");
SqlColumn<Integer> column = table.column("id", JDBCType.INTEGER);
IsEqualTo<Integer> condition = IsEqualTo.of(() -> 3);
SqlCriterion<Integer> criterion = SqlCriterion.withColumn(column)
.withCondition(condition)
.build();
AtomicInteger sequence = new AtomicInteger(1);
FragmentAndParameters fp = CriterionRenderer.withCriterion(criterion)
.withSequence(sequence)
.withRenderingStrategy(RenderingStrategy.MYBATIS3)
.withTableAliasCalculator(TableAliasCalculator.empty())
.build()
.render();
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(fp.fragment()).isEqualTo("id = #{parameters.p1,jdbcType=INTEGER}");
softly.assertThat(fp.parameters().size()).isEqualTo(1);
});
}
示例11: equals
import org.assertj.core.api.SoftAssertions; //导入依赖的package包/类
@Test
public void equals() {
final Investment i = mock(BigDecimal.TEN);
final InvestmentDescriptor id = new InvestmentDescriptor(i);
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(id).isNotEqualTo(null);
softly.assertThat(id).isNotEqualTo(UUID.randomUUID().toString());
softly.assertThat(id).isEqualTo(id);
});
final InvestmentDescriptor id2 = new InvestmentDescriptor(i);
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(id).isEqualTo(id2);
softly.assertThat(id2).isEqualTo(id);
});
final InvestmentDescriptor id3 = new InvestmentDescriptor(mock(BigDecimal.ONE));
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(id).isNotEqualTo(id3);
});
}
示例12: assertFullyPopulated
import org.assertj.core.api.SoftAssertions; //导入依赖的package包/类
private void assertFullyPopulated(SoftAssertions assertions, Person person, String breadcrumb, int level) {
logger.trace("[{}] Checking {}", level, breadcrumb);
assertions.assertThat(person).as(breadcrumb + " at level " + level).isNotNull();
if (person == null) {
return;
}
assertions.assertThat(person.getAnnualSalary()).as(breadcrumb + ".annualSalary at level " + level).isNotNull();
assertions.assertThat(person.getBirthday()).as(breadcrumb + ".birthday at level " + level).isNotNull();
assertions.assertThat(person.getName()).as(breadcrumb + ".name at level " + level).isNotNull();
assertions.assertThat(person.getPreferredColor()).as(breadcrumb + ".preferredColor at level " + level).isNotNull();
assertions.assertThat(person.getAlwaysNullValue()).as(breadcrumb + ".awaysNullValue at level " + level).isNull();
assertions.assertThat(person.getSingleValue()).as(breadcrumb + ".singleValue at level " + level).isSameAs(SingleValueEnum.SINGLE_VALUE);
if (level > 0) {
assertFullyPopulated(assertions, person.getManager(), breadcrumb + ".manager", level - 1);
String teamProperty = breadcrumb + ".team at level " + level;
assertions.assertThat(person.getTeam()).as(teamProperty).isNotNull();
if (person.getTeam() != null) {
for (Person teamMember : person.getTeam()) {
assertFullyPopulated(assertions, teamMember, teamProperty, level - 1);
}
}
}
}
示例13: defaultProperties
import org.assertj.core.api.SoftAssertions; //导入依赖的package包/类
@Test
public void defaultProperties() {
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(Settings.INSTANCE.get("user.dir", "")).isNotEqualTo("");
softly.assertThat(Settings.INSTANCE.get(UUID.randomUUID().toString(), ""))
.isEqualTo("");
softly.assertThat(Settings.INSTANCE.isDebugEventStorageEnabled()).isFalse();
softly.assertThat(Settings.INSTANCE.getTokenRefreshPeriod())
.matches(new SettingsTest.TemporalPredicate(60));
softly.assertThat(Settings.INSTANCE.getRemoteResourceRefreshInterval())
.matches(new SettingsTest.TemporalPredicate(5 * 60));
softly.assertThat(Settings.INSTANCE.getCaptchaDelay())
.matches(new SettingsTest.TemporalPredicate(0));
Stream.of(Rating.values()).forEach(r -> {
softly.assertThat(Settings.INSTANCE.getCaptchaDelay(r))
.as(r.toString())
.matches(new SettingsTest.TemporalPredicate(0));
});
softly.assertThat(Settings.INSTANCE.getDefaultDryRunBalance()).isEqualTo(-1);
softly.assertThat(Settings.INSTANCE.getSocketTimeout())
.matches(new SettingsTest.TemporalPredicate(60));
softly.assertThat(Settings.INSTANCE.getConnectionTimeout())
.matches(new SettingsTest.TemporalPredicate(60));
softly.assertThat(Settings.INSTANCE.getDefaultApiPageSize()).isEqualTo(100);
});
}
示例14: windows
import org.assertj.core.api.SoftAssertions; //导入依赖的package包/类
@Test
public void windows() throws IOException {
final File optionsFile = getTempFile().getAbsoluteFile();
final File root = optionsFile.getParentFile();
final CommandLinePart cli = getCommandLine();
final Function<CommandLinePart, File> generator =
RunScriptGenerator.forWindows(root, optionsFile);
final String result = new String(Files.readAllBytes(generator.apply(cli).toPath()));
common(cli, result);
Assertions.assertThat(result)
.as("Missing executable file call.")
.contains(root + "\\robozonky.bat @" + optionsFile.getAbsolutePath());
// assert all environment variables present
SoftAssertions.assertSoftly(softly -> cli.getEnvironmentVariables().forEach((var, value) -> {
final String arg = var + "=" + value;
softly.assertThat(result).as("Missing env var.").contains(arg);
}));
Assertions.assertThat(result).contains("\r\n");
}
示例15: testTypeHandlerAndAlias
import org.assertj.core.api.SoftAssertions; //导入依赖的package包/类
@Test
public void testTypeHandlerAndAlias() {
SqlTable table = SqlTable.of("foo");
SqlColumn<Integer> column = table.column("id", JDBCType.INTEGER, "foo.Bar");
IsEqualTo<Integer> condition = IsEqualTo.of(() -> 3);
SqlCriterion<Integer> criterion = SqlCriterion.withColumn(column)
.withCondition(condition)
.build();
AtomicInteger sequence = new AtomicInteger(1);
Map<SqlTable, String> tableAliases = new HashMap<>();
tableAliases.put(table, "a");
FragmentAndParameters fp = CriterionRenderer.withCriterion(criterion)
.withSequence(sequence)
.withRenderingStrategy(RenderingStrategy.MYBATIS3)
.withTableAliasCalculator(TableAliasCalculator.of(tableAliases))
.build()
.render();
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(fp.fragment()).isEqualTo("a.id = #{parameters.p1,jdbcType=INTEGER,typeHandler=foo.Bar}");
softly.assertThat(fp.parameters().size()).isEqualTo(1);
});
}