@Test public void handleMessage_removeInfo() { final Message message = new Message(); message.what = WHAT_REMOVE_INFO; message.arg1 = 1; freeToDBIdList.add(1); executor.handleMessage(message); verify(agent).removeInfo(eq(1)); assertThat(freeToDBIdList).isEmpty(); }
@Test public void handleMessage_removeFreeBunchId() { final Message message = new Message(); message.what = WHAT_REMOVE_FREE_BUNCH_ID; message.obj = idList; freeToDBIdList.addAll(idList); executor.handleMessage(message); assertThat(freeToDBIdList).isEmpty(); }
@Test public void handleMessage_removeFreeId() { final Message message = new Message(); message.what = WHAT_REMOVE_FREE_ID; message.arg1 = 1; freeToDBIdList.add(1); executor.handleMessage(message); assertThat(freeToDBIdList).isEmpty(); }
@Test public void inspectForConflict_sameTask_isFinishing() { final DownloadTask task = mock(DownloadTask.class); final DownloadCall call = mock(DownloadCall.class); when(call.equalsTask(task)).thenReturn(true); when(call.isFinishing()).thenReturn(true); final Collection<DownloadCall> calls = new ArrayList<>(); final Collection<DownloadTask> sameTaskList = new ArrayList<>(); final Collection<DownloadTask> fileBusyList = new ArrayList<>(); calls.add(call); assertThat(dispatcher.inspectForConflict(task, calls, sameTaskList, fileBusyList)) .isFalse(); assertThat(fileBusyList).isEmpty(); assertThat(sameTaskList).isEmpty(); assertThat(finishingCalls).hasSize(1); }
@Test public void testDataRenderedCallbacksAreNotTriggered() { final ChangeSetCompleteCallback changeSetCompleteCallback = mock(ChangeSetCompleteCallback.class); final ComponentsLogger componentsLogger = mock(ComponentsLogger.class); final ComponentContext componentContext = new ComponentContext(RuntimeEnvironment.application, "", componentsLogger); final RecyclerBinder recyclerBinder = new RecyclerBinder.Builder().rangeRatio(RANGE_RATIO).build(componentContext); for (int i = 0; i < 40; i++) { recyclerBinder.notifyChangeSetComplete(true, changeSetCompleteCallback); } final RecyclerView recyclerView = mock(LithoRecylerView.class); when(recyclerView.hasPendingAdapterUpdates()).thenReturn(true); when(recyclerView.isAttachedToWindow()).thenReturn(true); when(recyclerView.getWindowVisibility()).thenReturn(View.VISIBLE); when(recyclerView.getAlpha()).thenReturn(1f); when(recyclerView.getVisibility()).thenReturn(View.VISIBLE); when(recyclerView.getGlobalVisibleRect(any(Rect.class))).thenReturn(true); recyclerBinder.mount(recyclerView); recyclerBinder.notifyChangeSetComplete(true, changeSetCompleteCallback); verify(componentsLogger).emitMessage(eq(ComponentsLogger.LogLevel.ERROR), anyString()); assertThat(recyclerBinder.mDataRenderedCallbacks).isEmpty(); }
@Test public void inspectForConflict_sameTask() throws IOException { mockOkDownload(); final CallbackDispatcher callbackDispatcher = OkDownload.with().callbackDispatcher(); final DownloadListener listener = callbackDispatcher.dispatch(); DownloadTask task = mock(DownloadTask.class); final Collection<DownloadCall> calls = new ArrayList<>(); final Collection<DownloadTask> sameTaskList = new ArrayList<>(); final Collection<DownloadTask> fileBusyList = new ArrayList<>(); final DownloadCall call = mock(DownloadCall.class); when(call.equalsTask(task)).thenReturn(true); calls.add(call); assertThat(dispatcher.inspectForConflict(task, calls, sameTaskList, fileBusyList)).isTrue(); assertThat(sameTaskList).containsExactly(task); assertThat(fileBusyList).isEmpty(); verify(listener, never()).taskEnd(eq(task), any(EndCause.class), nullable(Exception.class)); }
@Test public void inspectForConflict_fileBusy() throws IOException { mockOkDownload(); final CallbackDispatcher callbackDispatcher = OkDownload.with().callbackDispatcher(); final DownloadListener listener = callbackDispatcher.dispatch(); DownloadTask task = mock(DownloadTask.class); final Collection<DownloadCall> calls = new ArrayList<>(); final Collection<DownloadTask> sameTaskList = new ArrayList<>(); final Collection<DownloadTask> fileBusyList = new ArrayList<>(); final DownloadCall call = mock(DownloadCall.class); final File file = mock(File.class); when(task.getFile()).thenReturn(file); when(call.getFile()).thenReturn(file); calls.add(call); assertThat(dispatcher.inspectForConflict(task, calls, sameTaskList, fileBusyList)).isTrue(); assertThat(sameTaskList).isEmpty(); assertThat(fileBusyList).containsExactly(task); verify(listener, never()).taskEnd(eq(task), any(EndCause.class), nullable(Exception.class)); }
@Test public void testDataRenderedCallbacksIsEmptyWithInsertAfterMount() { final RecyclerView recyclerView = mock(RecyclerView.class); final ChangeSetCompleteCallback changeSetCompleteCallback = mock(ChangeSetCompleteCallback.class); final RecyclerBinder recyclerBinder = new RecyclerBinder.Builder().rangeRatio(RANGE_RATIO).build(mComponentContext); // Mount view before insertions recyclerBinder.mount(recyclerView); final ArrayList<RenderInfo> renderInfos = new ArrayList<>(); for (int i = 0; i < 5; i++) { final Component component = TestDrawableComponent.create(mComponentContext).widthPx(100).heightPx(100).build(); renderInfos.add(ComponentRenderInfo.create().component(component).build()); } recyclerBinder.insertRangeAt(0, renderInfos); recyclerBinder.notifyChangeSetComplete(true, changeSetCompleteCallback); assertThat(recyclerBinder.mDataRenderedCallbacks).isEmpty(); }
@Test public void testDataRenderedCallbacksIsEmptyWithAsyncInsertAfterMount() { final RecyclerView recyclerView = mock(RecyclerView.class); final ChangeSetCompleteCallback changeSetCompleteCallback = mock(ChangeSetCompleteCallback.class); final RecyclerBinder recyclerBinder = new RecyclerBinder.Builder().rangeRatio(RANGE_RATIO).build(mComponentContext); // Mount view before insertions recyclerBinder.mount(recyclerView); final ArrayList<RenderInfo> renderInfos = new ArrayList<>(); for (int i = 0; i < 5; i++) { final Component component = TestDrawableComponent.create(mComponentContext).widthPx(100).heightPx(100).build(); renderInfos.add(ComponentRenderInfo.create().component(component).build()); } recyclerBinder.insertRangeAtAsync(0, renderInfos); recyclerBinder.notifyChangeSetCompleteAsync(true, changeSetCompleteCallback); recyclerBinder.measure( new Size(), makeSizeSpec(1000, EXACTLY), makeSizeSpec(1000, EXACTLY), null); assertThat(recyclerBinder.mDataRenderedCallbacks).isEmpty(); }
String testElt5 = null; assertThat(set).isEmpty(); assertThat(set).isEmpty(); assertThat(set) .doesNotContain(testElt1) .isEmpty(); assertThat(checkIterator(set)).isTrue(); .doesNotContain(testElt3) .doesNotContain(testElt4) .isEmpty(); assertThat(checkIterator(set)).isTrue(); assertThat(set).doesNotContain(testElt2); assertThat(set).doesNotContain(testElt3); assertThat(set).isEmpty(); assertThat(set).isEmpty(); assertThat(checkIterator(set)).isTrue();
public void assertNoEvents() { assertThat(events).isEmpty(); }
@Test public void defaultDefaultValue() { assertThat(rxPreferences.getBoolean("foo1").defaultValue()).isFalse(); assertThat(rxPreferences.getFloat("foo3").defaultValue()).isZero(); assertThat(rxPreferences.getInteger("foo4").defaultValue()).isZero(); assertThat(rxPreferences.getLong("foo5").defaultValue()).isZero(); assertThat(rxPreferences.getString("foo6").defaultValue()).isEqualTo(""); assertThat(rxPreferences.getStringSet("foo7").defaultValue()).isEmpty(); }
assertThat(pool.trash).isEmpty(); assertThat(connection1.inFlight.get()).isEqualTo(50); assertThat(connection2.inFlight.get()).isEqualTo(51);
assertThat(pool.trash).isEmpty(); assertThat(connection1.isClosed()).isTrue();
@Test(groups = "short", dataProvider = "newKeyspaceName") public void should_notify_of_keyspace_drop(String keyspace) throws InterruptedException { execute(CREATE_KEYSPACE, keyspace); for (SchemaChangeListener listener : listeners) { ArgumentCaptor<KeyspaceMetadata> added = ArgumentCaptor.forClass(KeyspaceMetadata.class); verify(listener, timeout(NOTIF_TIMEOUT_MS).times(1)).onKeyspaceAdded(added.capture()); assertThat(added.getValue()).hasName(handleId(keyspace)); } for (Metadata m : metadatas()) assertThat(m.getReplicas(keyspace, Bytes.fromHexString("0xCAFEBABE"))).isNotEmpty(); execute(CREATE_TABLE, keyspace); // to test table drop notifications execute(DROP_KEYSPACE, keyspace); for (SchemaChangeListener listener : listeners) { ArgumentCaptor<TableMetadata> table = ArgumentCaptor.forClass(TableMetadata.class); verify(listener, timeout(NOTIF_TIMEOUT_MS).times(1)).onTableRemoved(table.capture()); assertThat(table.getValue()).hasName("table1").isInKeyspace(handleId(keyspace)); ArgumentCaptor<KeyspaceMetadata> ks = ArgumentCaptor.forClass(KeyspaceMetadata.class); verify(listener, timeout(NOTIF_TIMEOUT_MS).times(1)).onKeyspaceRemoved(ks.capture()); assertThat(ks.getValue()).hasName(handleId(keyspace)); } for (Metadata m : metadatas()) { assertThat(m.getKeyspace(keyspace)).isNull(); assertThat(m.getReplicas(keyspace, Bytes.fromHexString("0xCAFEBABE"))).isEmpty(); } }
logs.disableFor(Session.class); assertThat(session.getState().getConnectedHosts()).isEmpty(); InetSocketAddress host = ccm().addressOfNode(1); assertThat(logs.get())
@After public void tearDown() { discovery.close(); AtomicBoolean completed = new AtomicBoolean(); vertx.close((v) -> completed.set(true)); await().untilAtomic(completed, is(true)); assertThat(discovery.bindings()).isEmpty(); }
@Test public void itResetsGlobalContextAfterRender() { Jinjava jinjava = new Jinjava(); Context globalContext = jinjava.getGlobalContext(); RenderResult result = jinjava.renderForResult("{{ foo + 1 }}", ImmutableMap.of("foo", 1)); assertThat(result.getOutput()).isEqualTo("2"); assertThat(result.getContext().getResolvedExpressions()).containsOnly("foo + 1"); assertThat(result.getContext().getResolvedValues()).containsOnly("foo"); assertThat(globalContext.getResolvedExpressions()).isEmpty(); assertThat(globalContext.getResolvedValues()).isEmpty(); } }
@Test public void testSearchArtifactsByKeyExact() throws Exception { createArtifactWithData(); Collection<ArtifactMetadata> artifactsByProperty = repository.searchArtifacts( "url", TEST_URL, TEST_REPO_ID, true ); assertThat( artifactsByProperty ).isNotNull().isNotEmpty(); artifactsByProperty = repository.searchArtifacts( "org.name", "pache", TEST_REPO_ID, true ); assertThat( artifactsByProperty ).isNotNull().isEmpty(); }
@Test public void shouldNotDeleteFromUnchangedView() { // given SubscriptionName s1 = anySubscriptionName(); SubscriptionAssignmentView current = assignmentView().withAssignment(s1, "c1").build(); SubscriptionAssignmentView target = assignmentView().withAssignment(s1, "c1").build(); // when SubscriptionAssignmentView deletions = current.deletions(target); // then assertThat(deletions.getSubscriptions()).isEmpty(); }