diff options
author | Timoney, Dan (dt5972) <dt5972@att.com> | 2021-10-29 14:47:40 -0400 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2021-11-01 10:17:41 -0400 |
commit | 5b935a9086ec1080f896b9a71c52283122aa0163 (patch) | |
tree | f28aee1327e5b6c8ad423dec5950d46f66ac201b /ms/sanity-test/sanity-test-app | |
parent | 53b2788231f5ab3aeda4f09e1445a02c3a3b6be9 (diff) |
Sync local changes to support GRA microservice
Sync changes made downstream to support GRA microservice
Change-Id: If3bf5d879f7d61ab91209c63b0344d78128246a8
Issue-ID: CCSDK-3504
Signed-off-by: Dan Timoney <dtimoney@att.com>
Diffstat (limited to 'ms/sanity-test/sanity-test-app')
5 files changed, 722 insertions, 0 deletions
diff --git a/ms/sanity-test/sanity-test-app/.swagger-codegen-ignore b/ms/sanity-test/sanity-test-app/.swagger-codegen-ignore new file mode 100644 index 0000000..1ed686e --- /dev/null +++ b/ms/sanity-test/sanity-test-app/.swagger-codegen-ignore @@ -0,0 +1,4 @@ +**/OperationsApiController.java +**/OperationalApiController.java +**/ConfigApiController.java +**/Swagger2SpringBoot.java
\ No newline at end of file diff --git a/ms/sanity-test/sanity-test-app/pom.xml b/ms/sanity-test/sanity-test-app/pom.xml new file mode 100644 index 0000000..9c273af --- /dev/null +++ b/ms/sanity-test/sanity-test-app/pom.xml @@ -0,0 +1,311 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.onap.sdnc.apps</groupId> + <artifactId>sanity-test</artifactId> + <version>2.3.0-SNAPSHOT</version> + </parent> + + <groupId>org.onap.sdnc.apps</groupId> + <artifactId>sanity-test-app</artifactId> + <version>2.3.0-SNAPSHOT</version> + <packaging>jar</packaging> + + <name>sdnc-apps :: ms :: sanity-test :: ${project.artifactId}</name> + <description>Sanity Test API application</description> + <url>http://wiki.onap.org</url> + + <properties> + <start-class>org.onap.sdnc.apps.ms.sanitytest.SanityTestMs</start-class> + <liquibase.properties>${project.basedir}/src/main/resources/liquibase.properties</liquibase.properties> + <maven.compiler.source>1.11</maven.compiler.source> + <maven.compiler.target>1.11</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + <exclusions> + <exclusion> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-log4j2</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-xml</artifactId> + </dependency> + <dependency> + <groupId>org.onap.aaf.authz</groupId> + <artifactId>aaf-auth-client</artifactId> + <version>${aaf.cadi.version}</version> + </dependency> + <dependency> + <groupId>org.onap.aaf.authz</groupId> + <artifactId>aaf-cadi-aaf</artifactId> + <version>${aaf.cadi.version}</version> + </dependency> + <dependency> + <groupId>org.onap.aaf.authz</groupId> + <artifactId>aaf-misc-env</artifactId> + <version>${aaf.cadi.version}</version> + </dependency> + <dependency> + <groupId>org.onap.aaf.authz</groupId> + <artifactId>aaf-misc-rosetta</artifactId> + <version>${aaf.cadi.version}</version> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-jpa</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-validation</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + <dependency> + <groupId>io.springfox</groupId> + <artifactId>springfox-swagger2</artifactId> + <version>3.0.0</version> + </dependency> + <dependency> + <groupId>io.springfox</groupId> + <artifactId>springfox-swagger-ui</artifactId> + <version>3.0.0</version> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.apps</groupId> + <artifactId>services</artifactId> + <version>${ccsdk.apps.version}</version> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.sli.core</groupId> + <artifactId>sli-common</artifactId> + <version>${ccsdk.sli.core.version}</version> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.sli.core</groupId> + <artifactId>sli-provider-base</artifactId> + <version>${ccsdk.sli.core.version}</version> + </dependency> + <dependency> + <groupId>org.onap.logging-analytics</groupId> + <artifactId>logging-filter-spring</artifactId> + <version>1.6.6</version> + </dependency> + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.sli.core</groupId> + <artifactId>sliPluginUtils-provider</artifactId> + <version>${ccsdk.sli.core.version}</version> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.sli.adaptors</groupId> + <artifactId>mdsal-resource-provider</artifactId> + <version>${ccsdk.sli.adaptors.version}</version> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.sli.adaptors.messagerouter</groupId> + <artifactId>publisher.provider</artifactId> + <version>${ccsdk.sli.adaptors.version}</version> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.sli.adaptors</groupId> + <artifactId>netbox-client-provider</artifactId> + <version>${ccsdk.sli.adaptors.version}</version> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.sli.adaptors</groupId> + <artifactId>sql-resource-provider</artifactId> + <version>${ccsdk.sli.adaptors.version}</version> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.sli.plugins</groupId> + <artifactId>restapi-call-node-provider</artifactId> + <version>${ccsdk.sli.plugins.version}</version> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.sli.plugins</groupId> + <artifactId>properties-node-provider</artifactId> + <version>${ccsdk.sli.plugins.version}</version> + </dependency> + + <dependency> + <groupId>org.liquibase</groupId> + <artifactId>liquibase-core</artifactId> + <version>4.3.0</version> + </dependency> + + <!-- this jersey jar is needed for rest api call node to function properly --> + <dependency> + <groupId>org.glassfish.jersey.inject</groupId> + <artifactId>jersey-hk2</artifactId> + </dependency> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + </dependency> + <dependency> + <groupId>org.apache.derby</groupId> + <artifactId>derby</artifactId> + <scope>test</scope> + </dependency> + <!-- Necessary to run tests with coverage in IntelliJ --> + <dependency> + <groupId>org.junit.platform</groupId> + <artifactId>junit-platform-launcher</artifactId> + <version>1.6.2</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>3.0.2</version> + + <executions> + + <!-- DGs are needed for unit tests as well --> + <execution> + <id>unpack dgs</id> + <phase>generate-sources</phase> + <goals> + <goal>unpack</goal> + </goals> + <configuration> + <outputDirectory>${basedir}/target</outputDirectory> + <artifactItems> + <artifactItem> + <groupId>org.onap.sdnc.oam</groupId> + <artifactId>platform-logic-installer</artifactId> + <version>${sdnc.oam.version}</version> + <type>zip</type> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>io.swagger</groupId> + <artifactId>swagger-codegen-maven-plugin</artifactId> + <version>2.3.1</version> + <executions> + <execution> + <phase>generate-sources</phase> + <goals> + <goal>generate</goal> + </goals> + <configuration> + <output>target/generated-sources</output> + <inputSpec>${project.basedir}/src/main/yaml/sanitytest-api.yaml</inputSpec> + <language>spring</language> + <apiPackage>org.onap.sdnc.apps.ms.sanitytest.swagger</apiPackage> + <modelPackage>org.onap.sdnc.apps.ms.sanitytest.swagger.model</modelPackage> + <invokerPackage>org.onap.sdnc.apps.ms.sanitytest.swagger</invokerPackage> + <generateApis>true</generateApis> + <generateApiTests>true</generateApiTests> + <ignoreFileOverride>${project.basedir}/.swagger-codegen-ignore</ignoreFileOverride> + <withXml>true</withXml> + <templateDirectory>${project.basedir}/src/main/templates</templateDirectory> + <configOptions> + <java8>true</java8> + <springBootVersion>2.2.4-RELEASE</springBootVersion> + </configOptions> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <configuration> + <classifier>exec</classifier> + </configuration> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>3.0.0</version> + <executions> + <execution> + <id>addSource</id> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>${project.basedir}/target/generated-sources/src/main/java</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.19.1</version> + <configuration> + <environmentVariables> + <SDNC_CONFIG_DIR>${basedir}/src/test/resources</SDNC_CONFIG_DIR> + <SVCLOGIC_PROPERTIES>${basedir}/src/test/resources/svclogic.properties</SVCLOGIC_PROPERTIES> + <MYSQL_DATABASE>${gratest.mysql.database}</MYSQL_DATABASE> + <MYSQL_USER>${gratest.mysql.user}</MYSQL_USER> + <MYSQL_PASSWORD>${gratest.mysql.password}</MYSQL_PASSWORD> + </environmentVariables> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + <configuration> + <skipITs>true</skipITs> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/ms/sanity-test/sanity-test-app/src/main/java/org/onap/sdnc/apps/ms/sanitytest/controllers/SanityTestOperationsApi.java b/ms/sanity-test/sanity-test-app/src/main/java/org/onap/sdnc/apps/ms/sanitytest/controllers/SanityTestOperationsApi.java new file mode 100644 index 0000000..d1b7233 --- /dev/null +++ b/ms/sanity-test/sanity-test-app/src/main/java/org/onap/sdnc/apps/ms/sanitytest/controllers/SanityTestOperationsApi.java @@ -0,0 +1,164 @@ +package org.onap.sdnc.apps.ms.sanitytest.controllers; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.Optional; +import java.util.Properties; +import java.util.TimeZone; + +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.onap.ccsdk.apps.services.RestException; +import org.onap.ccsdk.apps.services.SvcLogicFactory; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicLoader; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase; +import org.onap.sdnc.apps.ms.sanitytest.swagger.OperationsApi; +import org.onap.sdnc.apps.ms.sanitytest.swagger.model.SanitytestApiInputBodyparam; +import org.onap.sdnc.apps.ms.sanitytest.swagger.model.SanitytestApiRequestInformation; +import org.onap.sdnc.apps.ms.sanitytest.swagger.model.SanitytestApiResponseField; +import org.onap.sdnc.apps.ms.sanitytest.swagger.model.SanitytestApiResponseFields; +import org.onap.sdnc.apps.ms.sanitytest.swagger.model.SanitytestApiResultEnumeration; +import org.onap.sdnc.apps.ms.sanitytest.swagger.model.SanitytestApiServiceConfigurationOperation; +import org.onap.sdnc.apps.ms.sanitytest.swagger.model.SanitytestApiTestListItem; +import org.onap.sdnc.apps.ms.sanitytest.swagger.model.SanitytestApiTestNameEnumeration; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; + +@Controller +@ComponentScan(basePackages = { "org.onap.sdnc.apps.ms.sanitytest.*", "org.onap.ccsdk.apps.services" }) +@Import(value = SvcLogicFactory.class) +public class SanityTestOperationsApi implements OperationsApi +{ + + private static final String MODULE_NAME = "SANITYTEST-API"; + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @Autowired + protected SvcLogicServiceBase svc; + + @Autowired + protected SvcLogicLoader svcLogicLoader; + + private static class Iso8601Util { + + private static TimeZone timeZone = TimeZone.getTimeZone("UTC"); + private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + + private Iso8601Util() { + } + + static { + dateFormat.setTimeZone(timeZone); + } + + private static String now() { + return dateFormat.format(new Date()); + } + } + + @org.springframework.beans.factory.annotation.Autowired + public SanityTestOperationsApi(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + + @Override + public Optional<ObjectMapper> getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional<HttpServletRequest> getRequest() { + return Optional.ofNullable(request); + } + + @Override + public ResponseEntity<SanitytestApiServiceConfigurationOperation> operationsSANITYTESTAPIserviceConfigurationOperationPost( + @Valid SanitytestApiInputBodyparam input) throws RestException { + final String svcOperation = "service-configuration-operation"; + SanitytestApiRequestInformation reqInfo = input.getInput().getRequestInformation(); + List<SanitytestApiTestListItem> testList = reqInfo.getTestList(); + SanitytestApiServiceConfigurationOperation retval = new SanitytestApiServiceConfigurationOperation(); + SanitytestApiResponseFields resp = new SanitytestApiResponseFields(); + + + SvcLogicContext ctxIn = new SvcLogicContext(); + + + // Add input to SvcLogicContext + try { + ctxIn.mergeJson(svcOperation + "-input", objectMapper.writeValueAsString(input.getInput())); + } catch (JsonProcessingException e) { + log.error("Caught exception trying to save input to SvcLogicContext", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + + // Call DG + try { + // Any of these can throw a nullpointer exception + // execute should only throw a SvcLogicException + SvcLogicContext ctxOut = svc.execute(MODULE_NAME, svcOperation, null, "sync", ctxIn); + Properties respProps = ctxOut.toProperties(); + + String errCode = respProps.getProperty("error-code", "200"); + + if ("200".equals(errCode)) { + // DG returns success - return test results. + + + int testcount = Integer.parseInt(respProps.getProperty("service-configuration-operation-output.response-information.response-test-list_length")); + for (int i = 0; i < testcount; i++) { + SanitytestApiResponseField respItem = new SanitytestApiResponseField(); + SanitytestApiTestListItem testItem = testList.get(i); + respItem.setResponseTestNumber(testItem.getTestNumber()); + String testName = respProps.getProperty("service-configuration-operation-output.response-information.response-test-list[" + + i + "].response-test-name"); + respItem.setResponseTestName(SanitytestApiTestNameEnumeration.fromValue(testName)); + respItem.setStartTime(respProps.getProperty("service-configuration-operation-output.response-information.response-test-list[" + + i + "].start-time")); + respItem.setEndTime(respProps.getProperty("service-configuration-operation-output.response-information.response-test-list[" + + i + "].end-time")); + respItem.setElapsedTime(respProps.getProperty("service-configuration-operation-output.response-information.response-test-list[" + + i + "].elapsed-time")); + respItem.setErrorMessage(respProps.getProperty("service-configuration-operation-output.response-information.response-test-list[" + + i + "].error-message")); + respItem.setResult(SanitytestApiResultEnumeration.fromValue(respProps.getProperty("service-configuration-operation-output.response-information.response-test-list[" + + i + "].result"))); + resp.addResponseInformationItem(respItem); + } + log.info("Returned SUCCESS for " + svcOperation); + retval.setOutput(resp); + return new ResponseEntity<> (retval, HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + + } catch (NullPointerException npe) { + log.error("Caught NPE", npe); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } catch (SvcLogicException e) { + log.error("Caught SvcLogicException", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + + +} diff --git a/ms/sanity-test/sanity-test-app/src/main/templates/api.mustache b/ms/sanity-test/sanity-test-app/src/main/templates/api.mustache new file mode 100644 index 0000000..c28642c --- /dev/null +++ b/ms/sanity-test/sanity-test-app/src/main/templates/api.mustache @@ -0,0 +1,136 @@ +/** +* NOTE: This class is auto generated by the swagger code generator program ({{{generatorVersion}}}). +* https://github.com/swagger-api/swagger-codegen +* Do not edit the class manually. +*/ +package {{package}}; + +{{#imports}}import {{import}}; +{{/imports}} +{{#jdk8-no-delegate}} + import com.fasterxml.jackson.databind.ObjectMapper; +{{/jdk8-no-delegate}} +import io.swagger.annotations.*; +{{#jdk8-no-delegate}} + import org.slf4j.Logger; + import org.slf4j.LoggerFactory; + import org.springframework.http.HttpStatus; +{{/jdk8-no-delegate}} +import org.springframework.http.ResponseEntity; +{{#useBeanValidation}} + import org.springframework.validation.annotation.Validated; +{{/useBeanValidation}} +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; +import org.onap.ccsdk.apps.services.RestException; + +{{#jdk8-no-delegate}} + import javax.servlet.http.HttpServletRequest; +{{/jdk8-no-delegate}} +{{#useBeanValidation}} + import javax.validation.Valid; + import javax.validation.constraints.*; +{{/useBeanValidation}} +{{#jdk8-no-delegate}} + import java.io.IOException; +{{/jdk8-no-delegate}} +import java.util.List; +{{#jdk8-no-delegate}} + import java.util.Optional; +{{/jdk8-no-delegate}} +{{^jdk8-no-delegate}} + {{#useOptional}} + import java.util.Optional; + {{/useOptional}} +{{/jdk8-no-delegate}} +{{#async}} + import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}}; +{{/async}} +{{>generatedAnnotation}} +@Api(value = "{{{baseName}}}", description = "the {{{baseName}}} API") +{{#operations}} + public interface {{classname}} { + {{#jdk8}} + + {{^isDelegate}} + Logger log = LoggerFactory.getLogger({{classname}}.class); + + default Optional<ObjectMapper> getObjectMapper() { + return Optional.empty(); + } + + default Optional<HttpServletRequest> getRequest() { + return Optional.empty(); + } + + default Optional<String> getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + {{/isDelegate}} + {{#isDelegate}} + {{classname}}Delegate getDelegate(); + {{/isDelegate}} + {{/jdk8}} + {{#operation}} + + @ApiOperation(value = "{{{summary}}}", nickname = "{{{operationId}}}", notes = "{{{notes}}}"{{#returnBaseType}}, response = {{{returnBaseType}}}.class{{/returnBaseType}}{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = { + {{#authMethods}}@Authorization(value = "{{name}}"{{#isOAuth}}, scopes = { + {{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}}, + {{/hasMore}}{{/scopes}} + }{{/isOAuth}}){{#hasMore}}, + {{/hasMore}}{{/authMethods}} + }{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}",{{/vendorExtensions.x-tags}} }) + @ApiResponses(value = { {{#responses}} + @ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{baseType}}}.class{{/baseType}}{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}){{#hasMore}},{{/hasMore}}{{/responses}} }) + {{#implicitHeaders}} + @ApiImplicitParams({ + {{#headerParams}} + {{>implicitHeader}} + {{/headerParams}} + }) + {{/implicitHeaders}} + @RequestMapping(value = "{{{path}}}",{{#singleContentTypes}} + produces = "{{{vendorExtensions.x-accepts}}}", + consumes = "{{{vendorExtensions.x-contentType}}}",{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}} + produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}} + consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}} + method = RequestMethod.{{httpMethod}}) + {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{^jdk8}};{{/jdk8}}{{#jdk8}} throws RestException { + {{#delegate-method}} + return {{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + } + + // Override this method + default {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{{dataType}}}{{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}},{{/hasMore}}{{/allParams}}) throws RestException { + {{/delegate-method}} + {{^isDelegate}} + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + {{#examples}} + if (getAcceptHeader().get().contains("{{{contentType}}}")) { + try { + return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(getObjectMapper().get().readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; + } catch (IOException e) { + log.error("Couldn't serialize response for content type {{{contentType}}}", e); + return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR){{#async}}){{/async}}; + } + } + {{/examples}} + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default {{classname}} interface so no example is generated"); + } + return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; + {{/isDelegate}} + {{#isDelegate}} + return getDelegate().{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + {{/isDelegate}} + }{{/jdk8}} + + {{/operation}} + } +{{/operations}}
\ No newline at end of file diff --git a/ms/sanity-test/sanity-test-app/src/main/yaml/sanitytest-api.yaml b/ms/sanity-test/sanity-test-app/src/main/yaml/sanitytest-api.yaml new file mode 100644 index 0000000..f08d195 --- /dev/null +++ b/ms/sanity-test/sanity-test-app/src/main/yaml/sanitytest-api.yaml @@ -0,0 +1,107 @@ +--- +swagger: "2.0" +info: + description: "Defines API interface for SDNC sanity tests. " + version: "2108.0.1" + title: "SANITYTEST-API" +consumes: +- "application/json" +- "application/xml" +produces: +- "application/json" +- "application/xml" +paths: + /operations/SANITYTEST-API:service-configuration-operation/: + post: + tags: + - "SANITYTEST-API" + parameters: + - in: "body" + name: "sanitytest.api.Input.body-param" + required: false + schema: + properties: + input: + $ref: "#/definitions/sanitytest.api.serviceconfigurationoperation.Input" + responses: + 400: + description: "Internal error" + 200: + description: "Correct response" + schema: + $ref: "#/definitions/sanitytest.api.ServiceConfigurationOperation" + 201: + description: "No response" +definitions: + sanitytest.api.TestNameEnumeration: + type: "string" + enum: + - "EIPAMAdaptor" + - "AAI" + - "POLICY" + sanitytest.api.ResultEnumeration: + type: "string" + enum: + - "Success" + - "Failure" + sanitytest.api.serviceconfigurationoperation.Input: + type: "object" + properties: + request-information: + $ref: "#/definitions/sanitytest.api.RequestInformation" + sanitytest.api.RequestInformation: + type: "object" + properties: + test-list: + type: "array" + items: + $ref: "#/definitions/sanitytest.api.TestListItem" + sanitytest.api.TestListItem: + type: "object" + properties: + test-number: + type: "integer" + format: "int16" + test-name: + $ref: "#/definitions/sanitytest.api.TestNameEnumeration" + test-data: + type: "array" + items: + $ref: "#/definitions/sanitytest.api.TestDataItem" + sanitytest.api.TestDataItem: + type: "object" + properties: + data-name: + type: "string" + data-value: + type: "string" + sanitytest.api.ServiceConfigurationOperation: + type: "object" + properties: + output: + $ref: "#/definitions/sanitytest.api.ResponseFields" + sanitytest.api.ResponseFields: + type: "object" + properties: + response-information: + type: "array" + items: + $ref: "#/definitions/sanitytest.api.ResponseField" + sanitytest.api.ResponseField: + type: "object" + properties: + response-test-number: + type: "integer" + format: "int16" + response-test-name: + $ref: "#/definitions/sanitytest.api.TestNameEnumeration" + start-time: + type: "string" + end-time: + type: "string" + elapsed-time: + type: "string" + result: + $ref: "#/definitions/sanitytest.api.ResultEnumeration" + error-message: + type: "string"
\ No newline at end of file |