Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/java/test/org/openqa/selenium/PersistentCapabilitiesTest.java
1865 views
1
// Licensed to the Software Freedom Conservancy (SFC) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The SFC licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License. You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied. See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
package org.openqa.selenium;
19
20
import static org.assertj.core.api.Assertions.assertThat;
21
22
import org.junit.jupiter.api.Tag;
23
import org.junit.jupiter.api.Test;
24
25
@Tag("UnitTests")
26
class PersistentCapabilitiesTest {
27
28
@Test
29
void shouldAllowAnEmptySetOfCapabilities() {
30
Capabilities seen = new PersistentCapabilities();
31
32
assertThat(seen).isEqualTo(new ImmutableCapabilities());
33
}
34
35
@Test
36
void modifyingTheCapabilitiesThisPersistentCapabilitiesIsBasedOnDoesNotChangeOurView() {
37
MutableCapabilities mutableCaps = new MutableCapabilities();
38
Capabilities caps = new PersistentCapabilities(mutableCaps);
39
40
mutableCaps.setCapability("cheese", "parmesan");
41
42
assertThat(caps).isEqualTo(new ImmutableCapabilities());
43
}
44
45
@Test
46
void shouldBePossibleToOverrideAValue() {
47
Capabilities original = new ImmutableCapabilities("vegetable", "peas");
48
Capabilities seen = new PersistentCapabilities(original).setCapability("vegetable", "carrots");
49
50
assertThat(seen).isEqualTo(new ImmutableCapabilities("vegetable", "carrots"));
51
}
52
53
@Test
54
void shouldActuallyBePersistent() {
55
PersistentCapabilities original =
56
new PersistentCapabilities(new ImmutableCapabilities("cheese", "cheddar"));
57
Capabilities seen = original.setCapability("cheese", "orgu peynir");
58
59
assertThat(original).isEqualTo(new ImmutableCapabilities("cheese", "cheddar"));
60
assertThat(seen).isEqualTo(new ImmutableCapabilities("cheese", "orgu peynir"));
61
}
62
63
@Test
64
void shouldAllowChainedCallsToSetCapabilities() {
65
PersistentCapabilities caps =
66
new PersistentCapabilities(new ImmutableCapabilities())
67
.setCapability("one", 1)
68
.setCapability("two", 2);
69
70
assertThat(caps).isEqualTo(new ImmutableCapabilities("one", 1, "two", 2));
71
}
72
}
73
74