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

com.cedarsoft.AssertUtils Maven / Gradle / Ivy

package com.cedarsoft;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static org.testng.Assert.*;

import java.util.ArrayList;
import java.util.List;

/**
 *
 */
public class AssertUtils {
  private AssertUtils() {
  }

  public static void assertOne( @Nullable Object current, @NotNull Object... expectedAlternatives ) {
    List failed = new ArrayList();

    for ( Object expectedAlternative : expectedAlternatives ) {
      try {
        assertEquals( current, expectedAlternative );
        return; //Successfully
      } catch ( AssertionError e ) {
        failed.add( e );
      }
    }

    StringBuilder message = new StringBuilder();

    for ( AssertionError assertionError : failed ) {
      message.append( assertionError.getMessage() );
      message.append( "\n" );
    }

    throw new AssertionError( message.toString() );
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy