Search in sources :

Example 1 with DistributionClientEmulator

use of org.onap.so.asdc.client.test.emulators.DistributionClientEmulator in project so by onap.

the class ASDCRestInterface method invokeASDCStatusData.

@POST
@Path("/statusData/v1")
@Produces(MediaType.APPLICATION_JSON)
@Transactional
public Response invokeASDCStatusData(final String request) {
    try {
        final DistributionClientEmulator distributionClientEmulator = getDistributionClientEmulator("resource-examples/");
        final JsonStatusData statusData = JsonStatusData.instantiateNotifFromJsonFile("resource-examples/");
        asdcController.setDistributionClient(distributionClientEmulator);
        asdcController.initASDC();
        toscaInstaller.installTheComponentStatus(statusData);
        asdcController.closeASDC();
        logger.info(LoggingAnchor.FOUR, MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC.toString(), statusData.getDistributionID(), "ASDC", "ASDC Updates Are Complete");
    } catch (final Exception e) {
        logger.info("Error caught " + e.getMessage());
        logger.error(LoggingAnchor.SIX, MessageEnum.ASDC_GENERAL_EXCEPTION.toString(), "Exception caught during ASDCRestInterface", "ASDC", "invokeASDCService", ErrorCode.BusinessProcessError.getValue(), "Exception in invokeASDCService", e);
    }
    return null;
}
Also used : JsonStatusData(org.onap.so.asdc.client.test.emulators.JsonStatusData) DistributionClientEmulator(org.onap.so.asdc.client.test.emulators.DistributionClientEmulator) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Transactional(javax.transaction.Transactional)

Example 2 with DistributionClientEmulator

use of org.onap.so.asdc.client.test.emulators.DistributionClientEmulator in project so by onap.

the class ASDCControllerITTest method setUp.

@Before
public void setUp() {
    distributionId = UUID.randomUUID().toString();
    artifactUuid = UUID.randomUUID().toString();
    logger.info("Using distributionId: {}, artifactUUID: {} for testcase: {}", distributionId, artifactUuid, testName.getMethodName());
    distributionClient = new DistributionClientEmulator();
    distributionClient.setResourcePath("src/test/resources");
    asdcController.setDistributionClient(distributionClient);
    try {
        asdcController.initASDC();
    } catch (ASDCControllerException e) {
        logger.error(e.getMessage(), e);
        fail(e.getMessage());
    }
}
Also used : ASDCControllerException(org.onap.so.asdc.client.exceptions.ASDCControllerException) DistributionClientEmulator(org.onap.so.asdc.client.test.emulators.DistributionClientEmulator) Before(org.junit.Before)

Example 3 with DistributionClientEmulator

use of org.onap.so.asdc.client.test.emulators.DistributionClientEmulator in project so by onap.

the class ASDCRestInterface method invokeASDCService.

@POST
@Path("/treatNotification/v1")
@Produces(MediaType.APPLICATION_JSON)
@Transactional
public Response invokeASDCService(final NotificationDataImpl request, @HeaderParam("resource-location") final String resourceLocation) {
    try {
        logger.info("Received message : {}", request);
        logger.info("resource-location : {}", resourceLocation);
        final DistributionClientEmulator distributionClientEmulator = getDistributionClientEmulator(resourceLocation);
        asdcController.setControllerName("asdc-controller1");
        asdcController.setDistributionClient(distributionClientEmulator);
        if (asdcController.isStopped()) {
            logger.info("{} not running will try to initialize it, currrent status: {}", asdcController.getClass().getName(), asdcController.getControllerStatus());
            asdcController.initASDC();
        }
        asdcController.treatNotification(request);
        if (!asdcController.isBusy()) {
            asdcController.closeASDC();
        }
        return Response.status(Status.OK).build();
    } catch (final Exception exception) {
        logger.error("Unable to process notification request", exception);
        return Response.status(Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : DistributionClientEmulator(org.onap.so.asdc.client.test.emulators.DistributionClientEmulator) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Transactional(javax.transaction.Transactional)

Aggregations

DistributionClientEmulator (org.onap.so.asdc.client.test.emulators.DistributionClientEmulator)3 Transactional (javax.transaction.Transactional)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Before (org.junit.Before)1 ASDCControllerException (org.onap.so.asdc.client.exceptions.ASDCControllerException)1 JsonStatusData (org.onap.so.asdc.client.test.emulators.JsonStatusData)1