X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fbabel%2Fservice%2FTestGenerateArtifactsServiceImpl.java;h=be02e179bce60a8096cc80b675ebeda60a569a7d;hb=ff0718120f36e14b065047f0b3f29665f2191e53;hp=78e02f4d4134c5b69022983314a98533d3e0f854;hpb=e4cc64bb1b7c0acba0fe11160469c03b94bd5be2;p=aai%2Fbabel.git diff --git a/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java b/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java index 78e02f4..be02e17 100644 --- a/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java +++ b/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 European Software Marketing Ltd. + * Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2017-2019 European Software Marketing Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.aai.babel.service; import static org.hamcrest.Matchers.is; @@ -42,7 +43,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; import org.onap.aai.auth.AAIMicroServiceAuth; -import org.onap.aai.babel.parser.ArtifactGeneratorToscaParser; import org.onap.aai.babel.service.data.BabelRequest; import org.onap.aai.babel.testdata.CsarTest; import org.onap.aai.babel.util.ArtifactTestUtils; @@ -55,28 +55,19 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:/babel-beans.xml" }) +@ContextConfiguration(locations = {"classpath:/babel-beans.xml"}) public class TestGenerateArtifactsServiceImpl { static { - if (System.getProperty("APP_HOME") == null) { - System.setProperty("APP_HOME", "."); - } System.setProperty("CONFIG_HOME", "src/test/resources"); } - private static final String ARTIFACT_GENERATOR_CONFIG = "artifact-generator.properties"; - private static final String FILTER_TYPES_CONFIG = "filter-types.properties"; - @Inject private AAIMicroServiceAuth auth; @BeforeClass public static void setup() { - System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE, - new ArtifactTestUtils().getResourcePath(ARTIFACT_GENERATOR_CONFIG)); - System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_GROUP_FILTERS_CONFIG_FILE, - new ArtifactTestUtils().getResourcePath(FILTER_TYPES_CONFIG)); + new ArtifactTestUtils().setGeneratorSystemProperties(); } @Test @@ -88,11 +79,14 @@ public class TestGenerateArtifactsServiceImpl { /** * No VNF Configuration exists. - * - * @throws Exception + * + * @throws URISyntaxException + * if the URI cannot be created + * @throws IOException + * if the resource cannot be loaded */ @Test - public void testGenerateArtifactsWithoutVnfConfiguration() throws Exception { + public void testGenerateArtifactsWithoutVnfConfiguration() throws IOException, URISyntaxException { Response response = processJsonRequest(CsarTest.NO_VNF_CONFIG_CSAR); assertThat(response.getStatus(), is(Response.Status.OK.getStatusCode())); assertThat(response.getEntity(), is(getResponseJson("validNoVnfConfigurationResponse.json"))); @@ -150,6 +144,7 @@ public class TestGenerateArtifactsServiceImpl { * Create a (mocked) HTTPS request and invoke the Babel generate artifacts API. * * @param csar + * test CSAR file * @return the Response from the HTTP API * @throws URISyntaxException * if the URI cannot be created @@ -199,7 +194,7 @@ public class TestGenerateArtifactsServiceImpl { Mockito.when(mockCertificate.getSubjectX500Principal()) .thenReturn(new X500Principal("CN=test, OU=qa, O=Test Ltd, L=London, ST=London, C=GB")); - servletRequest.setAttribute("javax.servlet.request.X509Certificate", new X509Certificate[] { mockCertificate }); + servletRequest.setAttribute("javax.servlet.request.X509Certificate", new X509Certificate[] {mockCertificate}); servletRequest.setAttribute("javax.servlet.request.cipher_suite", ""); GenerateArtifactsServiceImpl service = new GenerateArtifactsServiceImpl(auth);