From 2ce68d3c8423d644056becc8ef1e3bb0df731c42 Mon Sep 17 00:00:00 2001 From: Piotr Bocheński Date: Fri, 8 Feb 2019 13:38:02 +0100 Subject: Add git info to PRH + cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id518d56373f6ccab9dd4195ad08b67589e0d9b4f Issue-ID: DCAEGEN2-1030 Signed-off-by: Piotr Bocheński --- .../prh/configuration/PrhAppConfigTest.java | 32 ++++++++++------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'prh-app-server/src/test/java') diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java index 42acc592..249fccc3 100644 --- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java +++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfigTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * PNF-REGISTRATION-HANDLER * ================================================================================ - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 NOKIA Intellectual Property. 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. @@ -20,17 +20,6 @@ package org.onap.dcaegen2.services.prh.configuration; -import static java.lang.ClassLoader.getSystemResource; -import static java.nio.file.Files.readAllBytes; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Paths; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -38,11 +27,18 @@ import org.onap.dcaegen2.services.prh.integration.junit5.mockito.MockitoExtensio import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.Resource; +import java.io.*; +import java.nio.file.Paths; + +import static java.lang.ClassLoader.getSystemResource; +import static java.nio.file.Files.readAllBytes; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; /** * @author Przemysław Wąsala on 4/9/18 */ -@ExtendWith({MockitoExtension.class}) +@ExtendWith({ MockitoExtension.class }) class PrhAppConfigTest { private static final String CORRECT_CONFIG_FILE = "correct_config.json"; @@ -58,7 +54,7 @@ class PrhAppConfigTest { @Test void whenTheConfigurationFits() throws Exception { InputStream inputStream = createInputStream(CORRECT_CONFIG_FILE); - appConfig.setResourceFile(new InputStreamResource(inputStream)); + appConfig.setPrhEndpoints(new InputStreamResource(inputStream)); appConfig.initFileStreamReader(); assertNotNull(appConfig.getDmaapConsumerConfiguration()); @@ -71,7 +67,7 @@ class PrhAppConfigTest { InputStream inputStream = createInputStream(CORRECT_CONFIG_FILE); Resource resource = spy(new InputStreamResource(inputStream)); when(resource.getInputStream()).thenThrow(new IOException()); - appConfig.setResourceFile(resource); + appConfig.setPrhEndpoints(resource); appConfig.initFileStreamReader(); assertNull(appConfig.getAaiClientConfiguration()); @@ -82,7 +78,7 @@ class PrhAppConfigTest { @Test void whenFileExistsButDmaapPublisherJsonConfigurationIsIncorrect() throws Exception { InputStream inputStream = createInputStream(INCORRECT_CONFIG_FILE); - appConfig.setResourceFile(new InputStreamResource(inputStream)); + appConfig.setPrhEndpoints(new InputStreamResource(inputStream)); appConfig.initFileStreamReader(); assertNotNull(appConfig.getAaiClientConfiguration()); @@ -93,7 +89,7 @@ class PrhAppConfigTest { @Test void whenRootElementIsNotAJsonObject() throws Exception { InputStream inputStream = createInputStream(NOT_JSON_OBJECT_FILE); - appConfig.setResourceFile(new InputStreamResource(inputStream)); + appConfig.setPrhEndpoints(new InputStreamResource(inputStream)); appConfig.initFileStreamReader(); @@ -105,4 +101,4 @@ class PrhAppConfigTest { private InputStream createInputStream(String jsonFile) throws Exception { return new ByteArrayInputStream(readAllBytes(Paths.get(getSystemResource(jsonFile).toURI()))); } -} \ No newline at end of file +} -- cgit