OneCollectorChannelListener extends AbstractChannelListener { @Override public void onPaused(@NonNull String groupName, String targetToken) { if (isOneCollectorGroup(groupName)) { return; } mChannel.pauseGroup(getOneCollectorGroupName(groupName), targetToken); } 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 pauseCorrespondingGroup() { Channel channel = mock(Channel.class); OneCollectorChannelListener listener = new OneCollectorChannelListener(channel, mock(LogSerializer.class), createHttpClient(mock(Context.class)), UUID.randomUUID()); listener.onPaused(TEST_GROUP, null); verify(channel).pauseGroup(TEST_GROUP + ONE_COLLECTOR_GROUP_NAME_SUFFIX, null); listener.onPaused(TEST_GROUP + ONE_COLLECTOR_GROUP_NAME_SUFFIX, null); verifyNoMoreInteractions(channel); listener.onPaused(TEST_GROUP, "token"); verify(channel).pauseGroup(TEST_GROUP + ONE_COLLECTOR_GROUP_NAME_SUFFIX, "token"); listener.onPaused(TEST_GROUP + ONE_COLLECTOR_GROUP_NAME_SUFFIX, null); verifyNoMoreInteractions(channel); }