use of org.onap.sdc.api.results.IDistributionClientResult in project so by onap.
the class ASDCController method initASDC.
/**
* This method initializes the ASDC Controller and the ASDC Client.
*
* @throws ASDCControllerException It throws an exception if the ASDC Client cannot be instantiated or if an init
* attempt is done when already initialized
* @throws ASDCParametersException If there is an issue with the parameters provided
* @throws IOException In case of issues when trying to load the key file
*/
public void initASDC() throws ASDCControllerException {
logger.debug("Initialize the ASDC Controller");
if (!isStopped()) {
throw new ASDCControllerException("The controller is already initialized, call the closeASDC method first");
}
if (asdcConfig != null) {
asdcConfig.setAsdcControllerName(controllerName);
}
if (this.distributionClient == null) {
distributionClient = DistributionClientFactory.createDistributionClient();
}
IDistributionClientResult result = this.distributionClient.init(asdcConfig, asdcNotificationCallBack, asdcStatusCallBack);
if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
String endEvent = "ASDC distribution client init failed with reason:" + result.getDistributionMessageResult();
logger.debug(endEvent);
this.changeControllerStatus(ASDCControllerStatus.STOPPED);
throw new ASDCControllerException("Initialization of the ASDC Controller failed with reason: " + result.getDistributionMessageResult());
}
result = this.distributionClient.start();
if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
String endEvent = "ASDC distribution client start failed with reason:" + result.getDistributionMessageResult();
logger.debug(endEvent);
this.changeControllerStatus(ASDCControllerStatus.STOPPED);
throw new ASDCControllerException("Startup of the ASDC Controller failed with reason: " + result.getDistributionMessageResult());
}
this.changeControllerStatus(ASDCControllerStatus.IDLE);
logger.info(LoggingAnchor.THREE, MessageEnum.ASDC_INIT_ASDC_CLIENT_SUC.toString(), "ASDC", "changeControllerStatus");
}
use of org.onap.sdc.api.results.IDistributionClientResult in project so by onap.
the class DistributionClientEmulatorTest method sendDownloadStatusSecondary.
@Test
public void sendDownloadStatusSecondary() {
IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId", "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
IDistributionClientResult result = distClientEmulator.sendDownloadStatus(message, "test");
IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
}
use of org.onap.sdc.api.results.IDistributionClientResult in project so by onap.
the class DistributionClientEmulatorTest method stop.
@Test
public void stop() {
IDistributionClientResult result = distClientEmulator.stop();
IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
}
use of org.onap.sdc.api.results.IDistributionClientResult in project so by onap.
the class DistributionClientEmulatorTest method updateConfiguration.
@Test
public void updateConfiguration() {
IDistributionClientResult result = distClientEmulator.updateConfiguration(new ASDCConfiguration());
IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
}
use of org.onap.sdc.api.results.IDistributionClientResult in project so by onap.
the class DistributionClientEmulatorTest method initSecondary.
@Test
public void initSecondary() {
IDistributionClientResult result = distClientEmulator.init(new ASDCConfiguration(), new ASDCNotificationCallBack(), new ASDCStatusCallBack());
IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
}
Aggregations