From bd1239c699d14050e5f3bca84138e775425a42ee Mon Sep 17 00:00:00 2001 From: "ICKostiantyn.Ivanov" Date: Wed, 17 Jan 2024 11:18:45 +0100 Subject: [PATCH] BAEL-7453 - Fix modifiers and naming for test classes fields --- ...ByteArrayToPrimitiveByteArrayUnitTest.java | 24 +++++++-------- ...PrimitiveByteArrayToByteArrayUnitTest.java | 30 +++++++++---------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/core-java-modules/core-java-arrays-convert/src/test/java/com/baeldung/array/conversions/ByteArrayToPrimitiveByteArrayUnitTest.java b/core-java-modules/core-java-arrays-convert/src/test/java/com/baeldung/array/conversions/ByteArrayToPrimitiveByteArrayUnitTest.java index 89c4ae7da2..edad1026f1 100644 --- a/core-java-modules/core-java-arrays-convert/src/test/java/com/baeldung/array/conversions/ByteArrayToPrimitiveByteArrayUnitTest.java +++ b/core-java-modules/core-java-arrays-convert/src/test/java/com/baeldung/array/conversions/ByteArrayToPrimitiveByteArrayUnitTest.java @@ -5,34 +5,34 @@ import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; class ByteArrayToPrimitiveByteArrayUnitTest { - public static byte[] expectedArrayValues = {65, 66, 67, 68}; - public static Byte[] byteArray = {65, 66, 67, 68}; + private static final byte[] EXPECTED_ARRAY_VALUES = {65, 66, 67, 68}; + private static final Byte[] BYTE_ARRAY = {65, 66, 67, 68}; @Test void givenByteArray_whenConvertingUsingByteValue_thenGiveExpectedResult() { - byte[] newByteArray = new byte[byteArray.length]; - for (int i = 0; i < byteArray.length; i++) { - newByteArray[i] = byteArray[i].byteValue(); + byte[] newByteArray = new byte[BYTE_ARRAY.length]; + for (int i = 0; i < BYTE_ARRAY.length; i++) { + newByteArray[i] = BYTE_ARRAY[i].byteValue(); } Assertions.assertThat(newByteArray) - .containsExactly(expectedArrayValues); + .containsExactly(EXPECTED_ARRAY_VALUES); } @Test void givenByteArray_whenConvertingUsingUnboxing_thenGiveExpectedResult() { - byte[] newByteArray = new byte[byteArray.length]; - for (int i = 0; i < byteArray.length; i++) { - newByteArray[i] = byteArray[i]; + byte[] newByteArray = new byte[BYTE_ARRAY.length]; + for (int i = 0; i < BYTE_ARRAY.length; i++) { + newByteArray[i] = BYTE_ARRAY[i]; } Assertions.assertThat(newByteArray) - .containsExactly(expectedArrayValues); + .containsExactly(EXPECTED_ARRAY_VALUES); } @Test void givenByteArray_whenConvertingArrayUtils_thenGiveExpectedResult() { - byte[] newByteArray = ArrayUtils.toPrimitive(byteArray); + byte[] newByteArray = ArrayUtils.toPrimitive(BYTE_ARRAY); Assertions.assertThat(newByteArray) - .containsExactly(expectedArrayValues); + .containsExactly(EXPECTED_ARRAY_VALUES); } } diff --git a/core-java-modules/core-java-arrays-convert/src/test/java/com/baeldung/array/conversions/PrimitiveByteArrayToByteArrayUnitTest.java b/core-java-modules/core-java-arrays-convert/src/test/java/com/baeldung/array/conversions/PrimitiveByteArrayToByteArrayUnitTest.java index 06f8fc2fe4..a04ff9583c 100644 --- a/core-java-modules/core-java-arrays-convert/src/test/java/com/baeldung/array/conversions/PrimitiveByteArrayToByteArrayUnitTest.java +++ b/core-java-modules/core-java-arrays-convert/src/test/java/com/baeldung/array/conversions/PrimitiveByteArrayToByteArrayUnitTest.java @@ -7,43 +7,43 @@ import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; class PrimitiveByteArrayToByteArrayUnitTest { - public static byte[] primitiveByteArray = {65, 66, 67, 68}; - public static Byte[] expectedArrayValues = {65, 66, 67, 68}; + private static final byte[] PRIMITIVE_BYTE_ARRAY = {65, 66, 67, 68}; + private static final Byte[] EXPECTED_ARRAY_VALUES = {65, 66, 67, 68}; @Test void givenPrimitiveByteArray_whenConvertingUsingByteValueOf_thenGiveExpectedResult() { - Byte[] newByteArray = new Byte[primitiveByteArray.length]; - for (int i = 0; i < primitiveByteArray.length; i++) { - newByteArray[i] = Byte.valueOf(primitiveByteArray[i]); + Byte[] newByteArray = new Byte[PRIMITIVE_BYTE_ARRAY.length]; + for (int i = 0; i < PRIMITIVE_BYTE_ARRAY.length; i++) { + newByteArray[i] = Byte.valueOf(PRIMITIVE_BYTE_ARRAY[i]); } Assertions.assertThat(newByteArray) - .containsExactly(expectedArrayValues); + .containsExactly(EXPECTED_ARRAY_VALUES); } @Test void givenPrimitiveByteArray_whenConvertingUsingAutoboxing_thenGiveExpectedResult() { - Byte[] newByteArray = new Byte[primitiveByteArray.length]; - for (int i = 0; i < primitiveByteArray.length; i++) { - newByteArray[i] = primitiveByteArray[i]; + Byte[] newByteArray = new Byte[PRIMITIVE_BYTE_ARRAY.length]; + for (int i = 0; i < PRIMITIVE_BYTE_ARRAY.length; i++) { + newByteArray[i] = PRIMITIVE_BYTE_ARRAY[i]; } Assertions.assertThat(newByteArray) - .containsExactly(expectedArrayValues); + .containsExactly(EXPECTED_ARRAY_VALUES); } @Test void givenPrimitiveByteArray_whenConvertingUsingAutoboxingAndArraysSetAll_thenGiveExpectedResult() { - Byte[] newByteArray = new Byte[primitiveByteArray.length]; - Arrays.setAll(newByteArray, n -> primitiveByteArray[n]); + Byte[] newByteArray = new Byte[PRIMITIVE_BYTE_ARRAY.length]; + Arrays.setAll(newByteArray, n -> PRIMITIVE_BYTE_ARRAY[n]); Assertions.assertThat(newByteArray) - .containsExactly(expectedArrayValues); + .containsExactly(EXPECTED_ARRAY_VALUES); } @Test void givenPrimitiveByteArray_whenConvertingUsingArrayUtils_thenGiveExpectedResult() { - Byte[] newByteArray = ArrayUtils.toObject(primitiveByteArray); + Byte[] newByteArray = ArrayUtils.toObject(PRIMITIVE_BYTE_ARRAY); Assertions.assertThat(newByteArray) - .containsExactly(expectedArrayValues); + .containsExactly(EXPECTED_ARRAY_VALUES); } }