diff options
author | sebdet <sebastien.determe@intl.att.com> | 2020-09-15 11:53:27 +0200 |
---|---|---|
committer | sebdet <sebastien.determe@intl.att.com> | 2020-09-15 16:19:11 +0200 |
commit | 536db7b811eba341aef48a745b495da068d170eb (patch) | |
tree | 72cdba6e61989c7a00ef19545969ac0e49e30075 | |
parent | 2d9f989e0d37002c758bdf66a3f25fcfdac35b62 (diff) |
Fix the ssl config
Fix SSL config so that clamp can access external files from the application.properties spring definition
Issue-ID: CLAMP-884
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Change-Id: Ic4483d56c86f52249b09b386cdbe505f2f2f2a66
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
33 files changed, 263 insertions, 246 deletions
diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java index 84232999..c2a1ab90 100644 --- a/src/main/java/org/onap/clamp/clds/Application.java +++ b/src/main/java/org/onap/clamp/clds/Application.java @@ -39,14 +39,13 @@ import java.util.Enumeration; import org.apache.catalina.connector.Connector; import org.onap.clamp.clds.util.ClampVersioning; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.onap.clamp.util.PassDecoder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -111,7 +110,7 @@ public class Application extends SpringBootServletInitializer { */ @Bean public ServletRegistrationBean camelServletRegistrationBean() throws IOException { - eelfLogger.info(ResourceFileUtil.getResourceAsString("boot-message.txt") + "(v" + eelfLogger.info(ResourceFileUtils.getResourceAsString("boot-message.txt") + "(v" + ClampVersioning.getCldsVersionFromProps() + ")" + System.getProperty("line.separator") + getSslExpirationDate()); ServletRegistrationBean registration = new ServletRegistrationBean(new ClampServlet(), "/restservices/clds/*"); @@ -161,7 +160,7 @@ public class Application extends SpringBootServletInitializer { String password = PassDecoder.decode(env.getProperty("server.ssl.key-store-password"), env.getProperty("clamp.config.keyFile")); String keyStore = env.getProperty("server.ssl.key-store"); - InputStream is = ResourceFileUtil.getResourceAsStream(keyStore.replaceAll("classpath:", "")); + InputStream is = ResourceFileUtils.getResourceAsStream(keyStore.replaceAll("classpath:", "")); keystore.load(is, password.toCharArray()); Enumeration<String> aliases = keystore.aliases(); diff --git a/src/main/java/org/onap/clamp/clds/config/CamelConfiguration.java b/src/main/java/org/onap/clamp/clds/config/CamelConfiguration.java index 949ff1eb..7bf45e49 100644 --- a/src/main/java/org/onap/clamp/clds/config/CamelConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/CamelConfiguration.java @@ -48,6 +48,7 @@ import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.BasicHttpClientConnectionManager; import org.onap.clamp.clds.util.ClampVersioning; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.onap.clamp.util.PassDecoder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; @@ -65,7 +66,7 @@ public class CamelConfiguration extends RouteBuilder { private void configureDefaultSslProperties() throws IOException { if (env.getProperty("server.ssl.trust-store") != null) { URL storeResource = Thread.currentThread().getContextClassLoader() - .getResource(env.getProperty("server.ssl.trust-store").replaceAll("classpath:", "")); + .getResource(env.getProperty("server.ssl.trust-store").replaceFirst("classpath:", "")); System.setProperty("javax.net.ssl.trustStore", storeResource.getPath()); String keyFile = env.getProperty("clamp.config.keyFile"); String trustStorePass = PassDecoder.decode(env.getProperty("server.ssl.trust-store-password"), @@ -74,7 +75,7 @@ public class CamelConfiguration extends RouteBuilder { System.setProperty("javax.net.ssl.trustStoreType", "jks"); System.setProperty("ssl.TrustManagerFactory.algorithm", "PKIX"); storeResource = Thread.currentThread().getContextClassLoader() - .getResource(env.getProperty("server.ssl.key-store").replaceAll("classpath:", "")); + .getResource(env.getProperty("server.ssl.key-store").replaceFirst("classpath:", "")); System.setProperty("javax.net.ssl.keyStore", storeResource.getPath()); String keyStorePass = PassDecoder.decode(env.getProperty("server.ssl.key-store-password"), @@ -91,8 +92,7 @@ public class CamelConfiguration extends RouteBuilder { String keyFile = env.getProperty("clamp.config.keyFile"); String password = PassDecoder.decode(env.getProperty("server.ssl.trust-store-password"), keyFile); truststore.load( - Thread.currentThread().getContextClassLoader() - .getResourceAsStream(env.getProperty("server.ssl.trust-store").replaceAll("classpath:", "")), + ResourceFileUtils.getResourceAsStream(env.getProperty("server.ssl.trust-store")), password.toCharArray()); TrustManagerFactory trustFactory = TrustManagerFactory.getInstance("PKIX"); diff --git a/src/main/java/org/onap/clamp/clds/config/SslConfig.java b/src/main/java/org/onap/clamp/clds/config/SslConfig.java index 7c7433e9..16af4469 100644 --- a/src/main/java/org/onap/clamp/clds/config/SslConfig.java +++ b/src/main/java/org/onap/clamp/clds/config/SslConfig.java @@ -30,7 +30,7 @@ import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.onap.clamp.util.PassDecoder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.web.ServerProperties; @@ -52,45 +52,42 @@ public class SslConfig { @Bean WebServerFactoryCustomizer<TomcatServletWebServerFactory> tomcatCustomizer(ServerProperties serverProperties, - ResourceLoader resourceLoader) { + ResourceLoader resourceLoader) { return (tomcat) -> tomcat.setSslStoreProvider(new SslStoreProvider() { @Override - public KeyStore getKeyStore() throws KeyStoreException, + public KeyStore getKeyStore() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { KeyStore keystore = KeyStore.getInstance(env.getProperty("server.ssl.key-store-type")); - String password = PassDecoder.decode(env.getProperty("server.ssl.key-store-password"), - env.getProperty("clamp.config.keyFile")); - String keyStore = env.getProperty("server.ssl.key-store"); - InputStream is = ResourceFileUtil.getResourceAsStream(keyStore.replaceAll("classpath:", "")); - keystore.load(is, password.toCharArray()); + String password = PassDecoder.decode(env.getProperty("server.ssl.key-store-password"), + env.getProperty("clamp.config.keyFile")); + keystore.load(ResourceFileUtils.getResourceAsStream(env.getProperty("server.ssl.key-store")), + password.toCharArray()); return keystore; } @Override - public KeyStore getTrustStore() throws KeyStoreException, + public KeyStore getTrustStore() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { - KeyStore truststore = KeyStore.getInstance("JKS"); - String password = PassDecoder.decode(env.getProperty("server.ssl.trust-store-password"), - env.getProperty("clamp.config.keyFile")); - truststore.load( - Thread.currentThread().getContextClassLoader() - .getResourceAsStream(env.getProperty("server.ssl.trust-store") - .replaceAll("classpath:", "")), - password.toCharArray()); - return truststore; + KeyStore truststore = KeyStore.getInstance("JKS"); + String password = PassDecoder.decode(env.getProperty("server.ssl.trust-store-password"), + env.getProperty("clamp.config.keyFile")); + truststore.load( + ResourceFileUtils.getResourceAsStream(env.getProperty("server.ssl.trust-store")), + password.toCharArray()); + return truststore; } }); } @Bean WebServerFactoryCustomizer<TomcatServletWebServerFactory> tomcatSslCustomizer(ServerProperties serverProperties, - ResourceLoader resourceLoader) { + ResourceLoader resourceLoader) { return (tomcat) -> tomcat.setSsl(new Ssl() { @Override public String getKeyPassword() { - String password = PassDecoder.decode(env.getProperty("server.ssl.key-password"), - env.getProperty("clamp.config.keyFile")); - return password; + String password = PassDecoder.decode(env.getProperty("server.ssl.key-password"), + env.getProperty("clamp.config.keyFile")); + return password; } }); } diff --git a/src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java b/src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java index 3bbb8a0b..f68990a8 100644 --- a/src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java +++ b/src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java @@ -46,7 +46,7 @@ import javax.servlet.http.HttpServletRequest; import org.onap.aaf.cadi.config.Config; import org.onap.aaf.cadi.filter.CadiFilter; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; @@ -102,6 +102,9 @@ public class ClampCadiFilter extends CadiFilter { @Value("${clamp.config.cadi.cadiX509Issuers:#{null}}") private String cadiX509Issuers; + @Value("${clamp.config.caCerts:#{null}}") + private String caCertsPath; + private void checkIfNullProperty(String key, String value) { /* * When value is null, so not defined in application.properties set nothing in @@ -153,7 +156,7 @@ public class ClampCadiFilter extends CadiFilter { URLDecoder.decode(certHeader, StandardCharsets.UTF_8.toString()).getBytes())); X509Certificate caCert = (X509Certificate) certificateFactory .generateCertificate(new ByteArrayInputStream( - ResourceFileUtil.getResourceAsString("clds/aaf/ssl/ca-certs.pem").getBytes())); + ResourceFileUtils.getResourceAsString(this.caCertsPath).getBytes())); X509Certificate[] certifArray = ((X509Certificate[]) request .getAttribute("javax.servlet.request.X509Certificate")); diff --git a/src/main/java/org/onap/clamp/clds/util/ClampVersioning.java b/src/main/java/org/onap/clamp/clds/util/ClampVersioning.java index fd7a9a0f..ec0162cb 100644 --- a/src/main/java/org/onap/clamp/clds/util/ClampVersioning.java +++ b/src/main/java/org/onap/clamp/clds/util/ClampVersioning.java @@ -51,7 +51,7 @@ public class ClampVersioning { public static String getCldsVersionFromProps() { String cldsVersion = ""; Properties props = new Properties(); - try (InputStream resourceStream = ResourceFileUtil.getResourceAsStream(RESOURCE_NAME)) { + try (InputStream resourceStream = ResourceFileUtils.getResourceAsStream(RESOURCE_NAME)) { props.load(resourceStream); cldsVersion = props.getProperty(CLDS_VERSION_PROPERTY); } catch (Exception ex) { diff --git a/src/main/java/org/onap/clamp/clds/util/CryptoUtils.java b/src/main/java/org/onap/clamp/clds/util/CryptoUtils.java index 7d37cca6..1ddf3a90 100644 --- a/src/main/java/org/onap/clamp/clds/util/CryptoUtils.java +++ b/src/main/java/org/onap/clamp/clds/util/CryptoUtils.java @@ -157,7 +157,7 @@ public final class CryptoUtils { if (encryptionKey != null && encryptionKey.trim().length() > 0) { return getSecretKeySpec(encryptionKey); } else { - props.load(ResourceFileUtil.getResourceAsStream(propertiesFileName)); + props.load(ResourceFileUtils.getResourceAsStream(propertiesFileName)); return getSecretKeySpec(props.getProperty(KEY_PARAM)); } } catch (IOException | DecoderException e) { diff --git a/src/main/java/org/onap/clamp/clds/util/ResourceFileUtil.java b/src/main/java/org/onap/clamp/clds/util/ResourceFileUtil.java deleted file mode 100644 index 5deee467..00000000 --- a/src/main/java/org/onap/clamp/clds/util/ResourceFileUtil.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T 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. - * 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.clamp.clds.util; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Scanner; - -/** - * Utility methods supporting resources accesses. - */ -public final class ResourceFileUtil { - - /** - * Private constructor to avoid creating instances of util class. - */ - private ResourceFileUtil() { - } - - /** - * Return resource as a Stream. - * - * @return resource - resource as stream - */ - public static InputStream getResourceAsStream(String name) { - InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(name); - if (is == null) { - throw new IllegalArgumentException("Unable to find resource: " + name); - } - return is; - } - - /** - * Return resource as a String. - */ - public static String getResourceAsString(String name) throws IOException { - try (InputStream is = getResourceAsStream(name)) { - try (Scanner scanner = new Scanner(is)) { - Scanner delimitedScanner = scanner.useDelimiter("\\A"); - return delimitedScanner.hasNext() ? delimitedScanner.next() : ""; - } - } - } -} diff --git a/src/main/java/org/onap/clamp/clds/util/ResourceFileUtils.java b/src/main/java/org/onap/clamp/clds/util/ResourceFileUtils.java new file mode 100644 index 00000000..f858ed2b --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/util/ResourceFileUtils.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017 AT&T 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. + * 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.clamp.clds.util; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Scanner; + +/** + * Utility methods supporting resources accesses. + */ +public final class ResourceFileUtils { + + /** + * getResourceAsStram supports the "file:" prefix as they use URL. + * So here we want to eliminate classpath: prefix, so that this class can get + * files from jar resource or file system. + */ + + private static final String CLASSPATH_PREFIX = "classpath:"; + + /** + * Private constructor to avoid creating instances of util class. + */ + private ResourceFileUtils() { + } + + /** + * Method to access a file from the jar resource folder or file system. + * Give the prefix "classpath:" so that it accesses the jar resource folder (default case) + * or the prefix "file:" so that it accesses the file system. + * + * @param fileName The path of the resource (no prefix it will be a classpath access, + * "classpath:/myfilename" or "file:/myfilename") + * @return The file as inputStream + */ + public static InputStream getResourceAsStream(String fileName) { + InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( + fileName.startsWith(CLASSPATH_PREFIX) ? fileName.replaceFirst(CLASSPATH_PREFIX, "") : fileName); + if (is == null) { + throw new IllegalArgumentException("Unable to find resource: " + fileName); + } + return is; + } + + /** + * Method to access a resource file as a string. + * Give the prefix "classpath:" so that it accesses the jar resource folder (default case) + * or the prefix "file:" so that it accesses the file system. + * + * @param fileName The path of the resource (no prefix it will be a classpath access, + * "classpath:/myfilename" or "file:/myfilename") + * @return The file as String + * @throws IOException In case of failure to find the file. + */ + public static String getResourceAsString(String fileName) throws IOException { + try (InputStream is = getResourceAsStream(fileName)) { + return streamToString(is); + } + } + + private static String streamToString(InputStream inputStream) { + try (Scanner scanner = new Scanner(inputStream)) { + Scanner delimitedScanner = scanner.useDelimiter("\\A"); + return delimitedScanner.hasNext() ? delimitedScanner.next() : ""; + } + } +}
\ No newline at end of file diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java index c0e1c019..0381f0a2 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java @@ -36,7 +36,7 @@ import java.util.Map.Entry; import java.util.Set; import org.onap.clamp.clds.util.JsonUtils; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.onap.clamp.loop.service.Service; public class OperationalPolicyRepresentationBuilder { @@ -74,7 +74,7 @@ public class OperationalPolicyRepresentationBuilder { JsonObject jsonSchema = null; try { jsonSchema = JsonUtils.GSON.fromJson( - ResourceFileUtil + ResourceFileUtils .getResourceAsString("clds/json-schema/operational_policies/operational_policy.json"), JsonObject.class); jsonSchema.get(PROPERTIES).getAsJsonObject() diff --git a/src/main/java/org/onap/clamp/util/PassDecoder.java b/src/main/java/org/onap/clamp/util/PassDecoder.java index 029f55d6..5d261c02 100644 --- a/src/main/java/org/onap/clamp/util/PassDecoder.java +++ b/src/main/java/org/onap/clamp/util/PassDecoder.java @@ -31,7 +31,7 @@ import java.io.IOException; import java.io.InputStream; import org.onap.aaf.cadi.Symm; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; /** * PassDecoder for decrypting the truststore and keystore password. @@ -44,12 +44,12 @@ public class PassDecoder { /** * Decode the password. - * + * * @param encryptedPass The encrypted password - * @param keyFile The key file name in String + * @param keyFileName The key file name in String */ - public static String decode(String encryptedPass, String keyFile) { - if (null == keyFile) { + public static String decode(String encryptedPass, String keyFileName) { + if (null == keyFileName) { logger.debug("Key file is not defined, thus password will not be decrypted"); return encryptedPass; } @@ -58,16 +58,7 @@ public class PassDecoder { return null; } try { - InputStream is; - if (keyFile.contains("classpath:")) { - is = ResourceFileUtil.getResourceAsStream(keyFile.replaceAll("classpath:", "")); - } else { - File key = new File(keyFile); - is = new FileInputStream(key); - } - Symm symm = Symm.obtain(is); - - return symm.depass(encryptedPass); + return Symm.obtain(ResourceFileUtils.getResourceAsStream(keyFileName)).depass(encryptedPass); } catch (IOException e) { logger.error("Exception occurred during the key decryption", e); return null; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c5bab26c..4ab551ea 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -63,6 +63,7 @@ server.ssl.key-alias=clamp@clamp.onap.org # The key file used to decode the key store and trust store password # If not defined, the key store and trust store password will not be decrypted clamp.config.keyFile=classpath:/clds/aaf/org.onap.clamp.keyfile +clamp.config.caCerts=classpath:/clds/aaf/ssl/ca-certs.pem ## Config part for Client certificates server.ssl.client-auth=want diff --git a/src/test/java/org/onap/clamp/clds/client/CdsServicesTest.java b/src/test/java/org/onap/clamp/clds/client/CdsServicesTest.java index 9fdc727b..3d189cf7 100644 --- a/src/test/java/org/onap/clamp/clds/client/CdsServicesTest.java +++ b/src/test/java/org/onap/clamp/clds/client/CdsServicesTest.java @@ -26,29 +26,29 @@ import com.google.gson.JsonObject; import java.io.IOException; import org.junit.Test; import org.onap.clamp.clds.util.JsonUtils; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.skyscreamer.jsonassert.JSONAssert; public class CdsServicesTest { @Test public void testParseCdsListTypeProperties() throws IOException { - String cdsResponse = ResourceFileUtil + String cdsResponse = ResourceFileUtils .getResourceAsString("example/cds-response/vFW-CDS-resource-assignment-workflow.json"); CdsServices services = new CdsServices(); JsonObject output = services.parseCdsResponse(cdsResponse); - JSONAssert.assertEquals(ResourceFileUtil + JSONAssert.assertEquals(ResourceFileUtils .getResourceAsString("example/cds-response/vFW-CDS-resource-assignment-wf-expected-result.json"), JsonUtils.GSON.toJson(output), true); } @Test public void testParseCdsResponse() throws IOException { - String cdsResponse = ResourceFileUtil + String cdsResponse = ResourceFileUtils .getResourceAsString("example/cds-response/vFW-CDS-modify-config-workflow.json"); CdsServices services = new CdsServices(); JsonObject output = services.parseCdsResponse(cdsResponse); - JSONAssert.assertEquals(ResourceFileUtil + JSONAssert.assertEquals(ResourceFileUtils .getResourceAsString("example/cds-response/vFW-CDS-modify-config-wf-expected-result.json"), JsonUtils.GSON.toJson(output), true); } diff --git a/src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java b/src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java index d27690bf..06df124c 100644 --- a/src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java +++ b/src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java @@ -36,7 +36,7 @@ import java.nio.charset.StandardCharsets; import org.junit.Test; import org.onap.clamp.clds.exception.sdc.controller.SdcParametersException; import org.onap.clamp.clds.util.JsonUtils; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; /** * This class tests the SDC Controller config. @@ -51,7 +51,7 @@ public class SdcSingleControllerConfigurationTest { public static SdcSingleControllerConfiguration loadControllerConfiguration(String fileName, String sdcControllerName) { - InputStreamReader streamReader = new InputStreamReader(ResourceFileUtil.getResourceAsStream(fileName), + InputStreamReader streamReader = new InputStreamReader(ResourceFileUtils.getResourceAsStream(fileName), StandardCharsets.UTF_8); JsonObject jsonNode = JsonUtils.GSON.fromJson(streamReader, JsonObject.class); diff --git a/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java b/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java index d985a5d7..c4c0c345 100644 --- a/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java @@ -29,7 +29,7 @@ import java.io.IOException; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.config.ClampProperties; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @@ -59,7 +59,7 @@ public class CldsReferencePropertiesItCase { */ @Test public void testGetFileContent() throws IOException { - String users = ResourceFileUtil.getResourceAsString("clds/clds-users.json"); + String users = ResourceFileUtils.getResourceAsString("clds/clds-users.json"); assertEquals(users, refProp.getFileContent("files.cldsUsers")); // Test composite key assertEquals(users, refProp.getFileContent("files", "cldsUsers")); diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java index cd7337a4..a768526a 100644 --- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java +++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java @@ -43,7 +43,7 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.onap.clamp.clds.exception.sdc.controller.BlueprintParserException; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.yaml.snakeyaml.Yaml; public class BlueprintParserTest { @@ -70,25 +70,25 @@ public class BlueprintParserTest { */ @BeforeClass public static void loadBlueprints() throws IOException { - microServiceTheWholeBlueprintValid = ResourceFileUtil + microServiceTheWholeBlueprintValid = ResourceFileUtils .getResourceAsString("clds/blueprint-with-microservice-chain.yaml"); - newMicroServiceBlueprint = ResourceFileUtil.getResourceAsString("clds/new-microservice.yaml"); + newMicroServiceBlueprint = ResourceFileUtils.getResourceAsString("clds/new-microservice.yaml"); - String microServiceBlueprintInvalid = ResourceFileUtil + String microServiceBlueprintInvalid = ResourceFileUtils .getResourceAsString("clds/single-microservice-fragment-invalid.yaml"); jsonObjectBlueprintInvalid = yamlToJson(microServiceBlueprintInvalid); - String microServiceBlueprintWithoutName = ResourceFileUtil + String microServiceBlueprintWithoutName = ResourceFileUtils .getResourceAsString("clds/single-microservice-fragment-without-name.yaml"); jsonObjectBlueprintWithoutName = yamlToJson(microServiceBlueprintWithoutName); - String microServiceBlueprintWithoutProperties = ResourceFileUtil + String microServiceBlueprintWithoutProperties = ResourceFileUtils .getResourceAsString("clds/single-microservice-fragment-without-properties.yaml"); jsonObjectBlueprintWithoutProperties = yamlToJson(microServiceBlueprintWithoutProperties); - String microServiceBlueprintValidWithVersion = ResourceFileUtil + String microServiceBlueprintValidWithVersion = ResourceFileUtils .getResourceAsString("clds/single-microservice-fragment-valid-with-version.yaml"); jsonObjectBlueprintValidWithVersion = yamlToJson(microServiceBlueprintValidWithVersion); - String microServiceBlueprintWithoutRelationships = ResourceFileUtil + String microServiceBlueprintWithoutRelationships = ResourceFileUtils .getResourceAsString("clds/single-microservice-fragment-without-relationships.yaml"); jsonObjectBlueprintWithoutRelationships = yamlToJson(microServiceBlueprintWithoutRelationships); diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandlerTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandlerTest.java index e0088747..f04e3fa3 100644 --- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandlerTest.java +++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandlerTest.java @@ -42,7 +42,7 @@ import org.junit.Test; import org.mockito.Mockito; import org.onap.clamp.clds.exception.sdc.controller.CsarHandlerException; import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.api.notification.INotificationData; import org.onap.sdc.api.notification.IResourceInstance; @@ -112,14 +112,14 @@ public class CsarHandlerTest { private IDistributionClientDownloadResult buildFakeSdcResut() throws IOException { IDistributionClientDownloadResult resultArtifact = Mockito.mock(IDistributionClientDownloadResult.class); Mockito.when(resultArtifact.getArtifactPayload()).thenReturn( - IOUtils.toByteArray(ResourceFileUtil.getResourceAsStream("example/sdc/service-Simsfoimap0112.csar"))); + IOUtils.toByteArray(ResourceFileUtils.getResourceAsStream("example/sdc/service-Simsfoimap0112.csar"))); return resultArtifact; } private IDistributionClientDownloadResult buildFakeSdcResultWithoutPolicyModel() throws IOException { IDistributionClientDownloadResult resultArtifact = Mockito.mock(IDistributionClientDownloadResult.class); Mockito.when(resultArtifact.getArtifactPayload()).thenReturn( - IOUtils.toByteArray(ResourceFileUtil.getResourceAsStream("example/sdc/service-without-policy.csar"))); + IOUtils.toByteArray(ResourceFileUtils.getResourceAsStream("example/sdc/service-without-policy.csar"))); return resultArtifact; } diff --git a/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTestItCase.java b/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTestItCase.java index b26f3ede..e7354765 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTestItCase.java +++ b/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTestItCase.java @@ -33,7 +33,7 @@ import javax.transaction.Transactional; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.Application; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.onap.clamp.tosca.Dictionary; import org.onap.clamp.tosca.DictionaryElement; import org.onap.clamp.tosca.DictionaryService; @@ -61,14 +61,14 @@ public class ToscaYamlToJsonConvertorTestItCase { */ @Test public final void testParseToscaYaml() throws IOException { - String toscaModelYaml = ResourceFileUtil.getResourceAsString("tosca/tosca_example.yaml"); + String toscaModelYaml = ResourceFileUtils.getResourceAsString("tosca/tosca_example.yaml"); ToscaYamlToJsonConvertor convertor = new ToscaYamlToJsonConvertor(); String parsedJsonSchema = convertor.parseToscaYaml(toscaModelYaml, "onap.policies.monitoring.cdap.tca.hi.lo.app"); assertNotNull(parsedJsonSchema); JSONAssert.assertEquals( - ResourceFileUtil.getResourceAsString("tosca/policy-yaml-to-json.json"), + ResourceFileUtils.getResourceAsString("tosca/policy-yaml-to-json.json"), parsedJsonSchema, true); } @@ -82,14 +82,14 @@ public class ToscaYamlToJsonConvertorTestItCase { @Test public final void testParseToscaYamlWithConstraints() throws IOException { String toscaModelYaml = - ResourceFileUtil.getResourceAsString("tosca/tosca-with-constraints.yaml"); + ResourceFileUtils.getResourceAsString("tosca/tosca-with-constraints.yaml"); ToscaYamlToJsonConvertor convertor = new ToscaYamlToJsonConvertor(); String parsedJsonSchema = convertor.parseToscaYaml(toscaModelYaml, "onap.policies.monitoring.example.app"); assertNotNull(parsedJsonSchema); JSONAssert.assertEquals( - ResourceFileUtil.getResourceAsString("tosca/policy-yaml-to-json-with-constraints.json"), + ResourceFileUtils.getResourceAsString("tosca/policy-yaml-to-json-with-constraints.json"), parsedJsonSchema, true); } @@ -103,14 +103,14 @@ public class ToscaYamlToJsonConvertorTestItCase { @Test public final void testParseToscaYamlWithTypes() throws IOException { String toscaModelYaml = - ResourceFileUtil.getResourceAsString("tosca/tosca-with-datatypes.yaml"); + ResourceFileUtils.getResourceAsString("tosca/tosca-with-datatypes.yaml"); ToscaYamlToJsonConvertor convertor = new ToscaYamlToJsonConvertor(); String parsedJsonSchema = convertor.parseToscaYaml(toscaModelYaml, "onap.policies.monitoring.example.app"); assertNotNull(parsedJsonSchema); JSONAssert.assertEquals( - ResourceFileUtil.getResourceAsString("tosca/policy-yaml-to-json-with-datatypes.json"), + ResourceFileUtils.getResourceAsString("tosca/policy-yaml-to-json-with-datatypes.json"), parsedJsonSchema, true); } @@ -126,7 +126,7 @@ public class ToscaYamlToJsonConvertorTestItCase { public final void testMetadataClampPossibleValues() throws IOException { setupDictionary(); String toscaModelYaml = - ResourceFileUtil.getResourceAsString("tosca/tosca_metadata_clamp_possible_values.yaml"); + ResourceFileUtils.getResourceAsString("tosca/tosca_metadata_clamp_possible_values.yaml"); JsonObject jsonObject = toscaYamlToJsonConvertor.validateAndConvertToJson(toscaModelYaml); assertNotNull(jsonObject); @@ -141,7 +141,7 @@ public class ToscaYamlToJsonConvertorTestItCase { assertEquals("onap.policies.monitoring.cdap.tca.hi.lo.app", policyModelType); assertEquals("tca", acronym); JSONAssert.assertEquals( - ResourceFileUtil + ResourceFileUtils .getResourceAsString("tosca/tosca_metadata_clamp_possible_values_json_schema.json"), parsedJsonSchema, true); diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java index 421bd6ab..8a81445b 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java @@ -31,7 +31,7 @@ import org.onap.clamp.clds.tosca.update.elements.ArrayField; import org.onap.clamp.clds.tosca.update.elements.ToscaElement; import org.onap.clamp.clds.tosca.update.elements.ToscaElementProperty; import org.onap.clamp.clds.tosca.update.templates.JsonTemplateManager; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; public class ArrayFieldTest extends TestCase { @@ -41,10 +41,10 @@ public class ArrayFieldTest extends TestCase { * @throws IOException in case of failure */ public void testDeploy() throws IOException { - JsonTemplateManager jsonTemplateManager = new JsonTemplateManager(ResourceFileUtil.getResourceAsString( - "tosca/new-converter/sampleOperationalPoliciesEXTENTED.yaml"),ResourceFileUtil.getResourceAsString( + JsonTemplateManager jsonTemplateManager = new JsonTemplateManager(ResourceFileUtils.getResourceAsString( + "tosca/new-converter/sampleOperationalPoliciesEXTENTED.yaml"), ResourceFileUtils.getResourceAsString( "clds/tosca-converter/default-tosca-types.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); ToscaElement toscaElement = jsonTemplateManager.getToscaElements().get("onap.datatype.controlloop.Actor"); ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("actor"); ArrayField arrayParser = new ArrayField((ArrayList<Object>) toscaElementProperty.getItems().get("default")); diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java index 5215cbd4..f147f404 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java @@ -31,14 +31,14 @@ import org.onap.clamp.clds.tosca.update.elements.ToscaElement; import org.onap.clamp.clds.tosca.update.elements.ToscaElementProperty; import org.onap.clamp.clds.tosca.update.templates.JsonTemplate; import org.onap.clamp.clds.tosca.update.templates.JsonTemplateManager; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; public class ConstraintTest extends TestCase { JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( - ResourceFileUtil.getResourceAsString("tosca/new-converter/constraints.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + ResourceFileUtils.getResourceAsString("tosca/new-converter/constraints.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); ToscaElement toscaElement = jsonTemplateManager.getToscaElements().get("onap.datatype.controlloop.Operation"); diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/JsonTemplateManagerTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/JsonTemplateManagerTest.java index 0a0710c6..b9fcf51a 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/JsonTemplateManagerTest.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/JsonTemplateManagerTest.java @@ -31,7 +31,7 @@ import junit.framework.TestCase; import org.onap.clamp.clds.tosca.update.templates.JsonTemplate; import org.onap.clamp.clds.tosca.update.templates.JsonTemplateField; import org.onap.clamp.clds.tosca.update.templates.JsonTemplateManager; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; public class JsonTemplateManagerTest extends TestCase { @@ -44,11 +44,11 @@ public class JsonTemplateManagerTest extends TestCase { public void testLaunchTranslationTca() throws IOException, UnknownComponentException { JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( - ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + ResourceFileUtils.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + ".policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0?" - + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString( + + "connectionTimeToLive=5000/.file"), ResourceFileUtils.getResourceAsString( "clds/tosca-converter/default-tosca-types.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); String componentName = "onap.policies.monitoring.cdap.tca.hi.lo.app"; jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null, null); } @@ -62,11 +62,11 @@ public class JsonTemplateManagerTest extends TestCase { public void testLaunchTranslationFrequencyLimiter() throws IOException, UnknownComponentException { JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( - ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + ResourceFileUtils.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + ".policies.controlloop.guard.common.FrequencyLimiter/versions/1.0.0?" - + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString( + + "connectionTimeToLive=5000/.file"), ResourceFileUtils.getResourceAsString( "clds/tosca-converter/default-tosca-types.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); String componentName = "onap.policies.controlloop.guard.common.FrequencyLimiter"; jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null, null); } @@ -80,11 +80,11 @@ public class JsonTemplateManagerTest extends TestCase { public void testLaunchTranslationApex() throws IOException, UnknownComponentException { JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( - ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + ResourceFileUtils.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + ".policies.controlloop.operational.common.Apex/versions/1.0.0?" - + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString( + + "connectionTimeToLive=5000/.file"), ResourceFileUtils.getResourceAsString( "clds/tosca-converter/default-tosca-types.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); String componentName = "onap.policies.controlloop.operational.common.Apex"; jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null, null); } @@ -98,11 +98,11 @@ public class JsonTemplateManagerTest extends TestCase { public void testLaunchTranslationDrools() throws IOException, UnknownComponentException { JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( - ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + ResourceFileUtils.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + ".policies.controlloop.operational.common.Drools/versions/1.0.0?" - + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString( + + "connectionTimeToLive=5000/.file"), ResourceFileUtils.getResourceAsString( "clds/tosca-converter/default-tosca-types.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); String componentName = "onap.policies.controlloop.operational.common.Drools"; jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null, null); } @@ -117,9 +117,9 @@ public class JsonTemplateManagerTest extends TestCase { public void testLaunchTranslation() throws IOException, UnknownComponentException { JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( - ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + ResourceFileUtils.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); String componentName = "onap.policies.controlloop.operational.common.Drools"; jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null, null); } @@ -132,9 +132,9 @@ public class JsonTemplateManagerTest extends TestCase { public void testAddTemplate() throws IOException { JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( - ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + ResourceFileUtils.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); int count = jsonTemplateManager.getJsonSchemaTemplates().size(); List<JsonTemplateField> jsonTemplateFields = @@ -154,9 +154,9 @@ public class JsonTemplateManagerTest extends TestCase { public void testRemoveTemplate() throws IOException { JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( - ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + ResourceFileUtils.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); int count = jsonTemplateManager.getJsonSchemaTemplates().size(); jsonTemplateManager.removeTemplate("string"); assertNotSame(count, jsonTemplateManager.getJsonSchemaTemplates().size()); @@ -170,9 +170,9 @@ public class JsonTemplateManagerTest extends TestCase { public void testUpdateTemplate() throws IOException { JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( - ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + ResourceFileUtils.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); int count = jsonTemplateManager.getJsonSchemaTemplates().get("integer").getJsonTemplateFields().size(); jsonTemplateManager.updateTemplate("integer", new JsonTemplateField("type"), false); assertNotSame(count, @@ -187,9 +187,9 @@ public class JsonTemplateManagerTest extends TestCase { public void testHasTemplate() throws IOException { JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( - ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + ResourceFileUtils.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); boolean has = true; List<JsonTemplateField> jsonTemplateFieldsString = new ArrayList<>(Arrays.asList(new JsonTemplateField("type"), new JsonTemplateField("description"), diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java index f7774214..b5b0247c 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java @@ -33,7 +33,7 @@ import org.onap.clamp.clds.tosca.update.execution.ToscaMetadataExecutor; import org.onap.clamp.clds.tosca.update.parser.metadata.ToscaMetadataParserWithDictionarySupport; import org.onap.clamp.clds.tosca.update.templates.JsonTemplateManager; import org.onap.clamp.clds.util.JsonUtils; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.onap.clamp.loop.service.Service; import org.onap.clamp.tosca.Dictionary; import org.onap.clamp.tosca.DictionaryElement; @@ -110,16 +110,16 @@ public class ToscaConverterWithDictionarySupportItCase { JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( - ResourceFileUtil + ResourceFileUtils .getResourceAsString("tosca/new-converter/tosca_metadata_clamp_possible_values.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + ResourceFileUtils.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); JsonObject jsonSchema = jsonTemplateManager.getJsonSchemaForPolicyType( "onap.policies.monitoring.cdap.tca.hi.lo.app", toscaMetadataParserWithDictionarySupport, null); JSONAssert.assertEquals( - ResourceFileUtil + ResourceFileUtils .getResourceAsString("tosca/new-converter/tca-with-metadata.json"), JsonUtils.GSON.toJson(jsonSchema), true); } @@ -127,21 +127,21 @@ public class ToscaConverterWithDictionarySupportItCase { @Test @Transactional public final void testMetadataClampPossibleValueWithExecutor() throws IOException, UnknownComponentException { - Service service = new Service(ResourceFileUtil.getResourceAsString("tosca/service-details.json"), - ResourceFileUtil.getResourceAsString("tosca/resource-details-cds.json")); + Service service = new Service(ResourceFileUtils.getResourceAsString("tosca/service-details.json"), + ResourceFileUtils.getResourceAsString("tosca/resource-details-cds.json")); JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( - ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + ResourceFileUtils.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + ".policies.controlloop.operational.common.Apex/versions/1.0" + ".0?connectionTimeToLive=5000/.file"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + ResourceFileUtils.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); JsonObject jsonSchema = jsonTemplateManager.getJsonSchemaForPolicyType( "onap.policies.controlloop.operational.common.Apex", toscaMetadataParserWithDictionarySupport, service); JSONAssert.assertEquals( - ResourceFileUtil + ResourceFileUtils .getResourceAsString("tosca/new-converter/tosca_apex_with_metadata.json"), JsonUtils.GSON.toJson(jsonSchema), true); } diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ToscaElementPropertyTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaElementPropertyTest.java index 967f330d..52f8444f 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/ToscaElementPropertyTest.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaElementPropertyTest.java @@ -32,7 +32,7 @@ import org.onap.clamp.clds.tosca.update.elements.ToscaElement; import org.onap.clamp.clds.tosca.update.elements.ToscaElementProperty; import org.onap.clamp.clds.tosca.update.templates.JsonTemplate; import org.onap.clamp.clds.tosca.update.templates.JsonTemplateManager; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; public class ToscaElementPropertyTest extends TestCase { public ToscaElementPropertyTest() throws IOException { @@ -45,9 +45,9 @@ public class ToscaElementPropertyTest extends TestCase { */ public void testParseArray() throws IOException { JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( - ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPoliciesEXTENTED.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + ResourceFileUtils.getResourceAsString("tosca/new-converter/sampleOperationalPoliciesEXTENTED.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); ToscaElement toscaElement = jsonTemplateManager.getToscaElements().get("onap.datatype.controlloop.Actor"); ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("actor"); JsonArray toTest = @@ -62,9 +62,9 @@ public class ToscaElementPropertyTest extends TestCase { */ public void testAddConstraintsAsJson() throws IOException { JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( - ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + ResourceFileUtils.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), + ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json")); ToscaElement toscaElement = jsonTemplateManager.getToscaElements().get("onap.datatype.controlloop.operation.Failure"); ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("category"); diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ToscaElementTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaElementTest.java index 5f7de28a..ba8454bb 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/ToscaElementTest.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaElementTest.java @@ -29,7 +29,7 @@ import java.util.Arrays; import junit.framework.TestCase;
import org.onap.clamp.clds.tosca.update.elements.ToscaElement;
import org.onap.clamp.clds.tosca.update.templates.JsonTemplateManager;
-import org.onap.clamp.clds.util.ResourceFileUtil;
+import org.onap.clamp.clds.util.ResourceFileUtils;
public class ToscaElementTest extends TestCase {
@@ -42,9 +42,9 @@ public class ToscaElementTest extends TestCase { ArrayList<String> reference = new ArrayList<>(Arrays.asList("actor", "operation", "target", "payload"));
JsonTemplateManager jsonTemplateManager =
new JsonTemplateManager(
- ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
- ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"),
- ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json"));
+ ResourceFileUtils.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
+ ResourceFileUtils.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"),
+ ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json"));
ToscaElement toscaElement = jsonTemplateManager.getToscaElements().get("onap.datatype.controlloop.Actor");
assertEquals(reference, toscaElement.propertiesNames());
}
diff --git a/src/test/java/org/onap/clamp/clds/util/JsonUtilsTest.java b/src/test/java/org/onap/clamp/clds/util/JsonUtilsTest.java index 926ed66b..bc2ec212 100644 --- a/src/test/java/org/onap/clamp/clds/util/JsonUtilsTest.java +++ b/src/test/java/org/onap/clamp/clds/util/JsonUtilsTest.java @@ -72,6 +72,6 @@ public class JsonUtilsTest { @Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionFileNotExists() throws IOException { - ResourceFileUtil.getResourceAsString("example/notExist.json"); + ResourceFileUtils.getResourceAsString("example/notExist.json"); } } diff --git a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java index 1c33d5e0..86bc8c07 100644 --- a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java +++ b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java @@ -35,6 +35,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; import javax.transaction.Transactional; + import org.apache.commons.lang3.RandomStringUtils; import org.json.JSONException; import org.junit.Assert; @@ -49,7 +50,7 @@ import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerExceptio import org.onap.clamp.clds.sdc.controller.installer.BlueprintArtifact; import org.onap.clamp.clds.sdc.controller.installer.CsarHandler; import org.onap.clamp.clds.util.JsonUtils; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.onap.clamp.loop.cds.CdsDataInstaller; import org.onap.clamp.loop.service.ServicesRepository; import org.onap.clamp.loop.template.LoopTemplate; @@ -74,7 +75,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) -@ActiveProfiles({"clamp-default","clamp-default-user","clamp-sdc-controller","legacy-operational-policy"}) +@ActiveProfiles({"clamp-default", "clamp-default-user", "clamp-sdc-controller", "legacy-operational-policy"}) public class CsarInstallerItCase { private static final String CSAR_ARTIFACT_NAME_CDS = "example/sdc/service_Vloadbalancerms_cds.csar"; @@ -106,7 +107,7 @@ public class CsarInstallerItCase { Mockito.when(resource.getResourceInvariantUUID()).thenReturn(invariantResourceUuid); BlueprintArtifact blueprintArtifact = Mockito.mock(BlueprintArtifact.class); Mockito.when(blueprintArtifact.getDcaeBlueprint()) - .thenReturn(ResourceFileUtil.getResourceAsString(blueprintFilePath)); + .thenReturn(ResourceFileUtils.getResourceAsString(blueprintFilePath)); Mockito.when(blueprintArtifact.getBlueprintArtifactName()).thenReturn(artifactName); Mockito.when(blueprintArtifact.getBlueprintInvariantServiceUuid()).thenReturn(invariantServiceUuid); Mockito.when(blueprintArtifact.getResourceAttached()).thenReturn(resource); @@ -159,7 +160,7 @@ public class CsarInstallerItCase { // Mockito.when(csarHandler.getSdcCsarHelper()).thenReturn(csarHelper); Mockito.when(csarHandler.getPolicyModelYaml()) - .thenReturn(Optional.ofNullable(ResourceFileUtil.getResourceAsString("tosca/tosca_example.yaml"))); + .thenReturn(Optional.ofNullable(ResourceFileUtils.getResourceAsString("tosca/tosca_example.yaml"))); return csarHandler; } @@ -182,9 +183,10 @@ public class CsarInstallerItCase { CsarHandler csarHandler = new CsarHandler(notificationData, "", ""); csarHandler - .setFilePath(Thread.currentThread().getContextClassLoader().getResource(CSAR_ARTIFACT_NAME_CDS).getFile()); + .setFilePath(Thread.currentThread().getContextClassLoader().getResource(CSAR_ARTIFACT_NAME_CDS). + getFile()); Assert.assertEquals(csarHandler.getPolicyModelYaml(), Optional - .ofNullable(ResourceFileUtil.getResourceAsString("example/sdc/expected-result/policy-data.yaml"))); + .ofNullable(ResourceFileUtils.getResourceAsString("example/sdc/expected-result/policy-data.yaml"))); } @Test @@ -235,11 +237,11 @@ public class CsarInstallerItCase { "1.0", RESOURCE_INSTANCE_NAME_RESOURCE1, "tca.yaml")).get(); assertThat(loopTemplate.getLoopElementModelsUsed()).hasSize(1); assertThat(loopTemplate.getModelService().getServiceUuid()).isEqualTo("63cac700-ab9a-4115-a74f-7eac85e3fce0"); - JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/model-properties.json"), + JSONAssert.assertEquals(ResourceFileUtils.getResourceAsString("tosca/model-properties.json"), JsonUtils.GSON_JPA_MODEL.toJson(loopTemplate.getModelService()), true); - JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/service-details.json"), + JSONAssert.assertEquals(ResourceFileUtils.getResourceAsString("tosca/service-details.json"), JsonUtils.GSON_JPA_MODEL.toJson(loopTemplate.getModelService().getServiceDetails()), true); - JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/resource-details.json"), + JSONAssert.assertEquals(ResourceFileUtils.getResourceAsString("tosca/resource-details.json"), JsonUtils.GSON_JPA_MODEL.toJson(loopTemplate.getModelService().getResourceDetails()), true); assertThat(((LoopTemplateLoopElementModel) (loopTemplate.getLoopElementModelsUsed().toArray()[0])) .getLoopElementModel().getName()).isNotEmpty(); diff --git a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java index 6827bf5f..1d6940f8 100644 --- a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java +++ b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java @@ -35,7 +35,7 @@ import java.io.IOException; import java.util.Random; import org.junit.Test; import org.onap.clamp.clds.util.JsonUtils; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.onap.clamp.loop.log.LogType; import org.onap.clamp.loop.log.LoopLog; import org.onap.clamp.loop.service.Service; @@ -111,7 +111,7 @@ public class LoopToJsonTest { Loop loopTest = getLoop("ControlLoopTest", "yamlcontent", "{\"testname\":\"testvalue\"}", "123456789", "https://dcaetest.org", "UUID-blueprint"); OperationalPolicy opPolicy = this.getOperationalPolicy( - ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), "GuardOpPolicyTest"); + ResourceFileUtils.getResourceAsString("tosca/operational-policy-properties.json"), "GuardOpPolicyTest"); loopTest.addOperationalPolicy(opPolicy); MicroServicePolicy microServicePolicy = getMicroServicePolicy("configPolicyTest", "", "{\"configtype\":\"json\"}", "tosca_definitions_version: tosca_simple_yaml_1_0_0", @@ -156,7 +156,7 @@ public class LoopToJsonTest { "123456789", "https://dcaetest.org", "UUID-blueprint"); JsonObject jsonModel = new GsonBuilder().create() - .fromJson(ResourceFileUtil.getResourceAsString("tosca/model-properties.json"), JsonObject.class); + .fromJson(ResourceFileUtils.getResourceAsString("tosca/model-properties.json"), JsonObject.class); Service service = new Service(jsonModel.get("serviceDetails").getAsJsonObject(), jsonModel.get("resourceDetails").getAsJsonObject(), "1.0"); loopTest2.setModelService(service); diff --git a/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java b/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java index 02135933..6a646e3e 100644 --- a/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java +++ b/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java @@ -32,7 +32,7 @@ import org.apache.camel.Message; import org.junit.Test; import org.mockito.Mockito; import org.onap.clamp.clds.config.LegacyOperationalPolicyController; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.onap.clamp.loop.components.external.ExternalComponentState; import org.onap.clamp.loop.components.external.PolicyComponent; import org.onap.clamp.loop.template.LoopTemplate; @@ -290,7 +290,7 @@ public class PolicyComponentTest { loopTest.setLoopTemplate(loopTemplate); String payload = PolicyComponent.createPoliciesPayloadPdpGroup(loopTest, "POST"); - String expectedRes = ResourceFileUtil.getResourceAsString("tosca/pdp-group-policy-payload.json"); + String expectedRes = ResourceFileUtils.getResourceAsString("tosca/pdp-group-policy-payload.json"); assertThat(payload).isEqualTo(expectedRes); } diff --git a/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java b/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java index b16aa558..6f6cad81 100644 --- a/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java +++ b/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java @@ -37,7 +37,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.Application; import org.onap.clamp.clds.util.JsonUtils; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.onap.clamp.loop.template.PolicyModel; import org.onap.clamp.loop.template.PolicyModelId; import org.onap.clamp.loop.template.PolicyModelsRepository; @@ -125,7 +125,7 @@ public class PolicyModelServiceItCase { @Transactional public void shouldCreatePolicyModelFromTosca() throws IOException { String toscaModelYaml = - ResourceFileUtil.getResourceAsString("tosca/tosca_with_metadata.yaml"); + ResourceFileUtils.getResourceAsString("tosca/tosca_with_metadata.yaml"); PolicyModel policyModel = policyModelsService.createNewPolicyModelFromTosca(toscaModelYaml); assertThat(policyModelsService.getAllPolicyModels()).contains(policyModel); @@ -143,10 +143,10 @@ public class PolicyModelServiceItCase { @Transactional public void shouldUpdatePolicyModel() throws IOException { String toscaModelYaml = - ResourceFileUtil.getResourceAsString("tosca/tosca_with_metadata.yaml"); + ResourceFileUtils.getResourceAsString("tosca/tosca_with_metadata.yaml"); PolicyModel policyModel = policyModelsService.createNewPolicyModelFromTosca(toscaModelYaml); String newToscaModelYaml = - ResourceFileUtil.getResourceAsString("tosca/tosca_metadata_clamp_possible_values.yaml"); + ResourceFileUtils.getResourceAsString("tosca/tosca_metadata_clamp_possible_values.yaml"); PolicyModel updatedPolicyModel = policyModelsService.updatePolicyModelTosca( policyModel.getPolicyModelType(), policyModel.getVersion(), newToscaModelYaml); diff --git a/src/test/java/org/onap/clamp/loop/deploy/BlueprintInputParametersTest.java b/src/test/java/org/onap/clamp/loop/deploy/BlueprintInputParametersTest.java index 2b3b4825..8a5b5876 100644 --- a/src/test/java/org/onap/clamp/loop/deploy/BlueprintInputParametersTest.java +++ b/src/test/java/org/onap/clamp/loop/deploy/BlueprintInputParametersTest.java @@ -33,7 +33,7 @@ import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; import org.onap.clamp.clds.util.JsonUtils; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.onap.clamp.loop.Loop; import org.onap.clamp.loop.template.LoopElementModel; import org.onap.clamp.loop.template.LoopTemplate; @@ -56,7 +56,7 @@ public class BlueprintInputParametersTest { Mockito.when(umService1.getName()).thenReturn("testName1"); LoopElementModel loopElement = Mockito.mock(LoopElementModel.class); - String blueprint1 = ResourceFileUtil.getResourceAsString("example/sdc/blueprint-dcae/tca.yaml"); + String blueprint1 = ResourceFileUtils.getResourceAsString("example/sdc/blueprint-dcae/tca.yaml"); Mockito.when(loopElement.getBlueprint()).thenReturn(blueprint1); Mockito.when(umService1.getLoopElementModel()).thenReturn(loopElement); @@ -64,7 +64,7 @@ public class BlueprintInputParametersTest { Mockito.when(umService2.getName()).thenReturn("testName2"); LoopElementModel loopElement2 = Mockito.mock(LoopElementModel.class); - String blueprint2 = ResourceFileUtil.getResourceAsString("example/sdc/blueprint-dcae/tca_2.yaml"); + String blueprint2 = ResourceFileUtils.getResourceAsString("example/sdc/blueprint-dcae/tca_2.yaml"); Mockito.when(loopElement2.getBlueprint()).thenReturn(blueprint2); Mockito.when(umService2.getLoopElementModel()).thenReturn(loopElement2); @@ -72,7 +72,7 @@ public class BlueprintInputParametersTest { Mockito.when(umService3.getName()).thenReturn("testName3"); LoopElementModel loopElement3 = Mockito.mock(LoopElementModel.class); - String blueprint3 = ResourceFileUtil.getResourceAsString("example/sdc/blueprint-dcae/tca_3.yaml"); + String blueprint3 = ResourceFileUtils.getResourceAsString("example/sdc/blueprint-dcae/tca_3.yaml"); Mockito.when(loopElement3.getBlueprint()).thenReturn(blueprint3); Mockito.when(umService3.getLoopElementModel()).thenReturn(loopElement3); @@ -90,7 +90,7 @@ public class BlueprintInputParametersTest { JsonObject paramJson = DcaeDeployParameters.getDcaeDeploymentParametersInJson(loop); Assert.assertEquals(JsonUtils.GSON_JPA_MODEL.toJson(paramJson), - ResourceFileUtil.getResourceAsString( + ResourceFileUtils.getResourceAsString( "example/sdc/expected-result/deployment-parameters-multi-blueprints.json")); } @@ -112,14 +112,14 @@ public class BlueprintInputParametersTest { LoopTemplate template = Mockito.mock(LoopTemplate.class); Mockito.when(template.getUniqueBlueprint()).thenReturn(true); - String blueprint = ResourceFileUtil.getResourceAsString("example/sdc/blueprint-dcae/tca.yaml"); + String blueprint = ResourceFileUtils.getResourceAsString("example/sdc/blueprint-dcae/tca.yaml"); Mockito.when(template.getBlueprint()).thenReturn(blueprint); Mockito.when(loop.getLoopTemplate()).thenReturn(template); JsonObject paramJson = DcaeDeployParameters.getDcaeDeploymentParametersInJson(loop); Assert.assertEquals(JsonUtils.GSON_JPA_MODEL.toJson(paramJson), - ResourceFileUtil.getResourceAsString( + ResourceFileUtils.getResourceAsString( "example/sdc/expected-result/deployment-parameters-single-blueprint.json")); } } diff --git a/src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java b/src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java index 01e2184a..0bfb6ece 100644 --- a/src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java +++ b/src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java @@ -27,7 +27,7 @@ import com.google.gson.JsonObject; import java.io.IOException; import org.junit.Test; import org.onap.clamp.clds.util.JsonUtils; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.onap.clamp.loop.template.PolicyModel; import org.skyscreamer.jsonassert.JSONAssert; @@ -37,10 +37,10 @@ public class MicroServicePayloadTest { public void testPayloadConstruction() throws IOException { MicroServicePolicy policy = new MicroServicePolicy("testPolicy", new PolicyModel( "onap.policies.monitoring.cdap.tca.hi.lo.app", - ResourceFileUtil.getResourceAsString("tosca/tosca_example.yaml"),"1.0.0"), false,null,null, null,null); + ResourceFileUtils.getResourceAsString("tosca/tosca_example.yaml"),"1.0.0"), false,null,null, null,null); policy.setConfigurationsJson(JsonUtils.GSON.fromJson( - ResourceFileUtil.getResourceAsString("tosca/micro-service-policy-properties.json"), JsonObject.class)); - JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/micro-service-policy-payload.json"), + ResourceFileUtils.getResourceAsString("tosca/micro-service-policy-properties.json"), JsonObject.class)); + JSONAssert.assertEquals(ResourceFileUtils.getResourceAsString("tosca/micro-service-policy-payload.json"), policy.createPolicyPayload(), false); } } diff --git a/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java b/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java index cef82e50..36f00072 100644 --- a/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java +++ b/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java @@ -28,35 +28,34 @@ import static org.assertj.core.api.Assertions.assertThat; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import java.io.IOException; -import java.util.Map; + import org.junit.Test; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.onap.clamp.loop.template.PolicyModel; import org.onap.clamp.policy.operational.LegacyOperationalPolicy; import org.onap.clamp.policy.operational.OperationalPolicy; -import org.skyscreamer.jsonassert.JSONAssert; public class OperationalPolicyPayloadTest { @Test public void testOperationalPolicyLegacyPayloadConstruction() throws IOException { JsonObject jsonConfig = new GsonBuilder().create().fromJson( - ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class); + ResourceFileUtils.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class); OperationalPolicy policy = new OperationalPolicy("testPolicy.legacy", jsonConfig, null, new PolicyModel("onap.policies.controlloop.Operational.legacy", "", "1.0.0", "test"), null, null, null); assertThat(policy.createPolicyPayloadYaml()) - .isEqualTo(ResourceFileUtil.getResourceAsString("tosca/operational-policy-payload.yaml")); + .isEqualTo(ResourceFileUtils.getResourceAsString("tosca/operational-policy-payload.yaml")); assertThat(policy.createPolicyPayload()) - .isEqualTo(ResourceFileUtil.getResourceAsString("tosca/operational-policy-payload.json")); + .isEqualTo(ResourceFileUtils.getResourceAsString("tosca/operational-policy-payload.json")); } @Test public void testLegacyOperationalPolicyPayloadConstruction() throws IOException { JsonObject jsonConfig = new GsonBuilder().create().fromJson( - ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class); + ResourceFileUtils.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class); assertThat(LegacyOperationalPolicy.createPolicyPayloadYamlLegacy(jsonConfig.get("operational_policy"))) - .isEqualTo(ResourceFileUtil.getResourceAsString("tosca/operational-policy-payload-legacy.yaml")); + .isEqualTo(ResourceFileUtils.getResourceAsString("tosca/operational-policy-payload-legacy.yaml")); } } diff --git a/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java b/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java index 4f728b44..322548bb 100644 --- a/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java +++ b/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java @@ -29,7 +29,7 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import java.io.IOException; import org.junit.Test; -import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.clds.util.ResourceFileUtils; import org.onap.clamp.loop.service.Service; import org.skyscreamer.jsonassert.JSONAssert; @@ -37,7 +37,7 @@ public class OperationalPolicyRepresentationBuilderTest { @Test public void testOperationalPolicyPayloadConstruction() throws IOException { - JsonObject jsonModel = new GsonBuilder().create().fromJson(ResourceFileUtil + JsonObject jsonModel = new GsonBuilder().create().fromJson(ResourceFileUtils .getResourceAsString("tosca/model-properties-operational-policy.json"), JsonObject.class); Service service = new Service(jsonModel.get("serviceDetails").getAsJsonObject(), jsonModel.get("resourceDetails").getAsJsonObject(), "1.0"); @@ -46,14 +46,14 @@ public class OperationalPolicyRepresentationBuilderTest { assertThat(jsonSchema).isNotNull(); - JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/operational-policy-json-schema.json"), + JSONAssert.assertEquals(ResourceFileUtils.getResourceAsString("tosca/operational-policy-json-schema.json"), new GsonBuilder().create().toJson(jsonSchema), false); } @Test public void testOperationalPolicyPayloadConstructionForCds() throws IOException { JsonObject jsonModel = new GsonBuilder().create() - .fromJson(ResourceFileUtil.getResourceAsString("tosca/model-properties-cds.json"), JsonObject.class); + .fromJson(ResourceFileUtils.getResourceAsString("tosca/model-properties-cds.json"), JsonObject.class); Service service = new Service(jsonModel.get("serviceDetails").getAsJsonObject(), jsonModel.get("resourceDetails").getAsJsonObject(), "1.0"); @@ -61,7 +61,7 @@ public class OperationalPolicyRepresentationBuilderTest { JsonObject jsonSchema = OperationalPolicyRepresentationBuilder.generateOperationalPolicySchema(service); assertThat(jsonSchema).isNotNull(); JSONAssert.assertEquals( - ResourceFileUtil.getResourceAsString("tosca/operational-policy-cds-payload-with-list.json"), + ResourceFileUtils.getResourceAsString("tosca/operational-policy-cds-payload-with-list.json"), new GsonBuilder().create().toJson(jsonSchema), false); } } diff --git a/src/test/resources/https/https-test.properties b/src/test/resources/https/https-test.properties index df1823f8..6f3a405f 100644 --- a/src/test/resources/https/https-test.properties +++ b/src/test/resources/https/https-test.properties @@ -36,6 +36,7 @@ server.ssl.key-alias=clamp@clamp.onap.org # The key file used to decode the key store and trust store password # If not defined, the key store and trust store password will not be decrypted clamp.config.keyFile=classpath:clds/aaf/org.onap.clamp.keyfile +clamp.config.caCerts=classpath:clds/aaf/ssl/ca-certs.pem ## Config part for Client certificates server.ssl.client-auth=want |