Search in sources :

Example 6 with IDistributionClientResult

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");
}
Also used : IDistributionClientResult(org.onap.sdc.api.results.IDistributionClientResult) ASDCControllerException(org.onap.so.asdc.client.exceptions.ASDCControllerException)

Example 7 with IDistributionClientResult

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());
}
Also used : IDistributionStatusMessage(org.onap.sdc.api.consumer.IDistributionStatusMessage) DistributionStatusMessage(org.onap.so.asdc.client.DistributionStatusMessage) IDistributionStatusMessage(org.onap.sdc.api.consumer.IDistributionStatusMessage) IDistributionClientResult(org.onap.sdc.api.results.IDistributionClientResult) DistributionClientResultImpl(org.onap.sdc.impl.DistributionClientResultImpl) Test(org.junit.Test)

Example 8 with IDistributionClientResult

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());
}
Also used : IDistributionClientResult(org.onap.sdc.api.results.IDistributionClientResult) DistributionClientResultImpl(org.onap.sdc.impl.DistributionClientResultImpl) Test(org.junit.Test)

Example 9 with IDistributionClientResult

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());
}
Also used : IDistributionClientResult(org.onap.sdc.api.results.IDistributionClientResult) ASDCConfiguration(org.onap.so.asdc.client.ASDCConfiguration) DistributionClientResultImpl(org.onap.sdc.impl.DistributionClientResultImpl) Test(org.junit.Test)

Example 10 with IDistributionClientResult

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());
}
Also used : IDistributionClientResult(org.onap.sdc.api.results.IDistributionClientResult) ASDCConfiguration(org.onap.so.asdc.client.ASDCConfiguration) ASDCNotificationCallBack(org.onap.so.asdc.client.ASDCNotificationCallBack) DistributionClientResultImpl(org.onap.sdc.impl.DistributionClientResultImpl) ASDCStatusCallBack(org.onap.so.asdc.client.ASDCStatusCallBack) Test(org.junit.Test)

Aggregations

IDistributionClientResult (org.onap.sdc.api.results.IDistributionClientResult)10 Test (org.junit.Test)9 DistributionClientResultImpl (org.onap.sdc.impl.DistributionClientResultImpl)9 IDistributionStatusMessage (org.onap.sdc.api.consumer.IDistributionStatusMessage)4 DistributionStatusMessage (org.onap.so.asdc.client.DistributionStatusMessage)4 ASDCConfiguration (org.onap.so.asdc.client.ASDCConfiguration)3 ASDCNotificationCallBack (org.onap.so.asdc.client.ASDCNotificationCallBack)2 ASDCStatusCallBack (org.onap.so.asdc.client.ASDCStatusCallBack)1 ASDCControllerException (org.onap.so.asdc.client.exceptions.ASDCControllerException)1