Search in sources :

Example 86 with EqualsTester

use of com.google.common.testing.EqualsTester in project google-cloud-java by GoogleCloudPlatform.

the class TimestampTest method equalsAndHashCode.

@Test
public void equalsAndHashCode() {
    EqualsTester tester = new EqualsTester();
    tester.addEqualityGroup(Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS, 0), Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS, 0), Timestamp.of(new java.sql.Timestamp(TEST_TIME_SECONDS * 1000)));
    tester.addEqualityGroup(Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS + 1, 0));
    tester.addEqualityGroup(Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS, 1));
    tester.testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 87 with EqualsTester

use of com.google.common.testing.EqualsTester in project core-java by SpineEventEngine.

the class MessageEnvelopeShould method support_equality.

@Test
public void support_equality() {
    final O oneMessage = outerObject();
    final O anotherMessage = outerObject();
    final E oneEnvelope = toEnvelope(oneMessage);
    final E anotherEnvelope = toEnvelope(anotherMessage);
    new EqualsTester().addEqualityGroup(oneEnvelope).addEqualityGroup(anotherEnvelope).testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 88 with EqualsTester

use of com.google.common.testing.EqualsTester in project core-java by SpineEventEngine.

the class EntityQueryShould method support_equality.

@Test
public void support_equality() {
    final EqualsTester tester = new EqualsTester();
    addEqualityGroupA(tester);
    addEqualityGroupB(tester);
    addEqualityGroupC(tester);
    addEqualityGroupD(tester);
    tester.testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 89 with EqualsTester

use of com.google.common.testing.EqualsTester in project core-java by SpineEventEngine.

the class EntityRecordWithColumnsShould method have_equals.

@Test
public void have_equals() {
    final MemoizedValue mockValue = mock(MemoizedValue.class);
    final EntityRecordWithColumns noFieldsEnvelope = of(EntityRecord.getDefaultInstance());
    final EntityRecordWithColumns emptyFieldsEnvelope = of(EntityRecord.getDefaultInstance(), Collections.<String, MemoizedValue>emptyMap());
    final EntityRecordWithColumns notEmptyFieldsEnvelope = of(EntityRecord.getDefaultInstance(), singletonMap("key", mockValue));
    new EqualsTester().addEqualityGroup(noFieldsEnvelope, emptyFieldsEnvelope, notEmptyFieldsEnvelope).addEqualityGroup(newRecord()).addEqualityGroup(// Each one has different EntityRecord
    newRecord()).testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) MemoizedValue(io.spine.server.entity.storage.EntityColumn.MemoizedValue) Test(org.junit.Test)

Example 90 with EqualsTester

use of com.google.common.testing.EqualsTester in project core-java by SpineEventEngine.

the class QueryParametersShould method support_equality.

@Test
public void support_equality() {
    // --- Group A ---
    // Consists of 2 empty instances
    final QueryParameters paramsA1 = newBuilder().build();
    final QueryParameters paramsA2 = newBuilder().build();
    // --- Group B ---
    // Consists of 3 instances with a single filter targeting a String column
    final EntityColumn bColumn = mockColumn();
    final ColumnFilter bFilter = ColumnFilters.eq("b", "c");
    final QueryParameters paramsB1 = newBuilder().add(aggregatingParameter(bColumn, bFilter)).build();
    final QueryParameters paramsB2 = newBuilder().add(aggregatingParameter(bColumn, bFilter)).build();
    final QueryParameters paramsB3 = newBuilder().add(aggregatingParameter(bColumn, bFilter)).build();
    // --- Group C ---
    // Consists of an instance with a single filter targeting an integer number column
    final EntityColumn cColumn = mockColumn();
    final ColumnFilter cFilter = ColumnFilters.eq("a", 42);
    final QueryParameters paramsC = newBuilder().add(aggregatingParameter(cColumn, cFilter)).build();
    // --- Check ---
    new EqualsTester().addEqualityGroup(paramsA1, paramsA2).addEqualityGroup(paramsB1, paramsB2, paramsB3).addEqualityGroup(paramsC).testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) ColumnFilter(io.spine.client.ColumnFilter) Test(org.junit.Test)

Aggregations

EqualsTester (com.google.common.testing.EqualsTester)177 Test (org.junit.Test)83 GwtIncompatible (com.google.common.annotations.GwtIncompatible)10 ParameterizedType (java.lang.reflect.ParameterizedType)10 WildcardType (java.lang.reflect.WildcardType)8 Method (java.lang.reflect.Method)7 Entry (java.util.Map.Entry)7 GenericArrayType (java.lang.reflect.GenericArrayType)6 Type (java.lang.reflect.Type)6 ImmutableList (com.google.common.collect.ImmutableList)5 Path (com.google.devtools.build.lib.vfs.Path)5 List (java.util.List)5 Set (java.util.Set)5 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)4 HashMap (java.util.HashMap)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 Label (com.google.devtools.build.lib.cmdline.Label)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3