diff options
author | Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com> | 2021-01-26 07:43:22 +0100 |
---|---|---|
committer | Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com> | 2021-01-28 10:16:25 +0100 |
commit | ed18ea83def89626ba42cbe3f38d96e50aabd2f6 (patch) | |
tree | 7fbfe76c003d8da7f9e4472340555c4ddd2cabf9 /pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/client/HttpTestUtils.java | |
parent | ef730fbed8743def93b864800928653a9e330457 (diff) |
Add message from VES to PNF simulator response when performing one time event request
Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Change-Id: I0a12263daafacc52643838ff80482e4c7168b7ea
Issue-ID: INT-1804
Diffstat (limited to 'pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/client/HttpTestUtils.java')
-rw-r--r-- | pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/client/HttpTestUtils.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/client/HttpTestUtils.java b/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/client/HttpTestUtils.java new file mode 100644 index 0000000..02ff531 --- /dev/null +++ b/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/client/HttpTestUtils.java @@ -0,0 +1,55 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2021 Nokia. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.pnfsimulator.simulator.client; + +import org.apache.http.HttpEntity; +import org.apache.http.ProtocolVersion; +import org.apache.http.message.BasicStatusLine; + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + +public class HttpTestUtils { + + private HttpTestUtils() { + } + + public static final String HTTP_MESSAGE_ACCEPTER = "Accepted"; + public static final String HTTP_MESSAGE_FORBIDDEN = "Forbidden"; + + static HttpEntity createMockedHttpEntity(String responseBody) throws IOException { + HttpEntity httpEntity = mock(HttpEntity.class); + doReturn(new ByteArrayInputStream(responseBody.getBytes())).when(httpEntity).getContent(); + return httpEntity; + } + + static BasicStatusLine createStatusLine(int responseCode) { + return new BasicStatusLine( + new ProtocolVersion("1.0.0", 1, 0), + responseCode, + "" + ); + } + +} |