use of org.opensmartgridplatform.domain.core.valueobjects.Certification in project open-smart-grid-platform by OSGP.
the class DeviceManagementServiceTest method testUpdateDeviceSslCertification.
@Test
public void testUpdateDeviceSslCertification() throws FunctionalException {
final Device device = mock(Device.class);
when(device.getIpAddress()).thenReturn(TEST_IP);
when(this.deviceDomainService.searchActiveDevice(TEST_DEVICE, ComponentType.DOMAIN_CORE)).thenReturn(device);
final Certification certification = new Certification("testUrl", "testDomain");
this.deviceManagementService.updateDeviceSslCertification(TEST_ORGANISATION, TEST_DEVICE, TEST_UID, certification, TEST_MESSAGE_TYPE, TEST_PRIORITY);
verify(this.osgpCoreRequestManager).send(this.argumentRequestMessage.capture(), this.argumentMessageType.capture(), this.argumentPriority.capture(), this.argumentIpAddress.capture());
final RequestMessage expectedRequestMessage = this.createNewRequestMessage(this.domainCoreMapper.map(certification, CertificationDto.class));
assertThat(this.argumentRequestMessage.getValue()).usingRecursiveComparison().isEqualTo(expectedRequestMessage);
assertThat(this.argumentMessageType.getValue()).isEqualTo(TEST_MESSAGE_TYPE);
assertThat(this.argumentPriority.getValue()).isEqualTo(TEST_PRIORITY);
assertThat(this.argumentIpAddress.getValue()).isEqualTo(TEST_IP);
}
use of org.opensmartgridplatform.domain.core.valueobjects.Certification in project open-smart-grid-platform by OSGP.
the class CommonUpdateDeviceSslCertificationRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) {
LOGGER.debug("Processing update device ssl certification message");
String correlationUid = null;
String messageType = null;
int messagePriority = MessagePriorityEnum.DEFAULT.getPriority();
String organisationIdentification = null;
String deviceIdentification = null;
try {
correlationUid = message.getJMSCorrelationID();
messageType = message.getJMSType();
messagePriority = message.getJMSPriority();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("correlationUid: {}", correlationUid);
LOGGER.debug("messageType: {}", messageType);
LOGGER.debug("messagePriority: {}", messagePriority);
LOGGER.debug("organisationIdentification: {}", organisationIdentification);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
return;
}
try {
final Certification certification = (Certification) message.getObject();
LOGGER.info("Calling application service function: {}", messageType);
this.deviceManagementService.updateDeviceSslCertification(organisationIdentification, deviceIdentification, correlationUid, certification, messageType, messagePriority);
} catch (final Exception e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType, messagePriority);
}
}
use of org.opensmartgridplatform.domain.core.valueobjects.Certification in project open-smart-grid-platform by OSGP.
the class DeviceManagementEndpoint method updateDeviceSslCertification.
@PayloadRoot(localPart = "UpdateDeviceSslCertificationRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE)
@ResponsePayload
public UpdateDeviceSslCertificationAsyncResponse updateDeviceSslCertification(@OrganisationIdentification final String organisationIdentification, @RequestPayload final UpdateDeviceSslCertificationRequest request, @MessagePriority final String messagePriority) throws OsgpException {
LOGGER.info("Update Device Ssl Certification Request received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
final UpdateDeviceSslCertificationAsyncResponse response = new UpdateDeviceSslCertificationAsyncResponse();
try {
final Certification certification = this.deviceManagementMapper.map(request.getCertification(), Certification.class);
final String correlationUid = this.deviceManagementService.enqueueUpdateDeviceSslCertificationRequest(organisationIdentification, request.getDeviceIdentification(), certification, MessagePriorityEnum.getMessagePriority(messagePriority));
final AsyncResponse asyncResponse = new AsyncResponse();
asyncResponse.setCorrelationUid(correlationUid);
asyncResponse.setDeviceId(request.getDeviceIdentification());
response.setAsyncResponse(asyncResponse);
} catch (final ConstraintViolationException e) {
throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_CORE, new ValidationException(e.getConstraintViolations()));
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
Aggregations