From e0ca0be76af2e7b8a96a5d4e1c5165b1a0967b9d Mon Sep 17 00:00:00 2001 From: "@hangga" Date: Wed, 1 Nov 2023 16:27:09 +0700 Subject: [PATCH] positive --- .../uuid/UUIDPositiveLongGeneratorUnitTest.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/core-java-modules/core-java-uuid/src/test/java/com/baeldung/uuid/UUIDPositiveLongGeneratorUnitTest.java b/core-java-modules/core-java-uuid/src/test/java/com/baeldung/uuid/UUIDPositiveLongGeneratorUnitTest.java index 5847ef44fb..cd538af523 100644 --- a/core-java-modules/core-java-uuid/src/test/java/com/baeldung/uuid/UUIDPositiveLongGeneratorUnitTest.java +++ b/core-java-modules/core-java-uuid/src/test/java/com/baeldung/uuid/UUIDPositiveLongGeneratorUnitTest.java @@ -28,33 +28,27 @@ public class UUIDPositiveLongGeneratorUnitTest { private void printTableHeader() { - logger.info(String.format("%-30s %-15s %-15s %-15s %-15s", "Approach", "collisions", "negatives", "collision", "negative")); - logger.info(String.format("%-30s %-15s %-15s %-15s %-15s", "(method name)", "count", "count", "probability", "probability")); - logger.info("--------------------------------------------------------------------------------------------"); + logger.info(String.format("%-30s %-15s %-15s", "Approach(method name)", "collisions", "probability")); + logger.info("-----------------------------------------------------------------------"); } - private void printOutput(String method, int collisionsCount, int negativeCount, double collisionsProbability, double negativeProbability) { + private void printOutput(String method, int collisionsCount, double collisionsProbability) { DecimalFormat decimalFormat = new DecimalFormat("#.#####"); - logger.info(String.format("%-30s %-15s %-15s %-15s %-15s", method, collisionsCount, negativeCount, decimalFormat.format(collisionsProbability), decimalFormat.format(negativeProbability))); + logger.info(String.format("%-30s %-15s %-15s", method, collisionsCount, decimalFormat.format(collisionsProbability))); } private void collisionCheck(Method method) throws InvocationTargetException, IllegalAccessException { Set uniqueValues = new HashSet<>(); int collisions = 0; - int negative = 0; for (int i = 0; i < n; i++) { long uniqueValue = (long) method.invoke(uuidLongGenerator); if (!uniqueValues.add(uniqueValue)) { collisions++; } - if (uniqueValue < 0) { - negative++; - } } double collisionsProbability = (double) collisions / n; - double negativeProbability = (double) negative / n; - printOutput(method.getName(), collisions, negative, collisionsProbability, negativeProbability); + printOutput(method.getName(), collisions, collisionsProbability); assertThat(collisionsProbability).isLessThan(COLLISION_THRESHOLD); } }