Search in sources :

Example 81 with AtomicIntegerArray

use of java.util.concurrent.atomic.AtomicIntegerArray in project assertj-core by joel-costigliola.

the class SoftAssertionsTest method should_work_with_atomic.

@Test
void should_work_with_atomic() {
    // WHEN
    // simple atomic value
    softly.assertThat(new AtomicBoolean(true)).isTrue().isFalse();
    softly.assertThat(new AtomicInteger(1)).hasValueGreaterThan(0).hasNegativeValue();
    softly.assertThat(new AtomicLong(1L)).hasValueGreaterThan(0L).hasNegativeValue();
    softly.assertThat(new AtomicReference<>("abc")).hasValue("abc").hasValue("def");
    // atomic array value
    softly.assertThat(new AtomicIntegerArray(new int[] { 1, 2, 3 })).containsExactly(1, 2, 3).isEmpty();
    softly.assertThat(new AtomicLongArray(new long[] { 1L, 2L, 3L })).containsExactly(1L, 2L, 3L).contains(0);
    softly.assertThat(new AtomicReferenceArray<>(array("a", "b", "c"))).containsExactly("a", "b", "c").contains("123");
    // THEN
    List<Throwable> errorsCollected = softly.errorsCollected();
    assertThat(errorsCollected).hasSize(7);
    assertThat(errorsCollected.get(0)).hasMessageContaining("false");
    assertThat(errorsCollected.get(1)).hasMessageContaining("0");
    assertThat(errorsCollected.get(2)).hasMessageContaining("0L");
    assertThat(errorsCollected.get(3)).hasMessageContaining("def");
    assertThat(errorsCollected.get(4)).hasMessageContaining("empty");
    assertThat(errorsCollected.get(5)).hasMessageContaining("0");
    assertThat(errorsCollected.get(6)).hasMessageContaining("123");
}
Also used : AtomicIntegerArray(java.util.concurrent.atomic.AtomicIntegerArray) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicLong(java.util.concurrent.atomic.AtomicLong) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicLongArray(java.util.concurrent.atomic.AtomicLongArray) Test(org.junit.jupiter.api.Test)

Example 82 with AtomicIntegerArray

use of java.util.concurrent.atomic.AtomicIntegerArray in project assertj-core by joel-costigliola.

the class Arrays_array_Test method should_return_an_int_array_from_AtomicIntegerArray.

@Test
void should_return_an_int_array_from_AtomicIntegerArray() {
    // GIVEN
    int[] expected = new int[] { 1, 2, 3, 4 };
    AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(expected);
    // WHEN
    int[] actual = array(atomicIntegerArray);
    // THEN
    assertThat(actual).isEqualTo(expected);
}
Also used : AtomicIntegerArray(java.util.concurrent.atomic.AtomicIntegerArray) Test(org.junit.jupiter.api.Test)

Example 83 with AtomicIntegerArray

use of java.util.concurrent.atomic.AtomicIntegerArray in project assertj-core by joel-costigliola.

the class AtomicIntegerArrayAssert_usingElementComparator_Test method should_honor_the_given_element_comparator.

@Test
void should_honor_the_given_element_comparator() {
    AtomicIntegerArray actual = new AtomicIntegerArray(new int[] { 1, 2, 3, 4 });
    assertThat(actual).usingElementComparator(new AbsValueComparator<Integer>()).containsExactly(-1, 2, 3, -4);
}
Also used : AtomicIntegerArray(java.util.concurrent.atomic.AtomicIntegerArray) AbsValueComparator(org.assertj.core.util.AbsValueComparator) Test(org.junit.jupiter.api.Test) AtomicIntegerArrayAssertBaseTest(org.assertj.core.api.AtomicIntegerArrayAssertBaseTest)

Example 84 with AtomicIntegerArray

use of java.util.concurrent.atomic.AtomicIntegerArray in project assertj-core by joel-costigliola.

the class AtomicIntegerArrayAssert_isNullOrEmpty_Test method should_pass_if_AtomicIntegerArray_is_null.

@Test
void should_pass_if_AtomicIntegerArray_is_null() {
    AtomicIntegerArray array = null;
    assertThat(array).isNullOrEmpty();
}
Also used : AtomicIntegerArray(java.util.concurrent.atomic.AtomicIntegerArray) Test(org.junit.jupiter.api.Test) AtomicIntegerArrayAssertBaseTest(org.assertj.core.api.AtomicIntegerArrayAssertBaseTest)

Example 85 with AtomicIntegerArray

use of java.util.concurrent.atomic.AtomicIntegerArray in project assertj-core by joel-costigliola.

the class DualValue_atomicValues_Test method isActualFieldAnAtomicIntegerArray_should_return_true_when_actual_is_an_AtomicIntegerArray.

// AtomicIntegerArray
@Test
void isActualFieldAnAtomicIntegerArray_should_return_true_when_actual_is_an_AtomicIntegerArray() {
    // GIVEN
    DualValue dualValue = new DualValue(PATH, new AtomicIntegerArray(new int[] { 1, 2, 3 }), "");
    // WHEN
    boolean isActualFieldAnAtomicIntegerArray = dualValue.isActualFieldAnAtomicIntegerArray();
    // THEN
    then(isActualFieldAnAtomicIntegerArray).isTrue();
}
Also used : AtomicIntegerArray(java.util.concurrent.atomic.AtomicIntegerArray) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

AtomicIntegerArray (java.util.concurrent.atomic.AtomicIntegerArray)85 Test (org.junit.Test)24 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)12 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)12 Test (org.junit.jupiter.api.Test)11 CountDownLatch (java.util.concurrent.CountDownLatch)8 AtomicReference (java.util.concurrent.atomic.AtomicReference)8 List (java.util.List)6 AtomicLongArray (java.util.concurrent.atomic.AtomicLongArray)6 AtomicLong (java.util.concurrent.atomic.AtomicLong)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)4 JSONArray (com.alibaba.fastjson.JSONArray)3 ArrayList (java.util.ArrayList)3 Random (java.util.Random)3 CacheException (javax.cache.CacheException)3 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)3 IgniteEx (org.apache.ignite.internal.IgniteEx)3 GridRandom (org.apache.ignite.internal.util.GridRandom)3 CAX (org.apache.ignite.internal.util.typedef.CAX)3