summaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorxg353y <xg353y@intl.att.com>2018-05-18 17:59:06 +0200
committerxg353y <xg353y@intl.att.com>2018-05-22 14:46:36 +0200
commit2aad6d681dcbea5564425648375f7ddca2080940 (patch)
tree34a3c864b1369c961b0998a1f3e808713f62bb3c /src/test/java/org
parentf172e9d4656c960e81f72cc6d6e52770271df9c9 (diff)
Generate API documents
Adding maven plugins to scan Clamp code automatically and generate swagger.json, html and pdf documents with the exposed Clamp API information. Issue-ID: CLAMP-169 Change-Id: Ia46cd2aa7000251b30c9eaaa040f1f8d9246af45 Signed-off-by: xg353y <xg353y@intl.att.com>
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java3
-rw-r--r--src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java3
-rw-r--r--src/test/java/org/onap/clamp/clds/swagger/SwaggerConfig.java46
-rw-r--r--src/test/java/org/onap/clamp/clds/swagger/SwaggerGenerationTest.java42
4 files changed, 92 insertions, 2 deletions
diff --git a/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java b/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java
index f0db51293..36cbc590c 100644
--- a/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java
@@ -32,6 +32,7 @@ import java.security.GeneralSecurityException;
import java.util.List;
import org.apache.commons.codec.DecoderException;
+import org.json.JSONException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -87,7 +88,7 @@ public class SdcReqItCase {
}
@Test
- public void formatSdcReqTest() {
+ public void formatSdcReqTest() throws JSONException {
String jsonResult = sdcReq.formatSdcReq("payload", "artifactName", "artifactLabel", "artifactType");
JSONAssert.assertEquals(
"{\"payloadData\" : \"cGF5bG9hZA==\",\"artifactLabel\" : \"artifactLabel\",\"artifactName\" :\"artifactName\",\"artifactType\" : \"artifactType\","
diff --git a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
index 222f757e0..56d29d525 100644
--- a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
@@ -38,6 +38,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.json.JSONException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
@@ -149,7 +150,7 @@ public class CsarInstallerItCase {
@Test
public void testInstallTheCsarTca()
- throws SdcArtifactInstallerException, SdcToscaParserException, CsarHandlerException, IOException {
+ throws SdcArtifactInstallerException, SdcToscaParserException, CsarHandlerException, IOException, JSONException {
String generatedName = RandomStringUtils.randomAlphanumeric(5);
CsarHandler csar = buildFakeCsarHandler(generatedName);
csarInstaller.installTheCsar(csar);
diff --git a/src/test/java/org/onap/clamp/clds/swagger/SwaggerConfig.java b/src/test/java/org/onap/clamp/clds/swagger/SwaggerConfig.java
new file mode 100644
index 000000000..87409644d
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/swagger/SwaggerConfig.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2018 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.swagger;
+
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.service.*;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+
+
+
+@EnableSwagger2
+@Configuration
+public class SwaggerConfig {
+
+ private ApiInfo apiInfo() {
+ return new ApiInfoBuilder()
+ .title("Clamp")
+ .description("Clamp API Description")
+ .license("Apache 2.0")
+ .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
+ .build();
+ }
+}
diff --git a/src/test/java/org/onap/clamp/clds/swagger/SwaggerGenerationTest.java b/src/test/java/org/onap/clamp/clds/swagger/SwaggerGenerationTest.java
new file mode 100644
index 000000000..a4691b164
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/swagger/SwaggerGenerationTest.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2018 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.swagger;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import io.github.swagger2markup.Swagger2MarkupConverter;
+import org.onap.clamp.clds.Application;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest(classes = {Application.class, SwaggerConfig.class})
+public class SwaggerGenerationTest {
+
+ @Test
+ public void convertRemoteSwaggerToAsciiDoc() {
+ Path localSwaggerFile = Paths.get("docs/swagger/swagger.json");
+ Swagger2MarkupConverter.from(localSwaggerFile).build();
+ }
+}