本文整理汇总了Java中org.assertj.core.api.Assertions类的典型用法代码示例。如果您正苦于以下问题:Java Assertions类的具体用法?Java Assertions怎么用?Java Assertions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Assertions类属于org.assertj.core.api包,在下文中一共展示了Assertions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testConstructorFromByteArray
import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void testConstructorFromByteArray() {
final RowKey rowKey = new RowKey(buildRowKeyArray());
assertEquals(STAT_TYPE_ID, rowKey.getTypeId());
Assertions.assertThat(ROLL_UP_BIT_MASK).isEqualTo(rowKey.getRollUpBitMask());
Assertions.assertThat(PARTIAL_TIMESTAMP).isEqualTo(rowKey.getPartialTimestamp());
final List<RowKeyTagValue> tagValuePairs = rowKey.getTagValuePairs();
assertEquals(3, tagValuePairs.size());
assertEquals(TAG_2, tagValuePairs.get(0).getTag());
assertEquals(VALUE_2, tagValuePairs.get(0).getValue());
assertEquals(TAG_1, tagValuePairs.get(1).getTag());
assertEquals(VALUE_1, tagValuePairs.get(1).getValue());
assertEquals(TAG_3, tagValuePairs.get(2).getTag());
assertEquals(VALUE_3, tagValuePairs.get(2).getValue());
}
示例2: call
import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void call() throws Exception {
// given
HelloWorldWork work1 = new HelloWorldWork("work1", WorkStatus.COMPLETED);
HelloWorldWork work2 = new HelloWorldWork("work2", WorkStatus.FAILED);
ParallelFlowExecutor parallelFlowExecutor = new ParallelFlowExecutor();
// when
List<WorkReport> workReports = parallelFlowExecutor.executeInParallel(Arrays.asList(work1, work2));
// then
Assertions.assertThat(workReports).hasSize(2);
Assertions.assertThat(work1.isExecuted()).isTrue();
Assertions.assertThat(work2.isExecuted()).isTrue();
}
示例3: deleteAsyncCollection
import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void deleteAsyncCollection() throws Exception {
TestLongEntity[] entities = fixture.get(3);
ofy().save().entities(entities).now();
List<TestLongEntity> listBeforeDelete = ofy().load().type(TestLongEntity.class).list();
Assertions.assertThat(listBeforeDelete).hasSize(3);
repository.deleteAsync(
Arrays.asList(entities[0], entities[1])
).run();
List<TestLongEntity> listAfterDelete = ofy().load().type(TestLongEntity.class).list();
Assertions.assertThat(listAfterDelete).hasSize(1);
Assertions.assertThat(listAfterDelete).containsExactly(entities[2]);
}
示例4: validateIntegration
import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Then("^validate record is present in SF \"([^\"]*)\"")
public void validateIntegration(String record) throws TwitterException {
Assertions.assertThat(getSalesforceContact(salesforce, accountsDirectory.getAccount(RestConstants.getInstance().getSYNDESIS_TALKY_ACCOUNT())
.get().getProperty("screenName")).isPresent()).isEqualTo(false);
log.info("Waiting until a contact appears in salesforce...");
final long start = System.currentTimeMillis();
final boolean contactCreated = TestUtils.waitForEvent(contact -> contact.isPresent(),
() -> getSalesforceContact(salesforce, accountsDirectory.getAccount(RestConstants.getInstance().getSYNDESIS_TALKY_ACCOUNT()).get().getProperty("screenName")),
TimeUnit.MINUTES,
2,
TimeUnit.SECONDS,
5);
Assertions.assertThat(contactCreated).as("Contact has appeard in salesforce").isEqualTo(true);
log.info("Contact appeared in salesforce. It took {}s to create contact.", TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - start));
final Contact createdContact = getSalesforceContact(salesforce, accountsDirectory.getAccount(RestConstants.getInstance().getSYNDESIS_TALKY_ACCOUNT()).get().getProperty("screenName")).get();
Assertions.assertThat(createdContact.getDescription()).startsWith(record);
Assertions.assertThat(createdContact.getFirstName()).isNotEmpty();
Assertions.assertThat(createdContact.getLastname()).isNotEmpty();
log.info("Twitter to salesforce integration test finished.");
}
示例5: visit_shouldVisitAllItems
import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void visit_shouldVisitAllItems() throws Exception {
//given
List<Object> list = new ArrayList<>();
OutputContainer.CellVisitor visitor = new OutputContainer.CellVisitor() {
@Override
public void visit(Object item) {
list.add(item);
}
};
container.addItem(Integer.MIN_VALUE, 0);
container.addItem(Boolean.TRUE, 1);
//when
container.visit(visitor);
//then
Assertions.assertThat(list).isNotEmpty();
Assertions.assertThat(list.size()).isEqualTo(2);
Assertions.assertThat(list.get(1)).isEqualTo(true);
}
示例6: rxSingleIntFallback
import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void rxSingleIntFallback() {
server.enqueue(new MockResponse().setResponseCode(500));
TestInterface api = target();
Single<Integer> single = api.intSingle();
assertThat(single).isNotNull();
assertThat(server.getRequestCount()).isEqualTo(0);
TestSubscriber<Integer> testSubscriber = new TestSubscriber<Integer>();
single.subscribe(testSubscriber);
testSubscriber.awaitTerminalEvent();
Assertions.assertThat(testSubscriber.getOnNextEvents().get(0)).isEqualTo(new Integer(0));
}
示例7: discoveryClientWithWrongUrlShouldUseServiceInstanceInfo
import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void discoveryClientWithWrongUrlShouldUseServiceInstanceInfo() {
String serviceId = "serviceId";
URI uri = URI.create("http://service-instance-uri");
EurekaServiceInstance serviceInstanceMock = Mockito.mock(EurekaServiceInstance.class);
Mockito.when(serviceInstanceMock.getUri()).thenReturn(uri);
Mockito.when(serviceInstanceMock.getServiceId()).thenReturn(serviceId);
Mockito.when(discoveryClient.getServices()).thenReturn(Lists.newArrayList("serviceId"));
Mockito.when(discoveryClient.getInstances("serviceId")).thenReturn(Lists.newArrayList(serviceInstanceMock));
Mockito.when(serviceInstanceMock.getMetadata())
.thenReturn(Maps.newHashMap(CereebroMetadata.KEY_SNITCH_URI, ""));
DiscoveryClientSnitchRegistry registry = new DiscoveryClientSnitchRegistry(discoveryClient, objectMapper);
Assertions.assertThat(registry.getAll()).hasSize(1);
Snitch snitch = registry.getAll().get(0);
Assertions.assertThat(snitch).isInstanceOf(ServiceInstanceSnitch.class);
Assertions.assertThat(snitch.getUri()).isEqualTo(uri);
Component component = Component.of(serviceId, ComponentType.HTTP_APPLICATION);
SystemFragment expected = SystemFragment.of(ComponentRelationships.of(component, new HashSet<>()));
Assertions.assertThat(snitch.snitch()).isEqualTo(expected);
}
示例8: assertLogsContainsOrNot
import org.assertj.core.api.Assertions; //导入依赖的package包/类
public static void assertLogsContainsOrNot(Collection<Pod> pods, String[] shouldFinds, String[] shouldNotFinds) throws IOException {
Pattern patterns[] = new Pattern[shouldFinds.length + shouldNotFinds.length];
for (int i = 0; i < shouldFinds.length; ++i) {
patterns[i] = Pattern.compile(shouldFinds[i]);
}
for (int i = 0; i < shouldNotFinds.length; ++i) {
patterns[shouldFinds.length + i] = Pattern.compile(shouldNotFinds[i]);
}
boolean found[] = findPatternsInLogs(pods, patterns);
for (int i = 0; i < patterns.length; ++i) {
if (i < shouldFinds.length) {
Assertions.assertThat(found[i]).as("Didn't find pattern '" + patterns[i].toString() + "' in pod " + formatPodLists(pods) + "logs").isEqualTo(true);
} else {
Assertions.assertThat(found[i]).as("Found pattern '" + patterns[i].toString() + "' in pod " + formatPodLists(pods) + "logs").isEqualTo(false);
}
}
}
示例9: should_not_return_merged_test_selections_if_test_selection_has_different_class
import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void should_not_return_merged_test_selections_if_test_selection_has_different_class() {
// given
final TestSelection testSelectionNew = new TestSelection(TestExecutionPlannerLoaderTest.class.getName(), "new");
final TestSelection testSelectionChanged =
new TestSelection(TestSelectorTest.class.getName(), "changed");
final Set<Class<?>> classes =
new LinkedHashSet<>(asList(TestExecutionPlannerLoaderTest.class, TestSelectorTest.class));
TestExecutionPlannerLoader testExecutionPlannerLoader = prepareLoader(classes);
final DummyTestSelector testSelector =
new DummyTestSelector(ConfigurationLoader.load(tmpFolder.getRoot()), testExecutionPlannerLoader,
new File("."));
// when
final Collection<TestSelection> testSelections =
testSelector.filterMergeAndOrderTestSelection(asList(testSelectionNew, testSelectionChanged),
asList("new", "changed"));
// then
Assertions.assertThat(testSelections)
.hasSize(2)
.flatExtracting("types").containsExactly("new", "changed");
}
示例10: handleMessage_secondSentMessageHasSessionId
import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void handleMessage_secondSentMessageHasSessionId() throws Exception {
//given
String expectedSessionId = message.getHeader().getSession();
//when
commMsgHandler.handle(message);
//then
Assertions.assertThat(kernel.getPublishedMessages()).isNotEmpty();
Message publishMessage = kernel.getPublishedMessages().get(1);
Assertions.assertThat(publishMessage.getHeader().getSession()).isEqualTo(expectedSessionId);
}
示例11: create
import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void create() {
Component a = Component.of("a", "a");
Component b = Component.of("b", "b");
Component c = Component.of("c", "c");
ComponentRelationships aRels = ComponentRelationships.builder().component(a).addDependency(Dependency.on(b))
.build();
ComponentRelationships bRels = ComponentRelationships.builder().component(b).addDependency(Dependency.on(c))
.build();
ComponentRelationships cRels = ComponentRelationships.builder().component(c).build();
LinkedHashSet<ComponentRelationships> set = new LinkedHashSet<>();
set.add(aRels);
set.add(bRels);
set.add(cRels);
System system = System.of("sys", set);
DependencyWheel result = DependencyWheel.of(system);
// @formatter:off
DependencyWheel expected = DependencyWheel.builder()
.name("a")
.matrixLine(Arrays.asList(0, 1, 0))
.name("b")
.matrixLine(Arrays.asList(0, 0, 1))
.name("c")
.matrixLine(Arrays.asList(0, 0, 0))
.build();
// @formatter:on
Assertions.assertThat(result).isEqualTo(expected);
}
示例12: setBoundsWithTwoDoubleParams_hasBoundsValuesAndHasAutoRangeIsFalse
import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void setBoundsWithTwoDoubleParams_hasBoundsValuesAndHasAutoRangeIsFalse() {
//when
YAxis yAxis = new YAxis();
yAxis.setBound(1, 2);
//then
Assertions.assertThat(yAxis.getAutoRange()).isEqualTo(false);
Assertions.assertThat(yAxis.getLowerBound()).isEqualTo(1);
Assertions.assertThat(yAxis.getUpperBound()).isEqualTo(2);
}
示例13: testSchemeAssets
import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void testSchemeAssets() throws Exception {
String uri = "assets://folder/1.png";
Scheme result = Scheme.ofUri(uri);
Scheme expected = Scheme.ASSETS;
Assertions.assertThat(result).isEqualTo(expected);
}
示例14: serializeStickyOfTreeMap_resultJsonHasSticky
import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void serializeStickyOfTreeMap_resultJsonHasSticky() throws IOException {
//when
treeMap.setSticky(true);
treeMapSerializer.serialize(treeMap, jgen, new DefaultSerializerProvider.Impl());
jgen.flush();
//then
JsonNode actualObj = mapper.readTree(sw.toString());
Assertions.assertThat(actualObj.has("sticky")).isTrue();
Assertions.assertThat(actualObj.get("sticky").asBoolean()).isTrue();
}
示例15: createPointsByEmptyConstructor_hasSizeAndShapeIsNotNull
import org.assertj.core.api.Assertions; //导入依赖的package包/类
@Test
public void createPointsByEmptyConstructor_hasSizeAndShapeIsNotNull() {
//when
Points points = new Points();
//then
Assertions.assertThat(points.getSize()).isNotNull();
Assertions.assertThat(points.getShape()).isNotNull();
}