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 voidassertArraysEqual(byte[] expected, byte[] got)static voidassertArraysEqual(int[] expected, int[] got)static voidassertContains(String textToCheck, String substring)static voidassertContains(String textToCheck, String substring, boolean caseSensitive)static voidassertContains(String textToCheck, Pattern pattern)static <T> voidassertContains(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 voidassertContainsAll(String text, String... messages)static voidassertContainsAny(String text, String... messages)static voidassertContainsWithCount(String textToCheck, String substring, int expectedCount)static voidassertEmpty(Collection collection)Asserts that collection is empty or null.static voidassertEmpty(Collection collection, String message)Asserts that collection is empty or null.static voidassertEquals(String message, BigDecimal expected, BigDecimal got)static voidassertEquals(String message, Date exp, Date got, long limit)Asserts sate and time.static voidassertEquals(Date exp, Date got, long limit)Asserts sate and time.static voidassertEqualsIgnoreNonBMP(String expected, String got)static voidassertGreater(int actual, int lowBound)static voidassertGreater(long actual, long lowBound)static voidassertGreaterOrEquals(int actual, int lowBound)static voidassertGreaterOrEquals(long actual, long lowBound)static voidassertHasWithCount(String textToCheck, String substring, int expectedCount)static <T> voidassertInstanceOf(Object instance, Class<T> expectedClass)static voidassertLess(int actual, int upperBound)static voidassertLess(long actual, long upperBound)static voidassertLessOrEquals(int actual, int upperBound)static voidassertLessOrEquals(long actual, long upperBound)static <T> voidassertListEquals(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 voidassertMatches(String actual, String pattern)static voidassertMatches(String actual, Pattern pattern)static voidassertMeaningTextEquals(String actual, String expected)static voidassertNotContains(String textToCheck, String substring, boolean caseSensitive)static voidassertNotContains(String textToCheck, Pattern pattern)static <T> voidassertNotContains(Collection<T> collection, T... items)Checks that the collection contains the given item.static voidassertNotEmpty(Collection<?> collection)Asserts that the collections is not empty (and is not null).static <T> voidassertNotEmpty(T[] array)Asserts that the array is not empty (and is not null).static voidassertNull2(Object object)More descriptive assertion than the Assert from junit.static <T> voidassertSameElements(Collection<? extends T> collection, Collection<T> expected)static <T> voidassertSameElements(Collection<? extends T> collection, T... expected)static <T> voidassertSameElements(T[] collection, T... expected)static <T> voidassertSetEquals(Set<T> actual, T... expected)Applicable for both sorted set and has set.static voidassertTime(double maxAllowedExecutionTimeInSecs, String message, int numberOfAttempts, Runnable r)static voidassertTime(double maxAllowedExecutionTimeInSecs, String message, Runnable r)static voidassertTimestampEquals(Date actual, Date expected)static voidmeasureRunsAndPrintStats(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)
-
-