diff options
author | JoeOLeary <joseph.o.leary@est.tech> | 2019-02-22 15:10:41 +0000 |
---|---|---|
committer | JoeOLeary <joseph.o.leary@est.tech> | 2019-02-22 15:10:41 +0000 |
commit | f7e07b1bfda9ffe612b1339e4b95394448c700f4 (patch) | |
tree | 6d1b54e35d8a45901036fa8d4676f05eced44f07 /src/test | |
parent | 5e40fbfdf79be48a5ff19393f65c0e09309e868a (diff) |
Add support for parallel event handling
*Add support for parallel event handling
*Add support for handling backpressure
*Update delivery end point
Issue-ID: DCAEGEN2-1268
Change-Id: Id467080fa135b58f2d3e366f00fd8ad5e1c6ec06
Signed-off-by: JoeOLeary <joseph.o.leary@est.tech>
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/onap/dcaegen2/services/pmmapper/AppTest.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/test/java/org/onap/dcaegen2/services/pmmapper/AppTest.java b/src/test/java/org/onap/dcaegen2/services/pmmapper/AppTest.java new file mode 100644 index 0000000..82650f3 --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/pmmapper/AppTest.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.services.pmmapper; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import io.undertow.util.StatusCodes; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; +import org.onap.dcaegen2.services.pmmapper.model.Event; +import org.onap.dcaegen2.services.pmmapper.model.EventMetadata; + + +@ExtendWith(MockitoExtension.class) +class AppTest { + + @Test + void testHandleBackPressureNullValue() { + assertThrows(NullPointerException.class, () -> App.handleBackPressure(null)); + } + + @Test + void testHandleBackPressure() { + Event event = utils.EventUtils.makeMockEvent("", mock(EventMetadata.class)); + App.handleBackPressure(event); + verify(event.getHttpServerExchange(), times(1)).setStatusCode(StatusCodes.TOO_MANY_REQUESTS); + verify(event.getHttpServerExchange(), times(1)).unDispatch(); + } + + @Test + void testReceiveRequestNullValue() { + assertThrows(NullPointerException.class, () -> App.receiveRequest(null)); + } + + @Test + void testReceiveRequest() { + Event event = utils.EventUtils.makeMockEvent("", mock(EventMetadata.class)); + App.receiveRequest(event); + verify(event.getHttpServerExchange(), times(1)).setStatusCode(StatusCodes.OK); + verify(event.getHttpServerExchange(), times(1)).unDispatch(); + } + + +} |