### Question:
Database implements DatabaseDistribution, QueryProvider { @Override public ListenerPromise<ConnectionStatus> onConnect() { return FutureListenerPromise.whenListener(new Consumer<FutureListenerPromise<ConnectionStatus>>() { @Override public void accept(FutureListenerPromise<ConnectionStatus> promise) { new QueryConnectionStatus(Database.this, getDatabasePath()) .with(promise) .execute(); } }); } Database(); @Override ListenerPromise<ConnectionStatus> onConnect(); @Override DatabaseDistribution inReference(String databasePath); @Override Promise<Void> setValue(final Object value); @Override @SuppressWarnings("unchecked") Promise<E> readValue(final Class<T> dataType); @Override @SuppressWarnings("unchecked") ListenerPromise<R> onDataChange(final Class<T> dataType); @Override ListenerPromise<R> onChildChange(final Class<T> dataType, final ChildEventType... eventsType); @Override @SuppressWarnings("unchecked") DatabaseDistribution filter(FilterType filterType, V... filterArguments); @Override DatabaseDistribution orderBy(OrderByMode orderByMode, String argument); @Override DatabaseDistribution orderBy(OrderByMode orderByMode); @Override DatabaseDistribution push(); @Override Promise<Void> removeValue(); @Override Promise<Void> updateChildren(final Map<String, Object> data); @Override @SuppressWarnings("unchecked") Promise<Void> transaction(final Class<T> dataType, final Function<R, R> transaction); @Override void setPersistenceEnabled(boolean enabled); @Override void keepSynced(boolean synced); @Override String getReferencePath(); @Override Array<Filter> getFilters(); @Override OrderByClause getOrderByClause(); @Override void terminateOperation();  }### Answer:
@Test public void onConnect() throws Exception { PowerMockito.mockStatic(QueryConnectionStatus.class); Database database = new Database(); QueryConnectionStatus query = Mockito.spy(new QueryConnectionStatus(database, "/test")); PowerMockito.whenNew(QueryConnectionStatus.class).withAnyArguments().thenReturn(query); when(query.withArgs(Mockito.any())).thenReturn(query); database.onConnect().subscribe(); PowerMockito.verifyNew(QueryConnectionStatus.class); }