Skip to content

Commit

Permalink
Adds some tests to the common plugin library to increase test coverag…
Browse files Browse the repository at this point in the history
…e and avoid JaCoCo coverage failures.

Signed-off-by: David Venable <[email protected]>
  • Loading branch information
dlvenable committed Nov 21, 2023
1 parent 30d88f9 commit ac7f197
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,46 @@ void different_identification_hashes_are_not_considered_equal() {

assertThat(result, is(not(equalTo(secondResult))));
}

@Test
void getKeyMap_returns_input_map() {
final Map<Object, Object> expectedKeyMap = Map.of(
UUID.randomUUID().toString(), UUID.randomUUID().toString(),
UUID.randomUUID().toString(), UUID.randomUUID().toString()
);

final IdentificationKeysHasher.IdentificationKeysMap objectUnderTest = new IdentificationKeysHasher.IdentificationKeysMap(expectedKeyMap);

assertThat(objectUnderTest.getKeyMap(), equalTo(expectedKeyMap));
}

@Test
void hashCode_returns_same_value_for_same_maps() {
final Map<Object, Object> input = Map.of(
UUID.randomUUID().toString(), UUID.randomUUID().toString(),
UUID.randomUUID().toString(), UUID.randomUUID().toString()
);

final IdentificationKeysHasher.IdentificationKeysMap objectUnderTest1 = new IdentificationKeysHasher.IdentificationKeysMap(input);
final IdentificationKeysHasher.IdentificationKeysMap objectUnderTest2 = new IdentificationKeysHasher.IdentificationKeysMap(input);

assertThat(objectUnderTest1.hashCode(), equalTo(objectUnderTest2.hashCode()));
}

@Test
void hashCode_returns_different_value_for_know_different_maps() {
final IdentificationKeysHasher.IdentificationKeysMap objectUnderTest1 = new IdentificationKeysHasher.IdentificationKeysMap(
Map.of(
"aaa", "bbb",
"ccc", "ddd"
));
final IdentificationKeysHasher.IdentificationKeysMap objectUnderTest2 = new IdentificationKeysHasher.IdentificationKeysMap(
Map.of(
"1", "22",
"3", "4"
)
);

assertThat(objectUnderTest1.hashCode(), not(equalTo(objectUnderTest2.hashCode())));
}
}

0 comments on commit ac7f197

Please sign in to comment.