BAEL-3589 : removed unnecessary final modifiers

This commit is contained in:
sampada 2019-12-16 22:50:51 +05:30
parent 32bae4023b
commit e68dd13723
1 changed files with 26 additions and 26 deletions

View File

@ -14,38 +14,38 @@ public class RandomStringsUnitTest {
@Test @Test
public void givenUsingPlainJava_whenGeneratingRandomStringUnbounded_thenCorrect() { public void givenUsingPlainJava_whenGeneratingRandomStringUnbounded_thenCorrect() {
final byte[] array = new byte[7]; // length is bounded by 7 byte[] array = new byte[7]; // length is bounded by 7
new Random().nextBytes(array); new Random().nextBytes(array);
final String generatedString = new String(array, Charset.forName("UTF-8")); String generatedString = new String(array, Charset.forName("UTF-8"));
LOG.debug(generatedString); LOG.debug(generatedString);
} }
@Test @Test
public void givenUsingPlainJava_whenGeneratingRandomStringBounded_thenCorrect() { public void givenUsingPlainJava_whenGeneratingRandomStringBounded_thenCorrect() {
final int leftLimit = 97; // letter 'a' int leftLimit = 97; // letter 'a'
final int rightLimit = 122; // letter 'z' int rightLimit = 122; // letter 'z'
final int targetStringLength = 10; int targetStringLength = 10;
final Random random = new Random(); Random random = new Random();
final StringBuilder buffer = new StringBuilder(targetStringLength); StringBuilder buffer = new StringBuilder(targetStringLength);
for (int i = 0; i < targetStringLength; i++) { for (int i = 0; i < targetStringLength; i++) {
final int randomLimitedInt = leftLimit + (int) (random.nextFloat() * (rightLimit - leftLimit + 1)); int randomLimitedInt = leftLimit + (int) (random.nextFloat() * (rightLimit - leftLimit + 1));
buffer.append((char) randomLimitedInt); buffer.append((char) randomLimitedInt);
} }
final String generatedString = buffer.toString(); String generatedString = buffer.toString();
LOG.debug(generatedString); LOG.debug(generatedString);
} }
@Test @Test
public void givenUsingJava8_whenGeneratingRandomAlphabeticString_thenCorrect() { public void givenUsingJava8_whenGeneratingRandomAlphabeticString_thenCorrect() {
final int leftLimit = 97; // letter 'a' int leftLimit = 97; // letter 'a'
final int rightLimit = 122; // letter 'z' int rightLimit = 122; // letter 'z'
final int targetStringLength = 10; int targetStringLength = 10;
final Random random = new Random(); Random random = new Random();
final String generatedString = random.ints(leftLimit, rightLimit + 1) String generatedString = random.ints(leftLimit, rightLimit + 1)
.limit(targetStringLength) .limit(targetStringLength)
.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append) .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
.toString(); .toString();
@ -55,12 +55,12 @@ public class RandomStringsUnitTest {
@Test @Test
public void givenUsingJava8_whenGeneratingRandomAlphanumericString_thenCorrect() { public void givenUsingJava8_whenGeneratingRandomAlphanumericString_thenCorrect() {
final int leftLimit = 48; // numeral '0' int leftLimit = 48; // numeral '0'
final int rightLimit = 122; // letter 'z' int rightLimit = 122; // letter 'z'
final int targetStringLength = 10; int targetStringLength = 10;
final Random random = new Random(); Random random = new Random();
final String generatedString = random.ints(leftLimit, rightLimit + 1) String generatedString = random.ints(leftLimit, rightLimit + 1)
.filter(i -> (i <= 57 || i >= 65) && (i <= 90 || i >= 97)) .filter(i -> (i <= 57 || i >= 65) && (i <= 90 || i >= 97))
.limit(targetStringLength) .limit(targetStringLength)
.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append) .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
@ -71,31 +71,31 @@ public class RandomStringsUnitTest {
@Test @Test
public void givenUsingApache_whenGeneratingRandomString_thenCorrect() { public void givenUsingApache_whenGeneratingRandomString_thenCorrect() {
final String generatedString = RandomStringUtils.random(10); String generatedString = RandomStringUtils.random(10);
LOG.debug(generatedString); LOG.debug(generatedString);
} }
@Test @Test
public void givenUsingApache_whenGeneratingRandomAlphabeticString_thenCorrect() { public void givenUsingApache_whenGeneratingRandomAlphabeticString_thenCorrect() {
final String generatedString = RandomStringUtils.randomAlphabetic(10); String generatedString = RandomStringUtils.randomAlphabetic(10);
LOG.debug(generatedString); LOG.debug(generatedString);
} }
@Test @Test
public void givenUsingApache_whenGeneratingRandomAlphanumericString_thenCorrect() { public void givenUsingApache_whenGeneratingRandomAlphanumericString_thenCorrect() {
final String generatedString = RandomStringUtils.randomAlphanumeric(10); String generatedString = RandomStringUtils.randomAlphanumeric(10);
LOG.debug(generatedString); LOG.debug(generatedString);
} }
@Test @Test
public void givenUsingApache_whenGeneratingRandomStringBounded_thenCorrect() { public void givenUsingApache_whenGeneratingRandomStringBounded_thenCorrect() {
final int length = 10; int length = 10;
final boolean useLetters = true; boolean useLetters = true;
final boolean useNumbers = false; boolean useNumbers = false;
final String generatedString = RandomStringUtils.random(length, useLetters, useNumbers); String generatedString = RandomStringUtils.random(length, useLetters, useNumbers);
LOG.debug(generatedString); LOG.debug(generatedString);
} }