package info.frostfs.sdk; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; public class ArrayHelperTest { @Test void concatTest_success() { //Given var startBytes = new byte[]{1, 2, 3, 4, 5}; var endBytes = new byte[]{6, 7, 8, 9}; //When var result = ArrayHelper.concat(startBytes, endBytes); //Then assertThat(startBytes).hasSize(5); assertThat(endBytes).hasSize(4); assertThat(result).hasSize(9).startsWith(startBytes).endsWith(endBytes); } @Test void concatTest_endArrayIsEmpty() { //Given var startBytes = new byte[]{1, 2, 3, 4, 5}; var endBytes = new byte[]{}; //When var result = ArrayHelper.concat(startBytes, endBytes); //Then assertThat(startBytes).hasSize(5); assertThat(endBytes).hasSize(0); assertThat(result).hasSize(5).startsWith(startBytes); } @Test void concatTest_startArrayIsEmpty() { //Given var startBytes = new byte[]{}; var endBytes = new byte[]{6, 7, 8, 9}; //When var result = ArrayHelper.concat(startBytes, endBytes); //Then assertThat(startBytes).hasSize(0); assertThat(endBytes).hasSize(4); assertThat(result).hasSize(4).startsWith(endBytes); } @Test void concatTest_givenParamsIsNull() { //Given var startBytes = new byte[]{1, 2, 3, 4, 5}; var endBytes = new byte[]{6, 7, 8, 9}; //When + Then assertThrows(IllegalArgumentException.class, () -> ArrayHelper.concat(startBytes, null)); assertThrows(IllegalArgumentException.class, () -> ArrayHelper.concat(null, endBytes)); assertThrows(IllegalArgumentException.class, () -> ArrayHelper.concat(null, null)); } }