From 77c8e7ee4645fcd7052ac2a1055dd0d387fc5ecb Mon Sep 17 00:00:00 2001 From: prathamesh morde Date: Fri, 22 Feb 2019 17:03:19 -0500 Subject: Skeleton of CDS-SDC Listener ms Change-Id: I3874b588a484a22cc4e0fe9d39541effa1f3c305 Issue-ID: CCSDK-349 Signed-off-by: prathamesh morde --- ms/cds-sdc-listener/application/pom.xml | 58 +++++++++++ .../cdssdclistener/CdsSdcListenerApplication.java | 19 ++++ ms/cds-sdc-listener/distribution/pom.xml | 106 +++++++++++++++++++++ ms/cds-sdc-listener/pom.xml | 28 ++++++ 4 files changed, 211 insertions(+) create mode 100644 ms/cds-sdc-listener/application/pom.xml create mode 100644 ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerApplication.java create mode 100644 ms/cds-sdc-listener/distribution/pom.xml create mode 100644 ms/cds-sdc-listener/pom.xml diff --git a/ms/cds-sdc-listener/application/pom.xml b/ms/cds-sdc-listener/application/pom.xml new file mode 100644 index 000000000..a5e6f1e53 --- /dev/null +++ b/ms/cds-sdc-listener/application/pom.xml @@ -0,0 +1,58 @@ + + + + + org.onap.ccsdk.parent + spring-boot-1-starter-parent + 1.2.1-SNAPSHOT + + + + 4.0.0 + application + CDS-SDC Listener Application + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-devtools + true + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + repackage + + repackage + + + + + + + + diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerApplication.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerApplication.java new file mode 100644 index 000000000..661f8cb5b --- /dev/null +++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerApplication.java @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2019 Bell Canada. All rights reserved. + * + * NOTICE: All the intellectual and technical concepts contained herein are + * proprietary to Bell Canada and are protected by trade secret or copyright law. + * Unauthorized copying of this file, via any medium is strictly prohibited. + */ + +package org.onap.ccsdk.apps.cdssdclistener; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class CdsSdcListenerApplication { + public static void main(String[] args) { + SpringApplication.run(CdsSdcListenerApplication.class, args); + } +} diff --git a/ms/cds-sdc-listener/distribution/pom.xml b/ms/cds-sdc-listener/distribution/pom.xml new file mode 100644 index 000000000..9ff555fce --- /dev/null +++ b/ms/cds-sdc-listener/distribution/pom.xml @@ -0,0 +1,106 @@ + + + + cds-sdc-listener + org.onap.ccsdk.apps + 0.4.1-SNAPSHOT + + + 4.0.0 + distribution + CDS-SDC Listener Distribution + + + onap/ccsdk-cdssdclistener + deploy + + + + + + maven-resources-plugin + 2.6 + + + copy-dockerfile + + copy-resources + + validate + + ${basedir}/target/docker-stage + + + src/main/docker + + * + + true + + + + + + + + + + + + docker + + + + + io.fabric8 + docker-maven-plugin + 0.26.1 + false + + + + ${image.name} + + try + ${basedir}/target/docker-stage + + ${project.version} + ${project.version}-STAGING-${maven.build.timestamp} + + + + + true + + + + generate-images + package + + build + + + + push-images + ${docker.push.phase} + + build + push + + + + + + + + + + \ No newline at end of file diff --git a/ms/cds-sdc-listener/pom.xml b/ms/cds-sdc-listener/pom.xml new file mode 100644 index 000000000..3998f5f28 --- /dev/null +++ b/ms/cds-sdc-listener/pom.xml @@ -0,0 +1,28 @@ + + + + ccsdk-apps-ms + org.onap.ccsdk.apps + 0.4.1-SNAPSHOT + + + 4.0.0 + cds-sdc-listener + CDS-SDC Listener Root + A microservice to get the cba file from SDC and store it into database at runtime + pom + + + application + distribution + + + \ No newline at end of file -- cgit 1.2.3-korg From 2ef29683072193132256b8ccc50e0c7cb097db33 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 12 Mar 2019 19:07:51 -0400 Subject: Add missing groupId Added missing groupId to cds-sdc-listener poms and updated artifactIds to ensure uniqueness Change-Id: Ibec810dc25c48cd5cf8527364d629cc463bce0c9 Issue-ID: CCSDK-1150 Signed-off-by: Timoney, Dan (dt5972) --- ms/cds-sdc-listener/application/pom.xml | 3 ++- ms/cds-sdc-listener/distribution/pom.xml | 11 ++++++----- ms/cds-sdc-listener/pom.xml | 2 ++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ms/cds-sdc-listener/application/pom.xml b/ms/cds-sdc-listener/application/pom.xml index a5e6f1e53..daa9f0a62 100644 --- a/ms/cds-sdc-listener/application/pom.xml +++ b/ms/cds-sdc-listener/application/pom.xml @@ -17,7 +17,8 @@ 4.0.0 - application + org.onap.ccsdk.apps + cds-sdc-listener-application CDS-SDC Listener Application diff --git a/ms/cds-sdc-listener/distribution/pom.xml b/ms/cds-sdc-listener/distribution/pom.xml index 9ff555fce..f22807838 100644 --- a/ms/cds-sdc-listener/distribution/pom.xml +++ b/ms/cds-sdc-listener/distribution/pom.xml @@ -15,7 +15,8 @@ 4.0.0 - distribution + org.onap.ccsdk.apps + cds-sdc-listener-distribution CDS-SDC Listener Distribution @@ -71,10 +72,10 @@ try ${basedir}/target/docker-stage - - ${project.version} - ${project.version}-STAGING-${maven.build.timestamp} - + + ${project.version} + ${project.version}-STAGING-${maven.build.timestamp} + diff --git a/ms/cds-sdc-listener/pom.xml b/ms/cds-sdc-listener/pom.xml index 3998f5f28..0c393db7f 100644 --- a/ms/cds-sdc-listener/pom.xml +++ b/ms/cds-sdc-listener/pom.xml @@ -22,7 +22,9 @@ application + \ No newline at end of file -- cgit 1.2.3-korg From 4bea60ce6d420d92fb1762467cbcff9897ac1896 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 14 Mar 2019 13:55:01 -0400 Subject: Prepare for release 0.4.1 Prepare to create release version 0.4.1 by using released version of parent pom Change-Id: Icf8432e14626a55b916b6f4d4a8992b79c29eff7 Issue-ID: CCSDK-1156 Signed-off-by: Timoney, Dan (dt5972) --- ms/cds-sdc-listener/application/pom.xml | 9 ++++----- ms/cds-sdc-listener/distribution/pom.xml | 7 +++---- ms/cds-sdc-listener/pom.xml | 7 +++---- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ms/cds-sdc-listener/application/pom.xml b/ms/cds-sdc-listener/application/pom.xml index daa9f0a62..54f59b7ca 100644 --- a/ms/cds-sdc-listener/application/pom.xml +++ b/ms/cds-sdc-listener/application/pom.xml @@ -1,3 +1,4 @@ + - + org.onap.ccsdk.parent spring-boot-1-starter-parent - 1.2.1-SNAPSHOT - + 1.2.1 + 4.0.0 diff --git a/ms/cds-sdc-listener/distribution/pom.xml b/ms/cds-sdc-listener/distribution/pom.xml index f22807838..60711f697 100644 --- a/ms/cds-sdc-listener/distribution/pom.xml +++ b/ms/cds-sdc-listener/distribution/pom.xml @@ -1,3 +1,4 @@ + - + cds-sdc-listener org.onap.ccsdk.apps @@ -104,4 +103,4 @@ - \ No newline at end of file + diff --git a/ms/cds-sdc-listener/pom.xml b/ms/cds-sdc-listener/pom.xml index 0c393db7f..0f2a4613b 100644 --- a/ms/cds-sdc-listener/pom.xml +++ b/ms/cds-sdc-listener/pom.xml @@ -1,3 +1,4 @@ + - + ccsdk-apps-ms org.onap.ccsdk.apps @@ -27,4 +26,4 @@ --> - \ No newline at end of file + -- cgit 1.2.3-korg From bf1605f2448380c45b7217b11d6ad24d1c2be3a2 Mon Sep 17 00:00:00 2001 From: prathamesh morde Date: Thu, 7 Mar 2019 17:11:14 -0500 Subject: CDS-SDC Listener application Things done- CDS-SDC listener able to register for SDC distribution. Download the artifacts. Things to do- Add logic to parse the blueprint from CSAR and store it into CDS DB. Change-Id: I2fe01af73814e749f93a62d3a90e1f05947c0505 Issue-ID: CCSDK-349 Signed-off-by: prathamesh morde --- ms/cds-sdc-listener/application/pom.xml | 15 +++ .../cdssdclistener/CdsSdcListenerApplication.java | 2 + .../apps/cdssdclistener/CdsSdcListenerClient.java | 81 ++++++++++++ .../CdsSdcListenerConfiguration.java | 137 +++++++++++++++++++++ .../apps/cdssdclistener/CdsSdcListenerDto.java | 23 ++++ .../CdsSdcListenerNotificationCallback.java | 69 +++++++++++ .../exceptions/CdsSdcListenerException.java | 27 ++++ .../cdssdclistener/service/ListenerService.java | 18 +++ .../service/ListenerServiceImpl.java | 27 ++++ .../application/src/main/resources/application.yml | 17 +++ .../cdssdclistener/CdsSdcListenerClientTest.java | 71 +++++++++++ .../CdsSdcListenerConfigurationTest.java | 41 ++++++ 12 files changed, 528 insertions(+) create mode 100644 ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerClient.java create mode 100644 ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerConfiguration.java create mode 100644 ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerDto.java create mode 100644 ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerNotificationCallback.java create mode 100644 ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/exceptions/CdsSdcListenerException.java create mode 100644 ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/service/ListenerService.java create mode 100644 ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/service/ListenerServiceImpl.java create mode 100644 ms/cds-sdc-listener/application/src/main/resources/application.yml create mode 100644 ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerClientTest.java create mode 100644 ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerConfigurationTest.java diff --git a/ms/cds-sdc-listener/application/pom.xml b/ms/cds-sdc-listener/application/pom.xml index 54f59b7ca..86cd764de 100644 --- a/ms/cds-sdc-listener/application/pom.xml +++ b/ms/cds-sdc-listener/application/pom.xml @@ -36,6 +36,21 @@ spring-boot-devtools true + + + + org.onap.sdc.sdc-distribution-client + sdc-distribution-client + 1.3.0 + + + + org.jmockit + jmockit + 1.19 + test + + diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerApplication.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerApplication.java index 661f8cb5b..3bd34fb08 100644 --- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerApplication.java +++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerApplication.java @@ -10,8 +10,10 @@ package org.onap.ccsdk.apps.cdssdclistener; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.EnableConfigurationProperties; @SpringBootApplication +@EnableConfigurationProperties(CdsSdcListenerConfiguration.class) public class CdsSdcListenerApplication { public static void main(String[] args) { SpringApplication.run(CdsSdcListenerApplication.class, args); diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerClient.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerClient.java new file mode 100644 index 000000000..af0bb40b6 --- /dev/null +++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerClient.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2019 Bell Canada. All rights reserved. + * + * NOTICE: All the intellectual and technical concepts contained herein are + * proprietary to Bell Canada and are protected by trade secret or copyright law. + * Unauthorized copying of this file, via any medium is strictly prohibited. + */ +package org.onap.ccsdk.apps.cdssdclistener; + +import java.util.Optional; +import org.onap.ccsdk.apps.cdssdclistener.exceptions.CdsSdcListenerException; +import org.onap.sdc.api.IDistributionClient; +import org.onap.sdc.api.results.IDistributionClientResult; +import org.onap.sdc.impl.DistributionClientFactory; +import org.onap.sdc.utils.DistributionActionResultEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; + +@Component +public class CdsSdcListenerClient { + + private static Logger LOG = LoggerFactory.getLogger(CdsSdcListenerClient.class); + + @Autowired + private CdsSdcListenerConfiguration configuration; + + @Autowired + private CdsSdcListenerNotificationCallback notification; + + @Autowired + private CdsSdcListenerDto listenerDto; + + private IDistributionClient distributionClient; + + /** + * This method initializes the SDC Distribution client. + */ + @EventListener(ApplicationReadyEvent.class) + public void initSdcClient() throws CdsSdcListenerException { + LOG.info("Initialize the SDC distribution client"); + + distributionClient = Optional.of(DistributionClientFactory.createDistributionClient()) + .orElseThrow(() -> new CdsSdcListenerException("Could not able to create SDC Distribution client")); + + listenerDto.setDistributionClient(distributionClient); + + IDistributionClientResult result = distributionClient.init(configuration, notification); + + startSdcClientBasedOnTheResult(result); + } + + private void startSdcClientBasedOnTheResult(IDistributionClientResult result) throws CdsSdcListenerException { + if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) { + throw new CdsSdcListenerException( + "SDC distribution client init failed with reason:" + result.getDistributionMessageResult()); + } + + // Start the client. + result = this.distributionClient.start(); + + if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) { + throw new CdsSdcListenerException( + "Startup of the SDC distribution client failed with reason: " + result.getDistributionMessageResult()); + } + } + + private void closeSdcDistributionclient() throws CdsSdcListenerException { + + IDistributionClientResult status = this.distributionClient.stop(); + + LOG.info("Closing SDC distribution client"); + if (status.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) { + throw new CdsSdcListenerException( + "Failed to close the SDC distribution client due to : " + status.getDistributionMessageResult()); + } + } +} diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerConfiguration.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerConfiguration.java new file mode 100644 index 000000000..0cbb917fc --- /dev/null +++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerConfiguration.java @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2019 Bell Canada. All rights reserved. + * + * NOTICE: All the intellectual and technical concepts contained herein are + * proprietary to Bell Canada and are protected by trade secret or copyright law. + * Unauthorized copying of this file, via any medium is strictly prohibited. + */ + +package org.onap.ccsdk.apps.cdssdclistener; + +import java.util.List; +import org.onap.sdc.api.consumer.IConfiguration; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * In order to initiate a SDC distribution client we need to supply some pre-configuration values that + * distribution client needs. + */ +@ConfigurationProperties("listenerservice") +public class CdsSdcListenerConfiguration implements IConfiguration { + + public static final String TOSCA_CSAR = "TOSCA_CSAR"; + + @Value("${listenerservice.config.asdcAddress}") + private String asdcAddress; + + @Value("${listenerservice.config.messageBusAddress}") + private List messageBusAddress; + + @Value("${listenerservice.config.user}") + private String user; + + @Value("${listenerservice.config.password}") + private String password; + + @Value("${listenerservice.config.pollingTimeout}") + private int pollingTimeout; + + @Value("${listenerservice.config.pollingInterval}") + private int pollingInterval; + + @Value("${listenerservice.config.relevantArtifactTypes}") + private List relevantArtifactTypes; + + @Value("${listenerservice.config.consumerGroup}") + private String consumerGroup; + + @Value("${listenerservice.config.environmentName}") + private String envName; + + @Value("${listenerservice.config.consumerId}") + private String consumerId; + + @Value("${listenerservice.config.activateServerTLSAuth}") + private boolean activateServerTLSAuth; + + @Value("${listenerservice.config.isUseHttpsWithDmaap}") + private boolean isUseHttpsWithDmaap; + + + @Override + public String getAsdcAddress() { + return asdcAddress; + } + + @Override + public List getMsgBusAddress() { + return messageBusAddress; + } + + @Override + public String getUser() { + return user; + } + + @Override + public String getPassword() { + return password; + } + + @Override + public int getPollingInterval() { + return pollingInterval; + } + + @Override + public int getPollingTimeout() { + return pollingTimeout; + } + + @Override + public List getRelevantArtifactTypes() { + return relevantArtifactTypes; + } + + @Override + public String getConsumerGroup() { + return consumerGroup; + } + + @Override + public String getEnvironmentName() { + return envName; + } + + @Override + public String getConsumerID() { + return consumerId; + } + + @Override + public String getKeyStorePath() { + return null; + } + + @Override + public String getKeyStorePassword() { + return null; + } + + @Override + public boolean activateServerTLSAuth() { + return activateServerTLSAuth; + } + + @Override + public boolean isFilterInEmptyResources() { + return false; + } + + @Override + public Boolean isUseHttpsWithDmaap() { + return isUseHttpsWithDmaap; + } +} + diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerDto.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerDto.java new file mode 100644 index 000000000..afa753e5a --- /dev/null +++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerDto.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2019 Bell Canada. All rights reserved. + * + * NOTICE: All the intellectual and technical concepts contained herein are + * proprietary to Bell Canada and are protected by trade secret or copyright law. + * Unauthorized copying of this file, via any medium is strictly prohibited. + */ +package org.onap.ccsdk.apps.cdssdclistener; + +import org.onap.sdc.api.IDistributionClient; + +public class CdsSdcListenerDto { + + private IDistributionClient distributionClient; + + public IDistributionClient getDistributionClient() { + return distributionClient; + } + + public void setDistributionClient(IDistributionClient distributionClient) { + this.distributionClient = distributionClient; + } +} diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerNotificationCallback.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerNotificationCallback.java new file mode 100644 index 000000000..35747635f --- /dev/null +++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerNotificationCallback.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2019 Bell Canada. All rights reserved. + * + * NOTICE: All the intellectual and technical concepts contained herein are + * proprietary to Bell Canada and are protected by trade secret or copyright law. + * Unauthorized copying of this file, via any medium is strictly prohibited. + */ + +package org.onap.ccsdk.apps.cdssdclistener; + +import static org.onap.sdc.utils.DistributionActionResultEnum.SUCCESS; +import java.util.List; +import org.onap.sdc.api.IDistributionClient; +import org.onap.sdc.api.consumer.INotificationCallback; +import org.onap.sdc.api.notification.IArtifactInfo; +import org.onap.sdc.api.notification.INotificationData; +import org.onap.sdc.api.results.IDistributionClientDownloadResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class CdsSdcListenerNotificationCallback implements INotificationCallback { + + @Autowired + private CdsSdcListenerDto cdsSdcListenerDto; + + private static final Logger LOGGER = LoggerFactory.getLogger(CdsSdcListenerNotificationCallback.class); + + @Override + public void activateCallback(INotificationData notificationData) { + LOGGER.info(notificationData.getDistributionID(), "The UUID generated by SDC {}"); + processNotification(notificationData); + } + + private void processNotification(INotificationData notificationData) { + downlaodCsarArtifacts(notificationData.getServiceArtifacts()); + } + + /** + * Download the TOSCA CSAR artifact. + * @param artifactInfo - An object consists of Artifact information. + */ + private void downlaodCsarArtifacts(List artifactInfo) { + final IDistributionClient distributionClient = cdsSdcListenerDto.getDistributionClient(); + + artifactInfo.forEach(info -> { + final String url = info.getArtifactURL(); + final String id = info.getArtifactUUID(); + if (info.getArtifactType().equals(CdsSdcListenerConfiguration.TOSCA_CSAR)) { + LOGGER.info("Trying to download the artifact from : {} and UUID is {} ", url, id); + + IDistributionClientDownloadResult result = distributionClient.download(info); + + if (!result.getDistributionActionResult().equals(SUCCESS)) { + LOGGER.info("Failed to download the artifact from : {} due to {} ", url, + result.getDistributionActionResult()); + } else { + parseCBAFileFromCsar(result); + } + } + }); + } + + private void parseCBAFileFromCsar(IDistributionClientDownloadResult result) { + + } +} diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/exceptions/CdsSdcListenerException.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/exceptions/CdsSdcListenerException.java new file mode 100644 index 000000000..3f83b6ac2 --- /dev/null +++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/exceptions/CdsSdcListenerException.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2019 Bell Canada. All rights reserved. + * + * NOTICE: All the intellectual and technical concepts contained herein are + * proprietary to Bell Canada and are protected by trade secret or copyright law. + * Unauthorized copying of this file, via any medium is strictly prohibited. + */ + +package org.onap.ccsdk.apps.cdssdclistener.exceptions; + +public class CdsSdcListenerException extends Exception { + + /** + * @param message The message to dump + */ + public CdsSdcListenerException(final String message) { + super(message); + } + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public CdsSdcListenerException(final String message, final Throwable cause) { + super(message, cause); + } +} diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/service/ListenerService.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/service/ListenerService.java new file mode 100644 index 000000000..d6c2c4f40 --- /dev/null +++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/service/ListenerService.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2019 Bell Canada. All rights reserved. + * + * NOTICE: All the intellectual and technical concepts contained herein are + * proprietary to Bell Canada and are protected by trade secret or copyright law. + * Unauthorized copying of this file, via any medium is strictly prohibited. + */ + +package org.onap.ccsdk.apps.cdssdclistener.service; + +import java.io.File; + +public interface ListenerService { + + void extractBluePrint(File file); + + void storeBluePrint(File file); +} diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/service/ListenerServiceImpl.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/service/ListenerServiceImpl.java new file mode 100644 index 000000000..864c485ce --- /dev/null +++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/service/ListenerServiceImpl.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2019 Bell Canada. All rights reserved. + * + * NOTICE: All the intellectual and technical concepts contained herein are + * proprietary to Bell Canada and are protected by trade secret or copyright law. + * Unauthorized copying of this file, via any medium is strictly prohibited. + */ + +package org.onap.ccsdk.apps.cdssdclistener.service; + +import java.io.File; +import org.springframework.stereotype.Component; + +@Component +public class ListenerServiceImpl implements ListenerService { + + @Override + public void extractBluePrint(File file) { + //TODO + + } + + @Override + public void storeBluePrint(File file) { + //TODO + } +} diff --git a/ms/cds-sdc-listener/application/src/main/resources/application.yml b/ms/cds-sdc-listener/application/src/main/resources/application.yml new file mode 100644 index 000000000..1daef585b --- /dev/null +++ b/ms/cds-sdc-listener/application/src/main/resources/application.yml @@ -0,0 +1,17 @@ +listenerservice: + config: + asdcAddress: localhost:8443 + messageBusAddress: localhost + user: vid + password: Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U + pollingInterval: 15 + pollingTimeout: 15 + relevantArtifactTypes: TOSCA_CSAR + consumerGroup: cds-id-local + environmentName: AUTO + consumerId: cds-id-local + keyStorePassword: + keyStorePath: + activateServerTLSAuth : false + isUseHttpsWithDmaap: false + diff --git a/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerClientTest.java b/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerClientTest.java new file mode 100644 index 000000000..3a634b8c9 --- /dev/null +++ b/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerClientTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2019 Bell Canada. All rights reserved. + * + * NOTICE: All the intellectual and technical concepts contained herein are + * proprietary to Bell Canada and are protected by trade secret or copyright law. + * Unauthorized copying of this file, via any medium is strictly prohibited. + */ + +package org.onap.ccsdk.apps.cdssdclistener; + +import mockit.Expectations; +import mockit.Injectable; +import mockit.Mock; +import mockit.MockUp; +import mockit.Tested; +import mockit.VerificationsInOrder; +import mockit.integration.junit4.JMockit; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.ccsdk.apps.cdssdclistener.exceptions.CdsSdcListenerException; +import org.onap.sdc.api.IDistributionClient; +import org.onap.sdc.api.results.IDistributionClientResult; +import org.onap.sdc.impl.DistributionClientFactory; +import org.onap.sdc.impl.DistributionClientResultImpl; +import org.onap.sdc.utils.DistributionActionResultEnum; + +@RunWith(JMockit.class) +public class CdsSdcListenerClientTest { + + @Tested + private CdsSdcListenerClient cdsSdcListenerClient; + + @Test + public void testInitCdsClientSuccesfully(@Injectable IDistributionClient distributionClient, + @Injectable CdsSdcListenerConfiguration configuration, + @Injectable CdsSdcListenerNotificationCallback notification, + @Injectable CdsSdcListenerDto cdsSdcListenerDto) throws CdsSdcListenerException { + + // Arrange + new MockUp() { + @Mock + public IDistributionClient createDistributionClient() { + return distributionClient; + } + }; + + new Expectations() {{ + distributionClient.init(configuration, notification); + result = getResult(); + }}; + + new Expectations() {{ + distributionClient.start(); + result = getResult(); + }}; + + // Act + cdsSdcListenerClient.initSdcClient(); + + // Verify + new VerificationsInOrder() {{ + distributionClient.init(configuration, notification); + distributionClient.start(); + }}; + } + + public IDistributionClientResult getResult() { + return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS, + DistributionActionResultEnum.SUCCESS.name()); + } +} diff --git a/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerConfigurationTest.java b/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerConfigurationTest.java new file mode 100644 index 000000000..886049df7 --- /dev/null +++ b/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerConfigurationTest.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2019 Bell Canada. All rights reserved. + * + * NOTICE: All the intellectual and technical concepts contained herein are + * proprietary to Bell Canada and are protected by trade secret or copyright law. + * Unauthorized copying of this file, via any medium is strictly prohibited. + */ + +package org.onap.ccsdk.apps.cdssdclistener; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@EnableConfigurationProperties(CdsSdcListenerConfiguration.class) +@SpringBootTest(classes = {CdsSdcListenerConfigurationTest.class}) +public class CdsSdcListenerConfigurationTest { + + @Autowired + private CdsSdcListenerConfiguration listenerConfiguration; + + @Test + public void testCdsSdcListenerConfiguration() { + assertEquals(listenerConfiguration.getAsdcAddress(), "localhost:8443"); + assertEquals(listenerConfiguration.getMsgBusAddress().stream().findFirst().get(), "localhost"); + assertEquals(listenerConfiguration.getUser(), "vid"); + assertEquals(listenerConfiguration.getPassword(), "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"); + assertEquals(listenerConfiguration.getPollingInterval(), 15); + assertEquals(listenerConfiguration.getPollingTimeout(), 15); + assertEquals(listenerConfiguration.getRelevantArtifactTypes().stream().findFirst().get(), "TOSCA_CSAR"); + assertEquals(listenerConfiguration.getConsumerGroup(), "cds-id-local"); + assertEquals(listenerConfiguration.getEnvironmentName(), "AUTO"); + assertEquals(listenerConfiguration.getConsumerID(), "cds-id-local"); + assertEquals(listenerConfiguration.activateServerTLSAuth(), false); + } +} -- cgit 1.2.3-korg From 21ed72977b85bba3a06ebc7a36dc588429149809 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 19 Mar 2019 16:31:51 -0400 Subject: Compile against Fluorine SR2 Updated to compile against Fluorine SR2 Change-Id: I434068531ce4a661a04c20201e0fddf3f6b92f47 Issue-ID: CCSDK-1156 Signed-off-by: Timoney, Dan (dt5972) --- ms/cds-sdc-listener/application/pom.xml | 2 +- ms/cds-sdc-listener/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ms/cds-sdc-listener/application/pom.xml b/ms/cds-sdc-listener/application/pom.xml index 54f59b7ca..412c5918f 100644 --- a/ms/cds-sdc-listener/application/pom.xml +++ b/ms/cds-sdc-listener/application/pom.xml @@ -11,7 +11,7 @@ org.onap.ccsdk.parent spring-boot-1-starter-parent - 1.2.1 + 1.2.2-SNAPSHOT diff --git a/ms/cds-sdc-listener/pom.xml b/ms/cds-sdc-listener/pom.xml index 0f2a4613b..538185ebc 100644 --- a/ms/cds-sdc-listener/pom.xml +++ b/ms/cds-sdc-listener/pom.xml @@ -10,7 +10,7 @@ ccsdk-apps-ms org.onap.ccsdk.apps - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT 4.0.0 -- cgit 1.2.3-korg