All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.assertj.guava.api.Assertions Maven / Gradle / Ivy

There is a newer version: 3.26.3
Show newest version
/**
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 *
 * Copyright 2012-2014 the original author or authors.
 */
package org.assertj.guava.api;

import org.assertj.core.data.MapEntry;

import com.google.common.base.Optional;
import com.google.common.collect.Multimap;
import com.google.common.collect.Range;
import com.google.common.collect.Table;
import com.google.common.io.ByteSource;

/**
 * The entry point for all Guava assertions.
 *
 * @author @marcelfalliere
 * @author @miralak
 * @author Kornel
 * @author Jan Gorman
 * @author Joel Costigliola
 * @author Marcin Kwaczyński
 */
public class Assertions {

  public static ByteSourceAssert assertThat(final ByteSource actual) {
    return new ByteSourceAssert(actual);
  }

  public static  MultimapAssert assertThat(final Multimap actual) {
    return new MultimapAssert(actual);
  }

  public static  OptionalAssert assertThat(final Optional actual) {
    return new OptionalAssert(actual);
  }

  public static > RangeAssert assertThat(final Range actual) {
    return new RangeAssert(actual);
  }

  public static  TableAssert assertThat(Table actual) {
    return new TableAssert(actual);
  }

  // ------------------------------------------------------------------------------------------------------
  // Data utility methods : not assertions but here to have a single entry point to all AssertJ Guava features.
  // ------------------------------------------------------------------------------------------------------

  /**
   * Only delegate to {@link MapEntry#entry(Object, Object)} so that Assertions offers a fully featured entry point to all
   * AssertJ Guava features (but you can use {@link MapEntry} if you prefer).
   * 

* Typical usage is to call entry in MultimapAssert contains assertion as shown below : * *


   * Multimap<String, String> actual = ArrayListMultimap.create();
   * actual.putAll("Lakers", newArrayList("Kobe Bryant", "Magic Johnson", "Kareem Abdul Jabbar"));
   * actual.putAll("Spurs", newArrayList("Tony Parker", "Tim Duncan", "Manu Ginobili"));
   *
   * assertThat(actual).contains(entry("Lakers", "Kobe Bryant"), entry("Spurs", "Tim Duncan"));
   * 
*/ public static MapEntry entry(final Object key, final Object value) { return MapEntry.entry(key, value); } /** * protected to avoid direct instanciation but allowing subclassing. */ protected Assertions() { // empty } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy