Skip to content

Commit 83ed37d

Browse files
committed
remove SetCacheBehaviorParameters class
1 parent 83e4520 commit 83ed37d

File tree

3 files changed

+21
-61
lines changed

3 files changed

+21
-61
lines changed

java/src/org/openqa/selenium/bidi/module/Network.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.util.Collections;
2121
import java.util.HashSet;
22+
import java.util.List;
2223
import java.util.Map;
2324
import java.util.Set;
2425
import java.util.function.Consumer;
@@ -30,12 +31,12 @@
3031
import org.openqa.selenium.bidi.HasBiDi;
3132
import org.openqa.selenium.bidi.network.AddInterceptParameters;
3233
import org.openqa.selenium.bidi.network.BeforeRequestSent;
34+
import org.openqa.selenium.bidi.network.CacheBehavior;
3335
import org.openqa.selenium.bidi.network.ContinueRequestParameters;
3436
import org.openqa.selenium.bidi.network.ContinueResponseParameters;
3537
import org.openqa.selenium.bidi.network.FetchError;
3638
import org.openqa.selenium.bidi.network.ProvideResponseParameters;
3739
import org.openqa.selenium.bidi.network.ResponseDetails;
38-
import org.openqa.selenium.bidi.network.SetCacheBehaviorParameters;
3940
import org.openqa.selenium.internal.Require;
4041

4142
public class Network implements AutoCloseable {
@@ -138,8 +139,20 @@ public void provideResponse(ProvideResponseParameters parameters) {
138139
this.bidi.send(new Command<>("network.provideResponse", parameters.toMap()));
139140
}
140141

141-
public void setCacheBehavior(SetCacheBehaviorParameters parameters) {
142-
this.bidi.send(new Command<>("network.setCacheBehavior", parameters.toMap()));
142+
public void setCacheBehavior(CacheBehavior cacheBehavior) {
143+
Require.nonNull("Cache behavior", cacheBehavior);
144+
this.bidi.send(
145+
new Command<>(
146+
"network.setCacheBehavior", Map.of("cacheBehavior", cacheBehavior.toString())));
147+
}
148+
149+
public void setCacheBehavior(CacheBehavior cacheBehavior, List<String> contexts) {
150+
Require.nonNull("Cache behavior", cacheBehavior);
151+
Require.nonNull("Contexts", contexts);
152+
this.bidi.send(
153+
new Command<>(
154+
"network.setCacheBehavior",
155+
Map.of("cacheBehavior", cacheBehavior.toString(), "contexts", contexts)));
143156
}
144157

145158
public void onBeforeRequestSent(Consumer<BeforeRequestSent> consumer) {

java/src/org/openqa/selenium/bidi/network/SetCacheBehaviorParameters.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

java/test/org/openqa/selenium/bidi/network/NetworkCommandsTest.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,7 @@ void canSetCacheBehaviorToBypass() {
278278
BrowsingContext context = new BrowsingContext(driver, WindowType.TAB);
279279
String contextId = context.getId();
280280

281-
network.setCacheBehavior(
282-
new SetCacheBehaviorParameters(
283-
CacheBehavior.BYPASS, Collections.singletonList(contextId)));
281+
network.setCacheBehavior(CacheBehavior.BYPASS, Collections.singletonList(contextId));
284282
}
285283
}
286284

@@ -293,9 +291,7 @@ void canSetCacheBehaviorToDefault() {
293291
BrowsingContext context = new BrowsingContext(driver, WindowType.TAB);
294292
String contextId = context.getId();
295293

296-
network.setCacheBehavior(
297-
new SetCacheBehaviorParameters(
298-
CacheBehavior.DEFAULT, Collections.singletonList(contextId)));
294+
network.setCacheBehavior(CacheBehavior.DEFAULT, Collections.singletonList(contextId));
299295
}
300296
}
301297

@@ -305,8 +301,8 @@ void canSetCacheBehaviorWithNoContextId() {
305301
try (Network network = new Network(driver)) {
306302
page = appServer.whereIs("basicAuth");
307303

308-
network.setCacheBehavior(new SetCacheBehaviorParameters(CacheBehavior.BYPASS));
309-
network.setCacheBehavior(new SetCacheBehaviorParameters(CacheBehavior.DEFAULT));
304+
network.setCacheBehavior(CacheBehavior.BYPASS);
305+
network.setCacheBehavior(CacheBehavior.DEFAULT);
310306
}
311307
}
312308

@@ -319,8 +315,7 @@ void throwsExceptionForInvalidContext() {
319315
assertThatThrownBy(
320316
() ->
321317
network.setCacheBehavior(
322-
new SetCacheBehaviorParameters(
323-
CacheBehavior.DEFAULT, Collections.singletonList("invalid-context"))))
318+
CacheBehavior.DEFAULT, Collections.singletonList("invalid-context")))
324319
.isInstanceOf(BiDiException.class)
325320
.hasMessageContaining("no such frame");
326321
}

0 commit comments

Comments
 (0)