diff options
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient')
-rw-r--r-- | plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumerTest.java (renamed from plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java) | 54 | ||||
-rw-r--r-- | plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java | 83 | ||||
-rw-r--r-- | plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java | 53 |
3 files changed, 86 insertions, 104 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumerTest.java index 61155c8cf..b3a6bca06 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConsumerTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation. + * Modifications Copyright (C) 2019-2020, 2023-2024 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,9 +24,10 @@ package org.onap.policy.apex.plugins.event.carrier.restclient; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.awaitility.Awaitility.await; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import jakarta.ws.rs.client.Client; import jakarta.ws.rs.client.Invocation.Builder; @@ -35,22 +36,23 @@ import jakarta.ws.rs.core.Response; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.util.concurrent.TimeUnit; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.policy.apex.service.engine.event.ApexEventException; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode; /** - * This class tests the ApexRestClientConusmer class. - * + * This class tests the ApexRestClientConsumer class. */ -@RunWith(MockitoJUnitRunner.class) -public class ApexRestClientConusmerTest { +@ExtendWith(MockitoExtension.class) +class ApexRestClientConsumerTest { private final PrintStream stdout = System.out; @Mock @@ -65,13 +67,13 @@ public class ApexRestClientConusmerTest { @Mock private Response responseMock; - @After - public void after() { + @AfterEach + void after() { System.setOut(stdout); } @Test - public void testApexRestClientConsumerErrors() throws ApexEventException { + void testApexRestClientConsumerErrors() throws ApexEventException { ApexRestClientConsumer arcc = new ApexRestClientConsumer(); assertNotNull(arcc); @@ -99,7 +101,7 @@ public class ApexRestClientConusmerTest { assertEquals("RestClientConsumer", arcc.getName()); arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null); - assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); + assertNull(arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); rcctp.setUrl("http://some.place.that.does.not/exist"); Mockito.doReturn(builderMock).when(targetMock).request("application/json"); @@ -120,7 +122,7 @@ public class ApexRestClientConusmerTest { } @Test - public void testApexRestClientConsumerHttpError() throws ApexEventException { + void testApexRestClientConsumerHttpError() throws ApexEventException { ApexRestClientConsumer arcc = new ApexRestClientConsumer(); assertNotNull(arcc); @@ -139,7 +141,7 @@ public class ApexRestClientConusmerTest { assertEquals("RestClientConsumer", arcc.getName()); arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null); - assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); + assertNull(arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); Mockito.doReturn(Response.Status.BAD_REQUEST.getStatusCode()).when(responseMock).getStatus(); Mockito.doReturn(responseMock).when(builderMock).get(); @@ -159,7 +161,7 @@ public class ApexRestClientConusmerTest { } @Test - public void testApexRestClientConsumerJsonError() throws ApexEventException { + void testApexRestClientConsumerJsonError() throws ApexEventException { ApexRestClientConsumer arcc = new ApexRestClientConsumer(); assertNotNull(arcc); @@ -175,7 +177,7 @@ public class ApexRestClientConusmerTest { arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null); - assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); + assertNull(arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); rcctp.setUrl("http://some.place.that.does.not/exist"); Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus(); @@ -197,7 +199,7 @@ public class ApexRestClientConusmerTest { } @Test - public void testApexRestClientConsumerJsonEmpty() throws ApexEventException { + void testApexRestClientConsumerJsonEmpty() throws ApexEventException { ApexRestClientConsumer arcc = new ApexRestClientConsumer(); assertNotNull(arcc); @@ -214,7 +216,7 @@ public class ApexRestClientConusmerTest { arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null); - assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); + assertNull(arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); rcctp.setUrl("http://some.place.that.does.not/exist"); Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus(); @@ -242,7 +244,7 @@ public class ApexRestClientConusmerTest { } @Test - public void testApexRestClientConsumerJsonOk() throws ApexEventException { + void testApexRestClientConsumerJsonOk() throws ApexEventException { ApexRestClientConsumer arcc = new ApexRestClientConsumer(); assertNotNull(arcc); @@ -259,7 +261,7 @@ public class ApexRestClientConusmerTest { arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null); - assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); + assertNull(arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); rcctp.setUrl("http://some.place.that.does.not/exist"); Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus(); @@ -278,7 +280,7 @@ public class ApexRestClientConusmerTest { } @Test - public void testApexRestClientConsumerInvalidStatusCode() throws ApexEventException { + void testApexRestClientConsumerInvalidStatusCode() throws ApexEventException { ApexRestClientConsumer arcc = new ApexRestClientConsumer(); assertNotNull(arcc); @@ -295,7 +297,7 @@ public class ApexRestClientConusmerTest { arcc.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null); - assertEquals(null, arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); + assertNull(arcc.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); rcctp.setUrl("http://some.place.that.does.not/exist"); Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus(); diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java index cc5ebbb9f..ec454af00 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation. + * Modifications Copyright (C) 2019-2020, 2023-2024 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,19 +23,23 @@ package org.onap.policy.apex.plugins.event.carrier.restclient; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import jakarta.ws.rs.client.Client; import jakarta.ws.rs.client.Invocation.Builder; import jakarta.ws.rs.client.WebTarget; import jakarta.ws.rs.core.Response; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.policy.apex.service.engine.event.ApexEventConsumer; import org.onap.policy.apex.service.engine.event.ApexEventException; import org.onap.policy.apex.service.engine.event.SynchronousEventCache; @@ -47,8 +51,8 @@ import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMo * Test the ApexRestClientProducer class. * */ -@RunWith(MockitoJUnitRunner.class) -public class ApexRestClientProducerTest { +@ExtendWith(MockitoExtension.class) +class ApexRestClientProducerTest { @Mock private Client httpClientMock; @@ -61,8 +65,10 @@ public class ApexRestClientProducerTest { @Mock private Response responseMock; + AutoCloseable closeable; + @Test - public void testApexRestClientProducerErrors() throws ApexEventException { + void testApexRestClientProducerErrors() throws ApexEventException { ApexRestClientProducer arcp = new ApexRestClientProducer(); assertNotNull(arcp); @@ -84,7 +90,7 @@ public class ApexRestClientProducerTest { assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.POST, rcctp.getHttpMethod()); assertEquals("RestClientConsumer", arcp.getName()); arcp.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null); - assertEquals(null, arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); + assertNull(arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); arcp.stop(); rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.POST); @@ -92,7 +98,7 @@ public class ApexRestClientProducerTest { assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.POST, rcctp.getHttpMethod()); assertEquals("RestClientConsumer", arcp.getName()); arcp.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null); - assertEquals(null, arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); + assertNull(arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); arcp.stop(); rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.PUT); @@ -100,12 +106,12 @@ public class ApexRestClientProducerTest { assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.PUT, rcctp.getHttpMethod()); assertEquals("RestClientConsumer", arcp.getName()); arcp.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, null); - assertEquals(null, arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); + assertNull(arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); arcp.stop(); } @Test - public void testApexRestClientProducerPutEvent() throws ApexEventException { + void testApexRestClientProducerPutEvent() throws ApexEventException { ApexRestClientProducer arcp = new ApexRestClientProducer(); assertNotNull(arcp); @@ -120,7 +126,7 @@ public class ApexRestClientProducerTest { rcctp.setUrl("http://some.place.that.does.not/exist"); Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus(); - Mockito.doReturn(responseMock).when(builderMock).put(Mockito.any()); + closeable = Mockito.doReturn(responseMock).when(builderMock).put(Mockito.any()); Mockito.doReturn(builderMock).when(targetMock).request("application/json"); Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any()); Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl()); @@ -131,7 +137,7 @@ public class ApexRestClientProducerTest { } @Test - public void testApexRestClientProducerPostEventFail() throws ApexEventException { + void testApexRestClientProducerPostEventFail() throws ApexEventException { ApexRestClientProducer arcp = new ApexRestClientProducer(); assertNotNull(arcp); @@ -160,7 +166,7 @@ public class ApexRestClientProducerTest { } @Test - public void testApexRestClientProducerPostEventOK() throws ApexEventException { + void testApexRestClientProducerPostEventOK() throws ApexEventException { ApexRestClientProducer arcp = new ApexRestClientProducer(); assertNotNull(arcp); @@ -179,7 +185,7 @@ public class ApexRestClientProducerTest { properties.put("tag", "exist"); properties.put("key", "that"); Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus(); - Mockito.doReturn(responseMock).when(builderMock).put(Mockito.any()); + closeable = Mockito.doReturn(responseMock).when(builderMock).put(Mockito.any()); Mockito.doReturn(builderMock).when(targetMock).request("application/json"); Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any()); Mockito.doReturn(targetMock).when(httpClientMock).target("http://some.place.that.does.not/exist"); @@ -190,7 +196,7 @@ public class ApexRestClientProducerTest { } @Test - public void testApexRestClientProducerPostEventAccepted() throws ApexEventException { + void testApexRestClientProducerPostEventAccepted() throws ApexEventException { ApexRestClientProducer arcp = new ApexRestClientProducer(); assertNotNull(arcp); @@ -219,7 +225,7 @@ public class ApexRestClientProducerTest { } @Test - public void testApexRestClientProducerPostEventCache() throws ApexEventException { + void testApexRestClientProducerPostEventCache() throws ApexEventException { ApexRestClientProducer arcp = new ApexRestClientProducer(); assertNotNull(arcp); @@ -251,39 +257,7 @@ public class ApexRestClientProducerTest { } @Test - public void testApexRestClientProducerPostEventCacheTrace() throws ApexEventException { - ApexRestClientProducer arcp = new ApexRestClientProducer(); - assertNotNull(arcp); - - EventHandlerParameters producerParameters = new EventHandlerParameters(); - RestClientCarrierTechnologyParameters rcctp = new RestClientCarrierTechnologyParameters(); - producerParameters.setCarrierTechnologyParameters(rcctp); - - rcctp.setHttpMethod(RestClientCarrierTechnologyParameters.HttpMethod.POST); - - ApexEventConsumer consumer = new ApexFileEventConsumer(); - SynchronousEventCache cache = - new SynchronousEventCache(EventHandlerPeeredMode.SYNCHRONOUS, consumer, arcp, 1000); - arcp.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS, cache); - assertEquals(cache, arcp.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS)); - arcp.init("RestClientConsumer", producerParameters); - assertEquals(RestClientCarrierTechnologyParameters.HttpMethod.POST, rcctp.getHttpMethod()); - assertEquals("RestClientConsumer", arcp.getName()); - - rcctp.setUrl("http://some.place.that.does.not/exist"); - Mockito.doReturn(Response.Status.OK.getStatusCode()).when(responseMock).getStatus(); - Mockito.doReturn(responseMock).when(builderMock).post(Mockito.any()); - Mockito.doReturn(builderMock).when(targetMock).request("application/json"); - Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any()); - Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl()); - arcp.setClient(httpClientMock); - - arcp.sendEvent(123, null, "EventName", "This is an Event"); - arcp.stop(); - } - - @Test - public void testApexRestClientProducerHttpError() throws ApexEventException { + void testApexRestClientProducerHttpError() throws ApexEventException { ApexRestClientProducer arcp = new ApexRestClientProducer(); assertNotNull(arcp); @@ -298,7 +272,7 @@ public class ApexRestClientProducerTest { rcctp.setUrl("http://some.place.that.does.not/exist"); Mockito.doReturn(Response.Status.BAD_REQUEST.getStatusCode()).when(responseMock).getStatus(); - Mockito.doReturn(responseMock).when(builderMock).post(Mockito.any()); + closeable = Mockito.doReturn(responseMock).when(builderMock).post(Mockito.any()); Mockito.doReturn(builderMock).when(targetMock).request("application/json"); Mockito.doReturn(builderMock).when(builderMock).headers(Mockito.any()); Mockito.doReturn(targetMock).when(httpClientMock).target(rcctp.getUrl()); @@ -308,4 +282,11 @@ public class ApexRestClientProducerTest { .hasMessageContaining("send of event to URL \"http://some.place.that.does.not/exist\" using HTTP \"POST\" " + "failed with status code 400"); } + + @AfterEach + void after() throws Exception { + if (closeable != null) { + closeable.close(); + } + } } diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java index 58d265a97..4539c5181 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParametersTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -25,12 +25,13 @@ package org.onap.policy.apex.plugins.event.carrier.restclient; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.apex.service.engine.main.ApexCommandLineArguments; import org.onap.policy.apex.service.parameters.ApexParameterHandler; import org.onap.policy.apex.service.parameters.ApexParameters; @@ -39,10 +40,10 @@ import org.onap.policy.common.parameters.ParameterException; /** * Test REST client carrier technology parameters. */ -public class RestClientCarrierTechnologyParametersTest { +class RestClientCarrierTechnologyParametersTest { @Test - public void testRestClientCarrierTechnologyParametersBadList() { + void testRestClientCarrierTechnologyParametersBadList() { ApexCommandLineArguments arguments = new ApexCommandLineArguments(); arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTClientWithHTTPHeaderBadList.json"); arguments.setRelativeFileRoot("."); @@ -55,7 +56,7 @@ public class RestClientCarrierTechnologyParametersTest { } @Test - public void testRestClientCarrierTechnologyParametersNotKvPairs() { + void testRestClientCarrierTechnologyParametersNotKvPairs() { ApexCommandLineArguments arguments = new ApexCommandLineArguments(); arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTClientWithHTTPHeaderNotKvPairs.json"); arguments.setRelativeFileRoot("."); @@ -67,7 +68,7 @@ public class RestClientCarrierTechnologyParametersTest { } @Test - public void testRestClientCarrierTechnologyParametersNulls() { + void testRestClientCarrierTechnologyParametersNulls() { ApexCommandLineArguments arguments = new ApexCommandLineArguments(); arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTClientWithHTTPHeaderNulls.json"); arguments.setRelativeFileRoot("."); @@ -79,7 +80,7 @@ public class RestClientCarrierTechnologyParametersTest { } @Test - public void testRestClientCarrierTechnologyParameterFilterInvalid() { + void testRestClientCarrierTechnologyParameterFilterInvalid() { ApexCommandLineArguments arguments = new ApexCommandLineArguments(); arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTClientWithHTTPFilterInvalid.json"); arguments.setRelativeFileRoot("."); @@ -92,7 +93,7 @@ public class RestClientCarrierTechnologyParametersTest { } @Test - public void testRestClientCarrierTechnologyParametersOk() throws ParameterException { + void testRestClientCarrierTechnologyParametersOk() throws ParameterException { ApexCommandLineArguments arguments = new ApexCommandLineArguments(); arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTClientWithHTTPHeaderOK.json"); arguments.setRelativeFileRoot("."); @@ -111,11 +112,11 @@ public class RestClientCarrierTechnologyParametersTest { assertEquals("fff", rrctp1.getHttpHeadersAsMultivaluedMap().get("eee").get(0)); rrctp1.setHttpHeaders(null); - assertEquals(null, rrctp1.getHttpHeadersAsMultivaluedMap()); + assertNull(rrctp1.getHttpHeadersAsMultivaluedMap()); } @Test - public void testRestClientCarrierTechnologyHttpCodeFilterOk() throws ParameterException { + void testRestClientCarrierTechnologyHttpCodeFilterOk() throws ParameterException { ApexCommandLineArguments arguments = new ApexCommandLineArguments(); arguments.setToscaPolicyFilePath("src/test/resources/prodcons/RESTClientWithHTTPHeaderOK.json"); arguments.setRelativeFileRoot("."); @@ -128,7 +129,7 @@ public class RestClientCarrierTechnologyParametersTest { } @Test - public void testGettersAndSetters() { + void testGettersAndSetters() { RestClientCarrierTechnologyParameters rrctp = new RestClientCarrierTechnologyParameters(); rrctp.setUrl("http://some.where"); @@ -168,7 +169,7 @@ public class RestClientCarrierTechnologyParametersTest { } @Test - public void testUrlValidation() { + void testUrlValidation() { RestClientCarrierTechnologyParameters rrctp = new RestClientCarrierTechnologyParameters(); rrctp.setUrl("http://some.where.no.tag.in.url"); @@ -186,29 +187,27 @@ public class RestClientCarrierTechnologyParametersTest { assertEquals("ccc", rrctp.getHttpHeaders()[1][0]); assertEquals("ddd", rrctp.getHttpHeaders()[1][1]); - assertEquals(true, rrctp.validate().isValid()); + assertTrue(rrctp.validate().isValid()); rrctp.setUrl("http://{place}.{that}/is{that}.{one}"); - assertEquals(true, rrctp.validate().isValid()); + assertTrue(rrctp.validate().isValid()); Set<String> keymap = rrctp.getKeysFromUrl(); - assertEquals(true, keymap.contains("place")); - assertEquals(true, keymap.contains("that")); - assertEquals(true, keymap.contains("one")); + assertTrue(keymap.contains("place") && keymap.contains("that") && keymap.contains("one")); rrctp.setUrl("http://{place.{that}/{is}.{not}/{what}.{exist}"); - assertEquals(false, rrctp.validate().isValid()); + assertFalse(rrctp.validate().isValid()); rrctp.setUrl("http://{place}.{that}/{is}.{not}/{what}.{exist"); - assertEquals(false, rrctp.validate().isValid()); + assertFalse(rrctp.validate().isValid()); rrctp.setUrl("http://place.that/is.not/what.{exist"); - assertEquals(false, rrctp.validate().isValid()); + assertFalse(rrctp.validate().isValid()); rrctp.setUrl("http://place}.{that}/{is}.{not}/{what}.{exist}"); - assertEquals(false, rrctp.validate().isValid()); + assertFalse(rrctp.validate().isValid()); rrctp.setUrl("http://{place}.{that}/is}.{not}/{what}.{exist}"); - assertEquals(false, rrctp.validate().isValid()); + assertFalse(rrctp.validate().isValid()); rrctp.setUrl("http://{place}.{that}/{}.{not}/{what}.{exist}"); - assertEquals(false, rrctp.validate().isValid()); + assertFalse(rrctp.validate().isValid()); rrctp.setUrl("http://{place}.{that}/{ }.{not}/{what}.{exist}"); - assertEquals(false, rrctp.validate().isValid()); + assertFalse(rrctp.validate().isValid()); } } |