OneCollectorChannelListener extends AbstractChannelListener { @Override public void onGroupAdded(@NonNull String groupName, Channel.GroupListener groupListener, long batchTimeInterval) { if (isOneCollectorGroup(groupName)) { return; } String oneCollectorGroupName = getOneCollectorGroupName(groupName); mChannel.addGroup(oneCollectorGroupName, ONE_COLLECTOR_TRIGGER_COUNT, batchTimeInterval, ONE_COLLECTOR_TRIGGER_MAX_PARALLEL_REQUESTS, mIngestion, groupListener); } OneCollectorChannelListener(@NonNull Channel channel, @NonNull LogSerializer logSerializer, @NonNull HttpClient httpClient, @NonNull UUID installId); @VisibleForTesting  OneCollectorChannelListener(@NonNull OneCollectorIngestion ingestion, @NonNull Channel channel, @NonNull LogSerializer logSerializer, @NonNull UUID installId); void setLogUrl(@NonNull String logUrl); @Override void onGroupAdded(@NonNull String groupName, Channel.GroupListener groupListener, long batchTimeInterval); @Override void onGroupRemoved(@NonNull String groupName); @Override void onPreparedLog(@NonNull Log log, @NonNull String groupName, int flags); @Override boolean shouldFilter(@NonNull Log log); @Override void onClear(@NonNull String groupName); @Override void onPaused(@NonNull String groupName, String targetToken); @Override void onResumed(@NonNull String groupName, String targetToken); @Override void onGloballyEnabled(boolean isEnabled);  }
@Test public void addCorrespondingGroup() { Channel channel = mock(Channel.class); OneCollectorChannelListener listener = new OneCollectorChannelListener(channel, mock(LogSerializer.class), createHttpClient(mock(Context.class)), UUID.randomUUID()); long batchTimeInterval = 3000; Channel.GroupListener groupListener = mock(Channel.GroupListener.class); listener.onGroupAdded(TEST_GROUP, groupListener, batchTimeInterval); verify(channel).addGroup(eq(TEST_GROUP + ONE_COLLECTOR_GROUP_NAME_SUFFIX), eq(ONE_COLLECTOR_TRIGGER_COUNT), eq(batchTimeInterval), eq(ONE_COLLECTOR_TRIGGER_MAX_PARALLEL_REQUESTS), argThat(new ArgumentMatcher<Ingestion>() { @Override public boolean matches(Object argument) { return argument instanceof OneCollectorIngestion; } }), same(groupListener)); listener.onGroupAdded(TEST_GROUP + ONE_COLLECTOR_GROUP_NAME_SUFFIX, groupListener, batchTimeInterval); verifyNoMoreInteractions(channel); }