
org.mockserver.test.Assert Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockserver-integration-testing Show documentation
Show all versions of mockserver-integration-testing Show documentation
A module used to simplify integration testing of all MockServer versions by sharing commons integration testing components
package org.mockserver.test;
import java.util.Collection;
import java.util.List;
import static org.junit.Assert.*;
/**
* @author jamesdbloom
*/
public class Assert {
/**
* Asserts that string contains specified substring.
*/
public static void assertContains(String string, String substring) {
assertNotNull("string should not be null", string);
assertNotNull("substring should not be null", substring);
if (!string.contains(substring)) {
fail("Unable to find [" + substring + "] in [" + string + "]");
}
}
/**
* Asserts that string contains specified substring.
*/
public static void assertDoesNotContain(String string, String substring) {
assertNotNull("string should not be null", string);
assertNotNull("substring should not be null", substring);
if (string.contains(substring)) {
fail("Able to find [" + substring + "] in [" + string + "]");
}
}
/**
* Asserts that the two lists contain the same entries regardless of order
*/
public static void assertSameEntries(Collection collectionOne, Collection collectionTwo) {
assertEquals("different number of entries between list [" + collectionOne + "] and [" + collectionTwo + "]", collectionOne.size(), collectionTwo.size());
for (T expected : collectionOne) {
if (!collectionTwo.contains(expected)) {
fail("list [" + collectionOne + "] does not contain [" + expected + "]");
}
}
for (T expected : collectionTwo) {
if (!collectionOne.contains(expected)) {
fail("list [" + collectionTwo + "] does not contain [" + expected + "]");
}
}
}
}