### Question:
Proctor { @SuppressWarnings("UnusedDeclaration") @Nonnull public ProctorResult determineTestGroups( final TestType testType, final String identifier, @Nonnull final Map<String, Object> context, @Nonnull final Map<String, Integer> forceGroups) { final Identifiers identifiers = new Identifiers(testType, identifier); return determineTestGroups(identifiers, context, forceGroups); } @VisibleForTesting  Proctor(
            final TestMatrixArtifact matrix,
            final ProctorLoadResult loadResult,
            @Nonnull final Map<String, TestChooser<?>> testChoosers
    ); @Nonnull static Proctor construct(
            @Nonnull final TestMatrixArtifact matrix,
            final ProctorLoadResult loadResult,
            final FunctionMapper functionMapper
    ); @SuppressWarnings("UnusedDeclaration") // TODO Remove deprecated @Nonnull ProctorResult determineTestGroups(
            final TestType testType,
            final String identifier,
            @Nonnull final Map<String, Object> context,
            @Nonnull final Map<String, Integer> forceGroups); @Nonnull ProctorResult determineTestGroups(
            @Nonnull final Identifiers identifiers,
            @Nonnull final Map<String, Object> inputContext,
            @Nonnull final Map<String, Integer> forceGroups); @Nonnull ProctorResult determineTestGroups(
            @Nonnull final Identifiers identifiers,
            @Nonnull final Map<String, Object> inputContext,
            @Nonnull final Map<String, Integer> forceGroups,
            @Nonnull final Collection<String> testNameFilter
    ); Set<String> getTestNames(); ConsumableTestDefinition getTestDefinition(final String name); ProctorLoadResult getLoadResult(); void appendAllTests(final Writer sb); void appendTests(final Writer sb, final TestType type); void appendTestsNameFiltered(final Writer sb, final Collection<String> testNameFilter); void appendTests(final Writer sb, @Nonnull final Predicate<TestChooser<?>> shouldIncludeTest); void appendTestMatrix(final Writer writer); void appendTestMatrixFiltered(final Writer writer, final Collection<String> testNameFilter); static final Proctor EMPTY; }### Answer:
@Test public void testDetermineTestGroupsForRandomTestWithRandomEnabled() { final String testName = "example_tst"; final RandomTestChooser testChooser = mock(RandomTestChooser.class); final TestMatrixArtifact matrix = createTestMatrixWithOneRandomTest(testName); final Proctor proctor = new Proctor( matrix, null, Collections.singletonMap(testName, testChooser) ); final Identifiers identifiersWithRandom = new Identifiers(Collections.emptyMap(), true); final Identifiers identifiersWithoutRandom = new Identifiers(Collections.emptyMap(), false); final Map<String, Object> inputContext = Collections.emptyMap(); final TestBucket testBucket = TestBucket.builder().build(); final Allocation allocation = new Allocation(); final TestChooser.Result result = new TestChooser.Result( testBucket, allocation ); when(testChooser.choose(null, inputContext)).thenReturn(result); final ProctorResult proctorResultWithRandom = proctor.determineTestGroups( identifiersWithRandom, inputContext, Collections.emptyMap() ); final ProctorResult proctorResultWithoutRandom = proctor.determineTestGroups( identifiersWithoutRandom, inputContext, Collections.emptyMap() ); assertThat(proctorResultWithRandom.getBuckets()).isEqualTo(Collections.singletonMap(testName, result.getTestBucket())); assertThat(proctorResultWithRandom.getAllocations()).isEqualTo(Collections.singletonMap(testName, result.getAllocation())); assertThat(proctorResultWithoutRandom.getBuckets()).isEqualTo(Collections.emptyMap()); assertThat(proctorResultWithoutRandom.getAllocations()).isEqualTo(Collections.emptyMap()); verify(testChooser, times(1)).choose(null, inputContext); }