use of io.servicetalk.client.api.partition.PartitionAttributes in project servicetalk by apple.
the class DefaultPartitionAttributesBuilderTest method equalsAndHashCode.
@Test
void equalsAndHashCode() {
DefaultPartitionAttributesBuilder builder = new DefaultPartitionAttributesBuilder(3);
builder.add(SHARD_KEY, DEFAULT_SHARD);
builder.add(DC_KEY, DEFAULT_DC);
builder.add(MAIN_KEY, true);
PartitionAttributes partitionAttributes = builder.build();
builder = new DefaultPartitionAttributesBuilder(3);
builder.add(DC_KEY, DEFAULT_DC);
builder.add(MAIN_KEY, true);
builder.add(SHARD_KEY, DEFAULT_SHARD);
PartitionAttributes partitionAttributes2 = builder.build();
assertEquals(partitionAttributes, partitionAttributes2);
assertEquals(partitionAttributes.hashCode(), partitionAttributes2.hashCode());
assertSize(partitionAttributes, 3);
assertEquals(DEFAULT_SHARD, partitionAttributes2.get(SHARD_KEY));
assertEquals(DEFAULT_DC, partitionAttributes2.get(DC_KEY));
assertEquals(true, partitionAttributes2.get(MAIN_KEY));
assertSize(partitionAttributes2, 3);
assertEquals(true, partitionAttributes2.get(MAIN_KEY));
assertEquals(DEFAULT_DC, partitionAttributes2.get(DC_KEY));
assertEquals(DEFAULT_SHARD, partitionAttributes2.get(SHARD_KEY));
}
use of io.servicetalk.client.api.partition.PartitionAttributes in project servicetalk by apple.
the class DefaultPartitionAttributesBuilderTest method addFourItemsSortedCorrectlyB.
@Test
void addFourItemsSortedCorrectlyB() {
PartitionAttributesBuilder builder = new DefaultPartitionAttributesBuilder(4);
builder.add(SHARD_KEY, DEFAULT_SHARD);
builder.add(MAIN_KEY, false);
builder.add(DC_KEY, DEFAULT_DC);
builder.add(OTHER_KEY, 2);
PartitionAttributes partitionAttributes = builder.build();
assertSize(partitionAttributes, 4);
assertEquals(DEFAULT_SHARD, partitionAttributes.get(SHARD_KEY));
assertEquals(DEFAULT_DC, partitionAttributes.get(DC_KEY));
assertEquals((Integer) 2, partitionAttributes.get(OTHER_KEY));
assertEquals(false, partitionAttributes.get(MAIN_KEY));
}
Aggregations