diff --git a/core-java-modules/core-java-uuid/src/test/java/com/baeldung/uuid/DecodeUUIDStringFromBase64Test.java b/core-java-modules/core-java-uuid/src/test/java/com/baeldung/uuid/DecodeUUIDStringFromBase64Test.java index 043ec59fb5..c3bb715c83 100644 --- a/core-java-modules/core-java-uuid/src/test/java/com/baeldung/uuid/DecodeUUIDStringFromBase64Test.java +++ b/core-java-modules/core-java-uuid/src/test/java/com/baeldung/uuid/DecodeUUIDStringFromBase64Test.java @@ -15,16 +15,18 @@ public class DecodeUUIDStringFromBase64Test { @Test public void shouldDecodeUUIDUsingByteArrayAndBase64Decoder() { + String expectedEncodedString = "UUrxjPeTX8xsDDoxQOfGgw"; byte[] decodedBytes = Base64.getDecoder() - .decode("UUrxjPeTX8xsDDoxQOfGgw"); + .decode(expectedEncodedString); UUID uuid = convertToUUID(decodedBytes); assertEquals(originalUUID, uuid); } @Test public void shouldDecodeUUIDUsingByteBufferAndBase64UrlDecoder() { + String expectedEncodedString = "zF-T94zxSlGDxudAMToMbA"; byte[] decodedBytes = Base64.getUrlDecoder() - .decode("zF-T94zxSlGDxudAMToMbA"); + .decode(expectedEncodedString); ByteBuffer byteBuffer = ByteBuffer.wrap(decodedBytes); long mostSignificantBits = byteBuffer.getLong(); long leastSignificantBits = byteBuffer.getLong(); @@ -34,7 +36,8 @@ public class DecodeUUIDStringFromBase64Test { @Test public void shouldDecodeUUIDUsingApacheUtils() { - byte[] decodedBytes = decodeBase64("UUrxjPeTX8xsDDoxQOfGgw"); + String expectedEncodedString = "UUrxjPeTX8xsDDoxQOfGgw"; + byte[] decodedBytes = decodeBase64(expectedEncodedString); UUID uuid = Conversion.byteArrayToUuid(decodedBytes, 0); assertEquals(originalUUID, uuid); } diff --git a/core-java-modules/core-java-uuid/src/test/java/com/baeldung/uuid/EncodeUUIDToBase64StringTest.java b/core-java-modules/core-java-uuid/src/test/java/com/baeldung/uuid/EncodeUUIDToBase64StringTest.java index cef80cdc24..19c220faf7 100644 --- a/core-java-modules/core-java-uuid/src/test/java/com/baeldung/uuid/EncodeUUIDToBase64StringTest.java +++ b/core-java-modules/core-java-uuid/src/test/java/com/baeldung/uuid/EncodeUUIDToBase64StringTest.java @@ -15,27 +15,30 @@ public class EncodeUUIDToBase64StringTest { @Test public void shouldEncodeUUIDUsingByteArrayAndBase64Encoder() { + String expectedEncodedString = "UUrxjPeTX8xsDDoxQOfGgw"; byte[] uuidBytes = convertToByteArray(originalUUID); String encodedUUID = Base64.getEncoder().withoutPadding() .encodeToString(uuidBytes); - assertEquals("UUrxjPeTX8xsDDoxQOfGgw", encodedUUID); + assertEquals(expectedEncodedString, encodedUUID); } @Test public void shouldEncodeUUIDUsingByteBufferAndBase64UrlEncoder() { + String expectedEncodedString = "zF-T94zxSlGDxudAMToMbA"; ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]); byteBuffer.putLong(originalUUID.getMostSignificantBits()); byteBuffer.putLong(originalUUID.getLeastSignificantBits()); String encodedUUID = Base64.getUrlEncoder().withoutPadding() .encodeToString(byteBuffer.array()); - assertEquals("zF-T94zxSlGDxudAMToMbA", encodedUUID); + assertEquals(expectedEncodedString, encodedUUID); } @Test public void shouldEncodeUUIDUsingApacheUtils() { + String expectedEncodedString = "UUrxjPeTX8xsDDoxQOfGgw"; byte[] bytes = Conversion.uuidToByteArray(originalUUID, new byte[16], 0, 16); String encodedUUID = encodeBase64URLSafeString(bytes); - assertEquals("UUrxjPeTX8xsDDoxQOfGgw", encodedUUID); + assertEquals(expectedEncodedString, encodedUUID); } private byte[] convertToByteArray(UUID uuid) {