Skip to content

Commit d8cb2fa

Browse files
committed
Fix comments
1 parent cc3e092 commit d8cb2fa

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

extra/modules/live-intent-omni-channel-identity/src/main/java/org/prebid/server/hooks/modules/liveintent/omni/channel/identity/config/LiveIntentOmniChannelIdentityConfiguration.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.springframework.context.annotation.Configuration;
1414

1515
import java.util.Collections;
16-
import java.util.concurrent.ThreadLocalRandom;
1716

1817
@Configuration
1918
@ConditionalOnProperty(
@@ -36,7 +35,7 @@ Module liveIntentOmniChannelIdentityModule(LiveIntentOmniChannelProperties prope
3635

3736
final LiveIntentOmniChannelIdentityProcessedAuctionRequestHook hook =
3837
new LiveIntentOmniChannelIdentityProcessedAuctionRequestHook(
39-
properties, mapper, httpClient, () -> ThreadLocalRandom.current().nextLong(), logSamplingRate);
38+
properties, mapper, httpClient, logSamplingRate);
4039

4140
return new LiveIntentOmniChannelIdentityModule(Collections.singleton(hook));
4241
}

extra/modules/live-intent-omni-channel-identity/src/main/java/org/prebid/server/hooks/modules/liveintent/omni/channel/identity/v1/hooks/LiveIntentOmniChannelIdentityProcessedAuctionRequestHook.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import java.util.List;
2828
import java.util.Objects;
2929
import java.util.Optional;
30-
import java.util.random.RandomGenerator;
30+
import java.util.concurrent.ThreadLocalRandom;
3131

3232
public class LiveIntentOmniChannelIdentityProcessedAuctionRequestHook implements ProcessedAuctionRequestHook {
3333

@@ -39,33 +39,30 @@ public class LiveIntentOmniChannelIdentityProcessedAuctionRequestHook implements
3939
private final LiveIntentOmniChannelProperties config;
4040
private final JacksonMapper mapper;
4141
private final HttpClient httpClient;
42-
private final RandomGenerator random;
4342
private final double logSamplingRate;
4443

4544
public LiveIntentOmniChannelIdentityProcessedAuctionRequestHook(LiveIntentOmniChannelProperties config,
4645
JacksonMapper mapper,
4746
HttpClient httpClient,
48-
RandomGenerator random,
4947
double logSamplingRate) {
5048

5149
this.config = Objects.requireNonNull(config);
5250
HttpUtil.validateUrlSyntax(config.getIdentityResolutionEndpoint());
5351
this.mapper = Objects.requireNonNull(mapper);
5452
this.httpClient = Objects.requireNonNull(httpClient);
55-
this.random = Objects.requireNonNull(random);
5653
this.logSamplingRate = logSamplingRate;
5754
}
5855

5956
@Override
6057
public Future<InvocationResult<AuctionRequestPayload>> call(AuctionRequestPayload auctionRequestPayload,
6158
AuctionInvocationContext invocationContext) {
6259

63-
return config.getTreatmentRate() <= random.nextFloat()
64-
? noAction()
65-
: requestIdentities(auctionRequestPayload.bidRequest())
60+
return config.getTreatmentRate() > ThreadLocalRandom.current().nextFloat()
61+
? requestIdentities(auctionRequestPayload.bidRequest())
6662
.<InvocationResult<AuctionRequestPayload>>map(this::update)
6763
.onFailure(throwable -> conditionalLogger.error(
68-
"Failed enrichment: %s".formatted(throwable.getMessage()), logSamplingRate));
64+
"Failed enrichment: %s".formatted(throwable.getMessage()), logSamplingRate))
65+
: noAction();
6966
}
7067

7168
private Future<IdResResponse> requestIdentities(BidRequest bidRequest) {

extra/modules/live-intent-omni-channel-identity/src/test/java/org/prebid/server/hooks/modules/liveintent/omni/channel/identity/v1/LiveIntentOmniChannelIdentityProcessedAuctionRequestHookTest.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.prebid.server.vertx.httpclient.model.HttpClientResponse;
2727

2828
import java.util.List;
29-
import java.util.Random;
3029
import java.util.concurrent.TimeoutException;
3130

3231
import static java.util.Collections.singletonList;
@@ -48,9 +47,6 @@ public class LiveIntentOmniChannelIdentityProcessedAuctionRequestHookTest {
4847
@Mock
4948
private HttpClient httpClient;
5049

51-
@Mock(strictness = LENIENT)
52-
private Random random;
53-
5450
@Mock(strictness = LENIENT)
5551
private LiveIntentOmniChannelProperties properties;
5652

@@ -61,19 +57,18 @@ public void setUp() {
6157
given(properties.getRequestTimeoutMs()).willReturn(5L);
6258
given(properties.getIdentityResolutionEndpoint()).willReturn("https://test.com/idres");
6359
given(properties.getAuthToken()).willReturn("auth_token");
64-
given(properties.getTreatmentRate()).willReturn(0.9f);
65-
given(random.nextFloat()).willReturn(0.89f);
60+
given(properties.getTreatmentRate()).willReturn(1.0f);
6661

6762
target = new LiveIntentOmniChannelIdentityProcessedAuctionRequestHook(
68-
properties, MAPPER, httpClient, random, 0.01d);
63+
properties, MAPPER, httpClient, 0.01d);
6964
}
7065

7166
@Test
7267
public void creationShouldFailOnInvalidIdentityUrl() {
7368
given(properties.getIdentityResolutionEndpoint()).willReturn("invalid_url");
7469
assertThatIllegalArgumentException().isThrownBy(() ->
7570
new LiveIntentOmniChannelIdentityProcessedAuctionRequestHook(
76-
properties, MAPPER, httpClient, random, 0.01d));
71+
properties, MAPPER, httpClient, 0.01d));
7772
}
7873

7974
@Test
@@ -164,8 +159,7 @@ public void callShouldReturnNoActionSuccessfullyWhenTreatmentRateIsLowerThanThre
164159
final AuctionInvocationContext auctionInvocationContext = AuctionInvocationContextImpl.of(
165160
null, null, false, null, null);
166161

167-
given(properties.getTreatmentRate()).willReturn(0.9f);
168-
given(random.nextFloat()).willReturn(0.91f);
162+
given(properties.getTreatmentRate()).willReturn(0.0f);
169163

170164
// when
171165
final InvocationResult<AuctionRequestPayload> result = target.call(

0 commit comments

Comments
 (0)