Search in sources :

Example 21 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 22 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)

Example 23 with EqualsTester

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

the class StorageSpecShould method provide_equals_based_on_values.

@Test
public void provide_equals_based_on_values() {
    final BoundedContextName bcName = newName(getClass().getName());
    new EqualsTester().addEqualityGroup(StorageSpec.of(bcName, TypeUrl.of(StringValue.class), String.class), StorageSpec.of(bcName, TypeUrl.of(StringValue.class), String.class)).addEqualityGroup(StorageSpec.of(bcName, TypeUrl.of(Timestamp.class), Integer.class), StorageSpec.of(bcName, TypeUrl.of(Timestamp.class), Integer.class)).testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Timestamp(com.google.protobuf.Timestamp) BoundedContextName(io.spine.core.BoundedContextName) Test(org.junit.Test)

Example 24 with EqualsTester

use of com.google.common.testing.EqualsTester in project instrumentation-java by census-instrumentation.

the class DistributionAggregationTest method testDistributionAggregationEquals.

@Test
public void testDistributionAggregationEquals() {
    List<Long> buckets = Arrays.asList(1L, 2L, 3L);
    new EqualsTester().addEqualityGroup(DistributionAggregation.create(10, 5.0, 30.0, Range.create(1.0, 5.0), TAGS), DistributionAggregation.create(10, 5.0, 30.0, Range.create(1.0, 5.0), TAGS)).addEqualityGroup(DistributionAggregation.create(10, 5.0, 30.0, Range.create(1.0, 5.0), TAGS, buckets), DistributionAggregation.create(10, 5.0, 30.0, Range.create(1.0, 5.0), TAGS, buckets)).testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 25 with EqualsTester

use of com.google.common.testing.EqualsTester in project instrumentation-java by census-instrumentation.

the class DistributionTest method testDistributionEquals.

@Test
public void testDistributionEquals() {
    BucketBoundaries boundaries = BucketBoundaries.create(Arrays.asList(-10.0, 10.0));
    MutableDistribution mDistribution = MutableDistribution.create(boundaries);
    mDistribution.add(1);
    mDistribution.add(-1);
    Distribution distribution1 = Distribution.create(mDistribution);
    Distribution distribution2 = Distribution.create(mDistribution);
    mDistribution.add(0);
    Distribution distribution3 = Distribution.create(mDistribution);
    new EqualsTester().addEqualityGroup(distribution1, distribution2).addEqualityGroup(distribution3).testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Aggregations

EqualsTester (com.google.common.testing.EqualsTester)225 Test (org.junit.Test)118 GwtIncompatible (com.google.common.annotations.GwtIncompatible)10 ParameterizedType (java.lang.reflect.ParameterizedType)10 Test (org.junit.jupiter.api.Test)9 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 HashMap (java.util.HashMap)6 ImmutableList (com.google.common.collect.ImmutableList)5 Path (com.google.devtools.build.lib.vfs.Path)5 List (java.util.List)5 DisplayName (org.junit.jupiter.api.DisplayName)5 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)4 HashSet (java.util.HashSet)4 Set (java.util.Set)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 Label (com.google.devtools.build.lib.cmdline.Label)3