diff options
author | 2020-04-17 14:29:01 +0200 | |
---|---|---|
committer | 2020-04-17 14:29:01 +0200 | |
commit | b411da406772fceea4b11f257e515258073d5f1b (patch) | |
tree | b579a8d764cf0e28228058389ecf68dc4a2145dd /pnfsimulator | |
parent | 8566d36ed85a784d4f552f4b0e0dffc472deca34 (diff) |
Fix sonar issue KeywordsValueProviderTest
Issue-ID: INT-1517
Signed-off-by: Edyta Krukowska <edyta.krukowska@nokia.com>
Change-Id: I092e792087463e7331549bb14d0bc4a7f550b342
Diffstat (limited to 'pnfsimulator')
-rw-r--r-- | pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/KeywordsValueProviderTest.java | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/KeywordsValueProviderTest.java b/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/KeywordsValueProviderTest.java index 73e4c31..ac54237 100644 --- a/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/KeywordsValueProviderTest.java +++ b/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/KeywordsValueProviderTest.java @@ -25,6 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.onap.pnfsimulator.simulator.KeywordsValueProvider.DEFAULT_STRING_LENGTH; import java.util.Random; + import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; @@ -33,49 +34,49 @@ class KeywordsValueProviderTest { @RepeatedTest(10) void randomLimitedStringTest() { String supplierResult = KeywordsValueProvider.getRandomLimitedString().apply(); - assertEquals(supplierResult.length(), DEFAULT_STRING_LENGTH); + assertEquals(DEFAULT_STRING_LENGTH, supplierResult.length()); } @RepeatedTest(10) void randomStringTest() { int length = new Random().nextInt(15) + 1; String supplierResult = KeywordsValueProvider.getRandomString().apply(length); - assertEquals(supplierResult.length(), length); + assertEquals(length, supplierResult.length()); } @RepeatedTest(10) - void randomIntegerTest(){ + void randomIntegerTest() { int min = new Random().nextInt(10) + 1; int max = new Random().nextInt(1000) + 20; String supplierResult = KeywordsValueProvider.getRandomInteger().apply(min, max); - assertTrue(Integer.parseInt(supplierResult)>=min); - assertTrue(Integer.parseInt(supplierResult)<=max); + assertTrue(Integer.parseInt(supplierResult) >= min); + assertTrue(Integer.parseInt(supplierResult) <= max); } @Test - void randomIntegerContainsMaximalAndMinimalValuesTest(){ + void randomIntegerContainsMaximalAndMinimalValuesTest() { int anyNumber = new Random().nextInt(10) + 1; String supplierResult = KeywordsValueProvider.getRandomInteger().apply(anyNumber, anyNumber); assertEquals(Integer.parseInt(supplierResult), anyNumber); } @Test - void randomIntegerFromNegativeRangeTest(){ + void randomIntegerFromNegativeRangeTest() { String supplierResult = KeywordsValueProvider.getRandomInteger().apply(-20, -20); assertEquals(Integer.parseInt(supplierResult), -20); } @RepeatedTest(10) - void randomIntegerFromParametersWithDifferentOrdersTest(){ + void randomIntegerFromParametersWithDifferentOrdersTest() { String supplierResult = KeywordsValueProvider.getRandomInteger().apply(-20, -10); - assertTrue(Integer.parseInt(supplierResult)>=-20); - assertTrue(Integer.parseInt(supplierResult)<=-10); + assertTrue(Integer.parseInt(supplierResult) >= -20); + assertTrue(Integer.parseInt(supplierResult) <= -10); } @RepeatedTest(10) - void epochSecondGeneratedInCorrectFormatTest(){ + void epochSecondGeneratedInCorrectFormatTest() { String supplierResult = KeywordsValueProvider.getEpochSecond().apply(); - assertEquals(supplierResult.length(), 10); + assertEquals(10, supplierResult.length()); } } |