本文整理了Java中org.assertj.core.api.AbstractListAssert.hasSameSizeAs()
方法的一些代码示例,展示了AbstractListAssert.hasSameSizeAs()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractListAssert.hasSameSizeAs()
方法的具体详情如下:
包路径:org.assertj.core.api.AbstractListAssert
类名称:AbstractListAssert
方法名:hasSameSizeAs
暂无
代码示例来源:origin: TNG/junit-dataprovider
private void assertThatResultContainsCorrectClassesExactlyInOrder(List<TestClass> result, Class<?>... expectedClasses) {
assertThat(result).hasSameSizeAs(expectedClasses);
for (int idx = 0; idx < expectedClasses.length; idx++) {
assertThat(result.get(idx).getJavaClass()).isEqualTo(expectedClasses[idx]);
assertThat(result.get(idx).getName()).isEqualTo(expectedClasses[idx].getName());
}
}
}
代码示例来源:origin: Nike-Inc/wingtips
private void verifyExpectedCapturedTracingStates(TracingState... expectedTracingStates) {
assertThat(capturedTracingStates).hasSize(expectedTracingStates.length);
assertThat(capturedTracingStates).containsExactly(expectedTracingStates);
assertThat(capturedThreadIds).hasSameSizeAs(capturedTracingStates);
long testThreadId = Thread.currentThread().getId();
assertThat(capturedThreadIds).doesNotContain(testThreadId);
}
代码示例来源: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: Nike-Inc/wingtips
@Test
public void invokeAll_no_timeout_passes_through_to_delegate_with_tracing_wrapped_tasks()
throws InterruptedException {
// given
List<Callable<Object>> origTasks = Arrays.asList(mock(Callable.class), mock(Callable.class));
List<Future<Object>> expectedResultMock = mock(List.class);
doReturn(expectedResultMock).when(executorServiceMock).invokeAll(any(Collection.class));
TracingState expectedTracingState = generateTracingStateOnCurrentThread();
// when
List<Future<Object>> result = instance.invokeAll(origTasks);
// then
assertThat(result).isSameAs(expectedResultMock);
verify(executorServiceMock).invokeAll(collectionCaptor.capture());
List<Callable<Object>> actualTasks = (List<Callable<Object>>) collectionCaptor.getValue();
assertThat(actualTasks).hasSameSizeAs(origTasks);
for (int i = 0; i < actualTasks.size(); i++) {
Callable<Object> actualTask = actualTasks.get(i);
Callable<Object> origTaskMock = origTasks.get(i);
verifyCallableWithTracingWrapper(actualTask, origTaskMock, expectedTracingState);
}
verifyNoMoreInteractions(executorServiceMock);
}
代码示例来源:origin: Nike-Inc/wingtips
@Test
public void invokeAny_no_timeout_passes_through_to_delegate_with_tracing_wrapped_tasks()
throws InterruptedException, ExecutionException {
// given
List<Callable<Object>> origTasks = Arrays.asList(mock(Callable.class), mock(Callable.class));
Object expectedResultMock = mock(Object.class);
doReturn(expectedResultMock).when(executorServiceMock).invokeAny(any(Collection.class));
TracingState expectedTracingState = generateTracingStateOnCurrentThread();
// when
Object result = instance.invokeAny(origTasks);
// then
assertThat(result).isSameAs(expectedResultMock);
verify(executorServiceMock).invokeAny(collectionCaptor.capture());
List<Callable<Object>> actualTasks = (List<Callable<Object>>) collectionCaptor.getValue();
assertThat(actualTasks).hasSameSizeAs(origTasks);
for (int i = 0; i < actualTasks.size(); i++) {
Callable<Object> actualTask = actualTasks.get(i);
Callable<Object> origTaskMock = origTasks.get(i);
verifyCallableWithTracingWrapper(actualTask, origTaskMock, expectedTracingState);
}
verifyNoMoreInteractions(executorServiceMock);
}
代码示例来源:origin: Nike-Inc/wingtips
@Test
public void invokeAll_with_timeout_passes_through_to_delegate_with_tracing_wrapped_tasks()
throws InterruptedException {
// given
List<Callable<Object>> origTasks = Arrays.asList(mock(Callable.class), mock(Callable.class));
List<Future<Object>> expectedResultMock = mock(List.class);
doReturn(expectedResultMock).when(executorServiceMock)
.invokeAll(any(Collection.class), anyLong(), any(TimeUnit.class));
long timeoutValue = 42;
TimeUnit timeoutTimeUnit = TimeUnit.MINUTES;
TracingState expectedTracingState = generateTracingStateOnCurrentThread();
// when
List<Future<Object>> result = instance.invokeAll(origTasks, timeoutValue, timeoutTimeUnit);
// then
assertThat(result).isSameAs(expectedResultMock);
verify(executorServiceMock).invokeAll(collectionCaptor.capture(), eq(timeoutValue), eq(timeoutTimeUnit));
List<Callable<Object>> actualTasks = (List<Callable<Object>>) collectionCaptor.getValue();
assertThat(actualTasks).hasSameSizeAs(origTasks);
for (int i = 0; i < actualTasks.size(); i++) {
Callable<Object> actualTask = actualTasks.get(i);
Callable<Object> origTaskMock = origTasks.get(i);
verifyCallableWithTracingWrapper(actualTask, origTaskMock, expectedTracingState);
}
verifyNoMoreInteractions(executorServiceMock);
}
代码示例来源:origin: Nike-Inc/wingtips
@Test
public void invokeAny_with_timeout_passes_through_to_delegate_with_tracing_wrapped_tasks()
throws InterruptedException, TimeoutException, ExecutionException {
// given
List<Callable<Object>> origTasks = Arrays.asList(mock(Callable.class), mock(Callable.class));
Object expectedResultMock = mock(Object.class);
doReturn(expectedResultMock).when(executorServiceMock)
.invokeAny(any(Collection.class), anyLong(), any(TimeUnit.class));
long timeoutValue = 42;
TimeUnit timeoutTimeUnit = TimeUnit.MINUTES;
TracingState expectedTracingState = generateTracingStateOnCurrentThread();
// when
Object result = instance.invokeAny(origTasks, timeoutValue, timeoutTimeUnit);
// then
assertThat(result).isSameAs(expectedResultMock);
verify(executorServiceMock).invokeAny(collectionCaptor.capture(), eq(timeoutValue), eq(timeoutTimeUnit));
List<Callable<Object>> actualTasks = (List<Callable<Object>>) collectionCaptor.getValue();
assertThat(actualTasks).hasSameSizeAs(origTasks);
for (int i = 0; i < actualTasks.size(); i++) {
Callable<Object> actualTask = actualTasks.get(i);
Callable<Object> origTaskMock = origTasks.get(i);
verifyCallableWithTracingWrapper(actualTask, origTaskMock, expectedTracingState);
}
verifyNoMoreInteractions(executorServiceMock);
}
代码示例来源:origin: Nike-Inc/wingtips
@Test
public void convertToCallableWithTracingList_works_as_expected() {
// given
List<Callable<Object>> origCallables = Arrays.asList(
mock(Callable.class),
null,
mock(Callable.class)
);
TracingState expectedTracingState = generateTracingStateOnCurrentThread();
// when
List<Callable<Object>> results = instance.convertToCallableWithTracingList(origCallables);
// then
assertThat(results).hasSameSizeAs(origCallables);
for (int i = 0; i < results.size(); i++) {
Callable<Object> actualTask = results.get(i);
Callable<Object> origTaskMock = origCallables.get(i);
if (origTaskMock == null) {
assertThat(actualTask).isNull();
}
else {
verifyCallableWithTracingWrapper(actualTask, origTaskMock, expectedTracingState);
}
}
}
代码示例来源:origin: FaustXVI/junit5-docker
@Test
@DisplayName("should remove the container's volumes")
public void shouldRemoveVolumes() {
defaultDockerClient.stopAndRemoveContainer(containerId);
assertThat(volumes()).hasSameSizeAs(existingVolumes);
}
代码示例来源:origin: dhleong/intellivim
/**
* To resolve multiple ambiguous imports during OptimizeImportsCommand,
* we need to be able to use ids from an old, cached Problems instance
* to find updated QuickFixDescriptors. This is a test of that
*/
public void testProblemsEquivalence() {
Project project = getProject();
Problems original = Problems.collectFrom(project, ProjectUtil.getPsiFile(project, filePath));
Problems updated = Problems.collectFrom(project, ProjectUtil.getPsiFile(project, filePath));
assertThat(updated)
.hasSize(2)
.hasSameSizeAs(original);
assertThat(updated.locateQuickFix(original.locateQuickFix("0.0"))).isNotNull();
assertSuccess(execute(new FixProblemCommand(project, filePath, "0.0")));
assertFileNowContains(FixProblemTest.IMPORT_STATEMENT);
final QuickFixDescriptor secondImportFix = original.locateQuickFix("1.0");
Problems afterFix = Problems.collectFrom(project, ProjectUtil.getPsiFile(project, filePath));
assertThat(afterFix).hasSize(1);
// first, we should be able to find it from contains()
assertThat(afterFix.get(0).getFixes())
.contains(secondImportFix);
// now, make sure locateQuickFix actually can
assertThat(afterFix.locateQuickFix(original.locateQuickFix("1.0"))).isNotNull();
}
内容来源于网络,如有侵权,请联系作者删除!