Package jetbrains.buildServer
Class TeamCityAsserts
- java.lang.Object
-
- jetbrains.buildServer.TeamCityAsserts
-
public final class TeamCityAsserts extends Object
Useful assert methods.- Since:
- 9.0
- Author:
- Leonid Bushuev from JetBrains
-
-
Constructor Summary
Constructors Constructor Description TeamCityAsserts()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
assertArraysEqual(byte[] expected, byte[] got)
static void
assertArraysEqual(int[] expected, int[] got)
static void
assertContains(String textToCheck, String substring)
static void
assertContains(String textToCheck, String substring, boolean caseSensitive)
static void
assertContains(String textToCheck, Pattern pattern)
static <T> void
assertContains(Collection<T> collection, T... items)
Checks that the collection contains the given item.static <K,V>
voidassertContains(Map<K,V> includingMap, Map<K,V> includedMap)
static void
assertContainsAll(String text, String... messages)
static void
assertContainsAny(String text, String... messages)
static void
assertContainsWithCount(String textToCheck, String substring, int expectedCount)
static void
assertEmpty(Collection collection)
Asserts that collection is empty or null.static void
assertEmpty(Collection collection, String message)
Asserts that collection is empty or null.static void
assertEquals(String message, BigDecimal expected, BigDecimal got)
static void
assertEquals(String message, Date exp, Date got, long limit)
Asserts sate and time.static void
assertEquals(Date exp, Date got, long limit)
Asserts sate and time.static void
assertEqualsIgnoreNonBMP(String expected, String got)
static void
assertGreater(int actual, int lowBound)
static void
assertGreater(long actual, long lowBound)
static void
assertGreaterOrEquals(int actual, int lowBound)
static void
assertGreaterOrEquals(long actual, long lowBound)
static void
assertHasWithCount(String textToCheck, String substring, int expectedCount)
static <T> void
assertInstanceOf(Object instance, Class<T> expectedClass)
static void
assertLess(int actual, int upperBound)
static void
assertLess(long actual, long upperBound)
static void
assertLessOrEquals(int actual, int upperBound)
static void
assertLessOrEquals(long actual, long upperBound)
static <T> void
assertListEquals(List<T> actual, T... expected)
static <K,V>
voidassertMap(Map<K,V> map, Object... expected)
static <K,V>
voidassertMapping(Map<K,V> map, K key, V expectedValue)
static void
assertMatches(String actual, String pattern)
static void
assertMatches(String actual, Pattern pattern)
static void
assertMeaningTextEquals(String actual, String expected)
static void
assertNotContains(String textToCheck, String substring, boolean caseSensitive)
static void
assertNotContains(String textToCheck, Pattern pattern)
static <T> void
assertNotContains(Collection<T> collection, T... items)
Checks that the collection contains the given item.static void
assertNotEmpty(Collection<?> collection)
Asserts that the collections is not empty (and is not null).static <T> void
assertNotEmpty(T[] array)
Asserts that the array is not empty (and is not null).static void
assertNull2(Object object)
More descriptive assertion than the Assert from junit.static <T> void
assertSameElements(Collection<? extends T> collection, Collection<T> expected)
static <T> void
assertSameElements(Collection<? extends T> collection, T... expected)
static <T> void
assertSameElements(T[] collection, T... expected)
static <T> void
assertSetEquals(Set<T> actual, T... expected)
Applicable for both sorted set and has set.static void
assertTime(double maxAllowedExecutionTimeInSecs, String message, int numberOfAttempts, Runnable r)
static void
assertTime(double maxAllowedExecutionTimeInSecs, String message, Runnable r)
static void
assertTimestampEquals(Date actual, Date expected)
static void
measureRunsAndPrintStats(Runnable r, int runCount)
-
-
-
Method Detail
-
assertTime
public static void assertTime(double maxAllowedExecutionTimeInSecs, String message, Runnable r)
-
assertTime
public static void assertTime(double maxAllowedExecutionTimeInSecs, String message, int numberOfAttempts, Runnable r)
-
measureRunsAndPrintStats
public static void measureRunsAndPrintStats(Runnable r, int runCount)
-
assertContains
public static <T> void assertContains(@Nullable Collection<T> collection, T... items)
Checks that the collection contains the given item.- Type Parameters:
T
- type of items.- Parameters:
collection
- collection to check.items
- items to found.
-
assertContains
public static <K,V> void assertContains(@NotNull Map<K,V> includingMap, @NotNull Map<K,V> includedMap)
-
assertNotContains
public static <T> void assertNotContains(@Nullable Collection<T> collection, T... items)
Checks that the collection contains the given item.- Type Parameters:
T
- type of items.- Parameters:
collection
- collection to check.items
- items to found.
-
assertEmpty
public static void assertEmpty(@Nullable Collection collection)
Asserts that collection is empty or null.- Parameters:
collection
- the collection to check.
-
assertEmpty
public static void assertEmpty(@Nullable Collection collection, @Nullable String message)
Asserts that collection is empty or null.- Parameters:
collection
- the collection to check.
-
assertNotEmpty
public static <T> void assertNotEmpty(@Nullable T[] array)
Asserts that the array is not empty (and is not null).- Parameters:
array
- array to check.
-
assertNotEmpty
public static void assertNotEmpty(@Nullable Collection<?> collection)
Asserts that the collections is not empty (and is not null).- Parameters:
collection
- the collection to check.
-
assertNull2
public static void assertNull2(@Nullable Object object)
More descriptive assertion than the Assert from junit. If object is not null, it says the object's value (usingObject.toString()
).- Parameters:
object
- object that is checking to be null.
-
assertMeaningTextEquals
public static void assertMeaningTextEquals(@Nullable String actual, @Nullable String expected)
-
assertContainsAll
public static void assertContainsAll(@Nullable String text, @NotNull String... messages)
-
assertContainsAny
public static void assertContainsAny(@Nullable String text, @NotNull String... messages)
-
assertContains
public static void assertContains(@Nullable String textToCheck, @NotNull String substring, boolean caseSensitive)
-
assertNotContains
public static void assertNotContains(@Nullable String textToCheck, @NotNull String substring, boolean caseSensitive)
-
assertHasWithCount
public static void assertHasWithCount(String textToCheck, String substring, int expectedCount)
-
assertContainsWithCount
public static void assertContainsWithCount(String textToCheck, String substring, int expectedCount)
-
assertSameElements
public static <T> void assertSameElements(T[] collection, T... expected)
-
assertSameElements
public static <T> void assertSameElements(Collection<? extends T> collection, T... expected)
-
assertSameElements
public static <T> void assertSameElements(Collection<? extends T> collection, Collection<T> expected)
-
assertEquals
public static void assertEquals(Date exp, Date got, long limit)
Asserts sate and time.- Parameters:
exp
- what is expected.got
- what's got (actual).limit
- max allowed difference, in seconds.
-
assertEquals
public static void assertEquals(String message, Date exp, Date got, long limit)
Asserts sate and time.- Parameters:
message
- message that will be outputted in case of a fail.exp
- what is expected.got
- what's got (actual).limit
- max allowed difference, in seconds.
-
assertEquals
public static void assertEquals(String message, BigDecimal expected, BigDecimal got)
-
assertEqualsIgnoreNonBMP
public static void assertEqualsIgnoreNonBMP(@Nullable String expected, @Nullable String got)
-
assertArraysEqual
public static void assertArraysEqual(int[] expected, int[] got)
-
assertArraysEqual
public static void assertArraysEqual(byte[] expected, byte[] got)
-
assertSetEquals
public static <T> void assertSetEquals(Set<T> actual, T... expected)
Applicable for both sorted set and has set. In case of sorted one, the actual set's comparator is used.- Type Parameters:
T
- type of items- Parameters:
actual
- the set to checkexpected
- expected items, must be no duplicates- Since:
- 8.1
-
assertListEquals
public static <T> void assertListEquals(List<T> actual, @NotNull T... expected)
-
assertMapping
public static <K,V> void assertMapping(@NotNull Map<K,V> map, @NotNull K key, @NotNull V expectedValue)
-
assertGreater
public static void assertGreater(int actual, int lowBound)
-
assertGreater
public static void assertGreater(long actual, long lowBound)
-
assertLess
public static void assertLess(int actual, int upperBound)
-
assertLess
public static void assertLess(long actual, long upperBound)
-
assertGreaterOrEquals
public static void assertGreaterOrEquals(int actual, int lowBound)
-
assertGreaterOrEquals
public static void assertGreaterOrEquals(long actual, long lowBound)
-
assertLessOrEquals
public static void assertLessOrEquals(int actual, int upperBound)
-
assertLessOrEquals
public static void assertLessOrEquals(long actual, long upperBound)
-
-