use of org.opensmartgridplatform.domain.core.valueobjects.RelayConfiguration in project open-smart-grid-platform by OSGP.
the class ConfigurationConverter method convertTo.
@Override
public Configuration convertTo(final org.opensmartgridplatform.dto.valueobjects.ConfigurationDto source, final Type<Configuration> destinationType, final MappingContext context) {
final LightType lightType = this.mapperFacade.map(source.getLightType(), LightType.class);
final DaliConfiguration daliConfiguration = this.mapperFacade.map(source.getDaliConfiguration(), DaliConfiguration.class);
final RelayConfiguration relayConfiguration = this.mapperFacade.map(source.getRelayConfiguration(), RelayConfiguration.class);
final LinkType preferredLinkType = this.mapperFacade.map(source.getPreferredLinkType(), LinkType.class);
final Configuration.Builder builder = new Configuration.Builder().withLightType(lightType).withDaliConfiguration(daliConfiguration).withRelayConfiguration(relayConfiguration).withPreferredLinkType(preferredLinkType).withTimeSyncFrequency(source.getTimeSyncFrequency()).withDhcpEnabled(source.isDhcpEnabled()).withTlsEnabled(source.isTlsEnabled()).withTlsPortNumber(source.getTlsPortNumber()).withCommonNameString(source.getCommonNameString()).withCommunicationTimeout(source.getCommunicationTimeout()).withCommunicationNumberOfRetries(source.getCommunicationNumberOfRetries()).withCommunicationPauseTimeBetweenConnectionTrials(source.getCommunicationPauseTimeBetweenConnectionTrials()).withOsgpIpAddress(source.getOsgpIpAddres()).withOsgpPortNumber(source.getOsgpPortNumber()).withNtpHost(source.getNtpHost()).withNtpEnabled(source.getNtpEnabled()).withNtpSyncInterval(source.getNtpSyncInterval()).withTestButtonEnabled(source.isTestButtonEnabled()).withAutomaticSummerTimingEnabled(source.isAutomaticSummerTimingEnabled()).withAstroGateSunRiseOffset(source.getAstroGateSunRiseOffset()).withAstroGateSunSetOffset(source.getAstroGateSunSetOffset()).withSwitchingDelays(source.getSwitchingDelays()).withRelayRefreshing(source.isRelayRefreshing()).withSummerTimeDetails(source.getSummerTimeDetails()).withWinterTimeDetails(source.getWinterTimeDetails());
if (source.getRelayLinking() != null) {
builder.withRelayLinking(this.mapperFacade.mapAsList(source.getRelayLinking(), org.opensmartgridplatform.domain.core.valueobjects.RelayMatrix.class));
}
if (source.getDeviceFixedIp() != null) {
builder.withDeviceFixedIp(this.mapperFacade.map(source.getDeviceFixedIp(), DeviceFixedIp.class));
}
return builder.build();
}
use of org.opensmartgridplatform.domain.core.valueobjects.RelayConfiguration in project open-smart-grid-platform by OSGP.
the class ConfigurationManagementServiceTest method testTrySetConfiguration.
@Test
void testTrySetConfiguration() throws FunctionalException, UnknownEntityException {
final RelayMap relayMap = new RelayMap(1, 1, RelayType.LIGHT, "1");
final List<RelayMap> relayMapList = Collections.singletonList(relayMap);
when(this.organisationDomainService.searchOrganisation(any(String.class))).thenReturn(TEST_ORGANISATION);
when(this.deviceDomainService.searchActiveDevice(any(), any())).thenReturn(this.device);
when(this.configuration.getRelayConfiguration()).thenReturn(new RelayConfiguration(relayMapList));
when(this.ssldRepository.findById(any())).thenReturn(java.util.Optional.of(this.ssld));
when(this.domainCoreMapper.map(any(), any())).thenReturn(this.configurationDto);
doNothing().when(this.ssld).updateOutputSettings(any());
when(this.device.getIpAddress()).thenReturn(IP_ADDRESS);
this.configurationManagementService.setConfiguration(this.correlationIds, this.configuration, SCHEDULE_TIME, MESSAGE_TYPE, MESSAGE_PRIORITY);
verify(this.osgpCoreRequestMessageSender).sendWithScheduledTime(this.requestMessageArgumentCaptor.capture(), this.messageTypeArgumentCaptor.capture(), this.messagePriorityArgumentCaptor.capture(), this.ipAddressArgumentCaptor.capture(), this.scheduledTimeArgumentCaptor.capture());
this.checkRequestMessageArgumentCaptor();
assertThat(this.messageTypeArgumentCaptor.getValue()).isEqualTo(MESSAGE_TYPE);
assertThat(this.messagePriorityArgumentCaptor.getValue()).isEqualTo(MESSAGE_PRIORITY);
assertThat(this.ipAddressArgumentCaptor.getValue()).isEqualTo(IP_ADDRESS);
assertThat(this.scheduledTimeArgumentCaptor.getValue()).isEqualTo(SCHEDULE_TIME);
}
Aggregations