aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authormark.j.leonard <mark.j.leonard@gmail.com>2018-06-27 11:46:19 +0100
committermark.j.leonard <mark.j.leonard@gmail.com>2018-06-27 11:46:37 +0100
commitdc94e09008ba0eb9dce7541d2c898ddc5c500814 (patch)
tree8bf2edf12dcf5062f120210be85d1e4f337ece2e /src/test/java
parentf3bf5dd360b93fd7ef6cc8d871a9903de9f27e5a (diff)
Remove the Generator Constants class
Move the String constants out of a common class and into the individual classes where they are used. This eliminates a set of Sonar code smells relating to non-standard ordering of declarations. It simplifies the code by removing the need for an empty private constructor in the static class (i.e. containing static methods only). Additionally, simplify the AaiModelGenerator interface by removing the static factory method (which is not currently required). If multiple implementations are needed we can use Spring annotations in the future. Issue-ID: AAI-1242 Change-Id: Ica03b66ae2fd899977093d11d3e23dc3f3c8f194 Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/onap/aai/babel/csar/extractor/YamlExtractorTest.java2
-rw-r--r--src/test/java/org/onap/aai/babel/parser/TestToscaParser.java7
-rw-r--r--src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java6
-rw-r--r--src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java18
4 files changed, 15 insertions, 18 deletions
diff --git a/src/test/java/org/onap/aai/babel/csar/extractor/YamlExtractorTest.java b/src/test/java/org/onap/aai/babel/csar/extractor/YamlExtractorTest.java
index b53f38d..f783e7c 100644
--- a/src/test/java/org/onap/aai/babel/csar/extractor/YamlExtractorTest.java
+++ b/src/test/java/org/onap/aai/babel/csar/extractor/YamlExtractorTest.java
@@ -129,7 +129,7 @@ public class YamlExtractorTest {
try {
new YamlExtractor().extract(archive, name, version);
fail("An instance of InvalidArchiveException should have been thrown");
- } catch (Exception ex) {
+ } catch (InvalidArchiveException ex) {
assertTrue(ex instanceof InvalidArchiveException);
assertEquals(expectedErrorMessage, ex.getLocalizedMessage());
}
diff --git a/src/test/java/org/onap/aai/babel/parser/TestToscaParser.java b/src/test/java/org/onap/aai/babel/parser/TestToscaParser.java
index d27396d..a73e64c 100644
--- a/src/test/java/org/onap/aai/babel/parser/TestToscaParser.java
+++ b/src/test/java/org/onap/aai/babel/parser/TestToscaParser.java
@@ -40,7 +40,6 @@ import org.onap.aai.babel.xml.generator.api.AaiArtifactGenerator;
import org.onap.aai.babel.xml.generator.data.AdditionalParams;
import org.onap.aai.babel.xml.generator.data.Artifact;
import org.onap.aai.babel.xml.generator.data.GenerationData;
-import org.onap.aai.babel.xml.generator.data.GeneratorConstants;
import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
/**
@@ -54,10 +53,12 @@ public class TestToscaParser {
}
}
+ private static final String ARTIFACT_GENERATOR_CONFIG = "artifact-generator.properties";
+
@Before
public void setup() throws FileNotFoundException, IOException {
- System.setProperty(GeneratorConstants.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE,
- new ArtifactTestUtils().getResourcePath("artifact-generator.properties"));
+ System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE,
+ new ArtifactTestUtils().getResourcePath(ARTIFACT_GENERATOR_CONFIG));
InputStream in = TestToscaParser.class.getClassLoader().getResourceAsStream("artifact-generator.properties");
Properties properties = new Properties();
properties.load(in);
diff --git a/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java b/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java
index 0bc7c31..0d6c7b3 100644
--- a/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java
+++ b/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java
@@ -37,10 +37,10 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onap.aai.babel.csar.CsarConverterException;
import org.onap.aai.babel.csar.CsarToXmlConverter;
+import org.onap.aai.babel.parser.ArtifactGeneratorToscaParser;
import org.onap.aai.babel.service.data.BabelArtifact;
import org.onap.aai.babel.util.ArtifactTestUtils;
import org.onap.aai.babel.xml.generator.XmlArtifactGenerationException;
-import org.onap.aai.babel.xml.generator.data.GeneratorConstants;
/**
* Tests {@link CsarToXmlConverter}
@@ -84,7 +84,7 @@ public class CsarToXmlConverterTest {
@Before
public void setup() {
- System.setProperty(GeneratorConstants.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE,
+ System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE,
new ArtifactTestUtils().getResourcePath(ARTIFACT_GENERATOR_CONFIG));
converter = new CsarToXmlConverter();
}
@@ -126,7 +126,7 @@ public class CsarToXmlConverterTest {
exception.expectMessage("Cannot generate artifacts. artifactgenerator.config system property not configured");
// Unset the required system property
- System.clearProperty(GeneratorConstants.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE);
+ System.clearProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE);
converter.generateXmlFromCsar(CsarTest.VALID_CSAR_FILE.getContent(), CsarTest.VALID_CSAR_FILE.getName(),
SERVICE_VERSION);
}
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 4cc8c8c..b5063dd 100644
--- a/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
+++ b/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
@@ -41,8 +41,8 @@ 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.util.ArtifactTestUtils;
-import org.onap.aai.babel.xml.generator.data.GeneratorConstants;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -52,7 +52,7 @@ 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 {
@@ -62,13 +62,14 @@ public class TestGenerateArtifactsServiceImpl {
System.setProperty("CONFIG_HOME", "src/test/resources");
}
+ private static final String ARTIFACT_GENERATOR_CONFIG = "artifact-generator.properties";
@Inject
private AAIMicroServiceAuth auth;
@BeforeClass
public static void setup() {
- System.setProperty(GeneratorConstants.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE,
- new ArtifactTestUtils().getResourcePath("artifact-generator.properties"));
+ System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE,
+ new ArtifactTestUtils().getResourcePath(ARTIFACT_GENERATOR_CONFIG));
}
@Test
@@ -109,8 +110,7 @@ public class TestGenerateArtifactsServiceImpl {
/**
* Create a (mocked) HTTPS request and invoke the Babel generate artifacts API
*
- * @param resource
- * path to the incoming JSON request
+ * @param resource path to the incoming JSON request
* @return the Response from the HTTP API
* @throws URISyntaxException
* @throws IOException
@@ -144,7 +144,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);
@@ -156,10 +156,6 @@ public class TestGenerateArtifactsServiceImpl {
return new ArtifactTestUtils().getRequestJson(resource);
}
- private String getResponseJson(String jsonResponse) throws IOException, URISyntaxException {
- return new ArtifactTestUtils().getResponseJson(jsonResponse);
- }
-
private List<String> createSingletonList(String listItem) {
return Collections.<String>singletonList(listItem);
}