diff options
Diffstat (limited to 'pnfsimulator/src/test/java/org')
4 files changed, 35 insertions, 32 deletions
diff --git a/pnfsimulator/src/test/java/org/onap/pnfsimulator/filesystem/WatcherEventProcessorTest.java b/pnfsimulator/src/test/java/org/onap/pnfsimulator/filesystem/WatcherEventProcessorTest.java index 42ed4d3..9dfa002 100644 --- a/pnfsimulator/src/test/java/org/onap/pnfsimulator/filesystem/WatcherEventProcessorTest.java +++ b/pnfsimulator/src/test/java/org/onap/pnfsimulator/filesystem/WatcherEventProcessorTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,6 +31,7 @@ import java.time.Instant; import java.util.Collections; import java.util.HashMap; import java.util.Optional; + import org.bson.Document; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -84,18 +85,18 @@ class WatcherEventProcessorTest { } private void verifyPersistedValue() { - Assertions.assertEquals(storage.getAll().size(), 1); + Assertions.assertEquals(1, storage.getAll().size()); Optional<Template> templateFromStorage = storage.get("test1.json"); if (templateFromStorage.isPresent()) { Template retrievedTemplate = templateFromStorage.get(); Document templateContent = retrievedTemplate.getContent(); Document flatContent = retrievedTemplate.getFlatContent(); - Assertions.assertEquals(templateContent.getString("field1"), "value1"); - Assertions.assertEquals(templateContent.getInteger("field2", 0), 2); - Assertions.assertEquals(flatContent.getInteger(":nested:key1[0]", 0), 1); - Assertions.assertEquals(flatContent.getInteger(":nested:key1[1]", 0), 2); - Assertions.assertEquals(flatContent.getInteger(":nested:key1[2]", 0), 3); - Assertions.assertEquals(flatContent.getString(":nested:key2"), "sampleValue2"); + Assertions.assertEquals("value1", templateContent.getString("field1")); + Assertions.assertEquals(2, templateContent.getInteger("field2", 0)); + Assertions.assertEquals(1, flatContent.getInteger(":nested:key1[0]", 0)); + Assertions.assertEquals(2, flatContent.getInteger(":nested:key1[1]", 0)); + Assertions.assertEquals(3, flatContent.getInteger(":nested:key1[2]", 0)); + Assertions.assertEquals("sampleValue2", flatContent.getString(":nested:key2")); } else { fail(); } @@ -113,7 +114,7 @@ class WatcherEventProcessorTest { Mockito.when(watchEvent.kind()).thenReturn(StandardWatchEventKinds.ENTRY_DELETE); WatcherEventProcessor.process(watchEvent, storage, templatesDir); // then - Assertions.assertEquals(storage.getAll().size(), 0); + Assertions.assertEquals(0, storage.getAll().size()); } private void initStubs() { diff --git a/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/util/ResponseBuilderTest.java b/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/util/ResponseBuilderTest.java index 0d62ee9..66187bc 100644 --- a/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/util/ResponseBuilderTest.java +++ b/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/util/ResponseBuilderTest.java @@ -25,6 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import java.util.Map; + import org.junit.jupiter.api.Test; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -39,8 +40,8 @@ class ResponseBuilderTest { ResponseEntity responseEntity = ResponseBuilder.status(SAMPLE_STATUS).build(); assertAll( - () -> assertEquals(responseEntity.getStatusCode(), SAMPLE_STATUS), - () -> assertNull(responseEntity.getBody()) + () -> assertEquals(SAMPLE_STATUS, responseEntity.getStatusCode()), + () -> assertNull(responseEntity.getBody()) ); } @@ -49,15 +50,15 @@ class ResponseBuilderTest { String key = "key"; String value = "value"; ResponseEntity response = ResponseBuilder - .status(SAMPLE_STATUS) - .put(key, value) - .build(); + .status(SAMPLE_STATUS) + .put(key, value) + .build(); Map<String, Object> body = (Map<String, Object>) response.getBody(); assertAll( - () -> assertEquals(SAMPLE_STATUS, response.getStatusCode()), - () -> assertEquals(value, body.get(key)) + () -> assertEquals(SAMPLE_STATUS, response.getStatusCode()), + () -> assertEquals(value, body.get(key)) ); } 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()); } } diff --git a/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SslSupportLevelTest.java b/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SslSupportLevelTest.java index ff41c44..3a7dbf2 100644 --- a/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SslSupportLevelTest.java +++ b/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SslSupportLevelTest.java @@ -35,17 +35,17 @@ class SslSupportLevelTest { @Test void testShouldReturnAlwaysTrustSupportLevelForHttpsUrl() throws MalformedURLException { SslSupportLevel actualSupportLevel = SslSupportLevel.getSupportLevelBasedOnProtocol(HTTPS_URL); - assertEquals(actualSupportLevel, SslSupportLevel.ALWAYS_TRUST); + assertEquals(SslSupportLevel.ALWAYS_TRUST, actualSupportLevel); } @Test void testShouldReturnNoneSupportLevelForHttpUrl() throws MalformedURLException { SslSupportLevel actualSupportLevel = SslSupportLevel.getSupportLevelBasedOnProtocol(HTTP_URL); - assertEquals(actualSupportLevel, SslSupportLevel.NONE); + assertEquals(SslSupportLevel.NONE, actualSupportLevel); } @Test - void testShouldRaiseExceptionWhenInvalidUrlPassed(){ + void testShouldRaiseExceptionWhenInvalidUrlPassed() { assertThrows(MalformedURLException.class, () -> SslSupportLevel.getSupportLevelBasedOnProtocol("http://bla:VES-PORT/")); } |