Skip to content

Commit 7297dcd

Browse files
Unit tests revision - part 2
1 parent f75eb8a commit 7297dcd

3 files changed

Lines changed: 8 additions & 10 deletions

File tree

extra/modules/wurfl-devicedetection/src/test/java/org/prebid/server/hooks/modules/com/scientiamobile/wurfl/devicedetection/v1/OrtbDeviceUpdaterTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import static org.assertj.core.api.Assertions.assertThat;
2020
import static org.mockito.BDDMockito.given;
2121
import static org.mockito.Mock.Strictness.LENIENT;
22-
import static org.mockito.Mockito.when;
2322

2423
@ExtendWith(MockitoExtension.class)
2524
public class OrtbDeviceUpdaterTest {
@@ -251,7 +250,7 @@ public void updateShouldReturnNullWhenMobileTypeIsUnknown() {
251250
final BidRequest bidRequest = BidRequest.builder().device(device).build();
252251
final OrtbDeviceUpdater target = new OrtbDeviceUpdater(wurflDevice, staticCaps, virtualCaps, true, mapper);
253252
// when
254-
when(payload.bidRequest()).thenReturn(bidRequest);
253+
given(payload.bidRequest()).willReturn(bidRequest);
255254
final AuctionRequestPayload result = target.apply(payload);
256255
// then
257256
final Device resultDevice = result.bidRequest().getDevice();
@@ -272,7 +271,7 @@ public void updateShouldHandlePersonalComputerDeviceType() {
272271
given(wurflDevice.getVirtualCapability("form_factor")).willReturn("Desktop");
273272
final OrtbDeviceUpdater target = new OrtbDeviceUpdater(wurflDevice, staticCaps, virtualCaps, true, mapper);
274273
// when
275-
when(payload.bidRequest()).thenReturn(bidRequest);
274+
given(payload.bidRequest()).willReturn(bidRequest);
276275
final AuctionRequestPayload result = target.apply(payload);
277276

278277
// then

extra/modules/wurfl-devicedetection/src/test/java/org/prebid/server/hooks/modules/com/scientiamobile/wurfl/devicedetection/v1/WURFLDeviceDetectionEntrypointHookTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import org.prebid.server.model.CaseInsensitiveMultiMap;
1515

1616
import static org.assertj.core.api.Assertions.assertThat;
17-
import static org.mockito.Mockito.when;
17+
import static org.mockito.BDDMockito.given;
1818

1919
@ExtendWith(MockitoExtension.class)
2020
public class WURFLDeviceDetectionEntrypointHookTest {
@@ -45,7 +45,7 @@ public void callShouldReturnSuccessWithNoAction() {
4545
final CaseInsensitiveMultiMap headers = CaseInsensitiveMultiMap.builder()
4646
.add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Test")
4747
.build();
48-
when(payload.headers()).thenReturn(headers);
48+
given(payload.headers()).willReturn(headers);
4949

5050
// when
5151
final Future<InvocationResult<EntrypointPayload>> result = target.call(payload, context);
@@ -65,7 +65,7 @@ public void callShouldHandleNullHeaders() {
6565
final WURFLDeviceDetectionEntrypointHook target = new WURFLDeviceDetectionEntrypointHook();
6666

6767
// when
68-
when(payload.headers()).thenReturn(null);
68+
given(payload.headers()).willReturn(null);
6969
final Future<InvocationResult<EntrypointPayload>> result = target.call(payload, context);
7070

7171
// then

extra/modules/wurfl-devicedetection/src/test/java/org/prebid/server/hooks/modules/com/scientiamobile/wurfl/devicedetection/v1/WURFLServiceTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import static org.mockito.Mockito.doThrow;
2121
import static org.mockito.Mockito.mock;
2222
import static org.mockito.Mockito.verify;
23-
import static org.mockito.Mockito.when;
2423
import static org.mockito.Mock.Strictness.LENIENT;
2524
import static org.mockito.Mockito.spy;
2625
import static org.mockito.Mockito.doReturn;
@@ -87,7 +86,7 @@ public void lookupDeviceShouldReturnDeviceWhenEngineIsNotNull() {
8786
headers.put("User-Agent", "test-user-agent");
8887

8988
final Device expectedDevice = mock(Device.class);
90-
when(wurflEngine.getDeviceForRequest(headers)).thenReturn(expectedDevice);
89+
given(wurflEngine.getDeviceForRequest(headers)).willReturn(expectedDevice);
9190

9291
// when
9392
final Optional<Device> result = wurflService.lookupDevice(headers);
@@ -115,7 +114,7 @@ public void lookupDeviceShouldReturnEmptyWhenEngineIsNull() {
115114
public void getAllCapabilitiesShouldReturnCapabilitiesWhenEngineIsNotNull() {
116115
// given
117116
final Set<String> expectedCapabilities = Set.of("capability1", "capability2");
118-
when(wurflEngine.getAllCapabilities()).thenReturn(expectedCapabilities);
117+
given(wurflEngine.getAllCapabilities()).willReturn(expectedCapabilities);
119118

120119
// when
121120
final Set<String> result = wurflService.getAllCapabilities();
@@ -141,7 +140,7 @@ public void getAllCapabilitiesShouldReturnEmptySetWhenEngineIsNull() {
141140
public void getAllVirtualCapabilitiesShouldReturnCapabilitiesWhenEngineIsNotNull() {
142141
// given
143142
final Set<String> expectedCapabilities = Set.of("virtualCapability1", "virtualCapability2");
144-
when(wurflEngine.getAllVirtualCapabilities()).thenReturn(expectedCapabilities);
143+
given(wurflEngine.getAllVirtualCapabilities()).willReturn(expectedCapabilities);
145144

146145
// when
147146
final Set<String> result = wurflService.getAllVirtualCapabilities();

0 commit comments

Comments
 (0)