Path: blob/trunk/java/test/org/openqa/selenium/PersistentCapabilitiesTest.java
1865 views
// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the5// "License"); you may not use this file except in compliance6// with the License. You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing,11// software distributed under the License is distributed on an12// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13// KIND, either express or implied. See the License for the14// specific language governing permissions and limitations15// under the License.1617package org.openqa.selenium;1819import static org.assertj.core.api.Assertions.assertThat;2021import org.junit.jupiter.api.Tag;22import org.junit.jupiter.api.Test;2324@Tag("UnitTests")25class PersistentCapabilitiesTest {2627@Test28void shouldAllowAnEmptySetOfCapabilities() {29Capabilities seen = new PersistentCapabilities();3031assertThat(seen).isEqualTo(new ImmutableCapabilities());32}3334@Test35void modifyingTheCapabilitiesThisPersistentCapabilitiesIsBasedOnDoesNotChangeOurView() {36MutableCapabilities mutableCaps = new MutableCapabilities();37Capabilities caps = new PersistentCapabilities(mutableCaps);3839mutableCaps.setCapability("cheese", "parmesan");4041assertThat(caps).isEqualTo(new ImmutableCapabilities());42}4344@Test45void shouldBePossibleToOverrideAValue() {46Capabilities original = new ImmutableCapabilities("vegetable", "peas");47Capabilities seen = new PersistentCapabilities(original).setCapability("vegetable", "carrots");4849assertThat(seen).isEqualTo(new ImmutableCapabilities("vegetable", "carrots"));50}5152@Test53void shouldActuallyBePersistent() {54PersistentCapabilities original =55new PersistentCapabilities(new ImmutableCapabilities("cheese", "cheddar"));56Capabilities seen = original.setCapability("cheese", "orgu peynir");5758assertThat(original).isEqualTo(new ImmutableCapabilities("cheese", "cheddar"));59assertThat(seen).isEqualTo(new ImmutableCapabilities("cheese", "orgu peynir"));60}6162@Test63void shouldAllowChainedCallsToSetCapabilities() {64PersistentCapabilities caps =65new PersistentCapabilities(new ImmutableCapabilities())66.setCapability("one", 1)67.setCapability("two", 2);6869assertThat(caps).isEqualTo(new ImmutableCapabilities("one", 1, "two", 2));70}71}727374