Search in sources :

Example 6 with RelayMap

use of org.opensmartgridplatform.domain.core.valueobjects.RelayMap 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);
}
Also used : RelayConfiguration(org.opensmartgridplatform.domain.core.valueobjects.RelayConfiguration) RelayMap(org.opensmartgridplatform.domain.core.valueobjects.RelayMap) Test(org.junit.jupiter.api.Test)

Aggregations

RelayMap (org.opensmartgridplatform.domain.core.valueobjects.RelayMap)6 DeviceOutputSetting (org.opensmartgridplatform.domain.core.entities.DeviceOutputSetting)2 Ssld (org.opensmartgridplatform.domain.core.entities.Ssld)2 ByteString (com.google.protobuf.ByteString)1 Then (io.cucumber.java.en.Then)1 ArrayList (java.util.ArrayList)1 Test (org.junit.jupiter.api.Test)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1 Device (org.opensmartgridplatform.domain.core.entities.Device)1 Configuration (org.opensmartgridplatform.domain.core.valueobjects.Configuration)1 RelayConfiguration (org.opensmartgridplatform.domain.core.valueobjects.RelayConfiguration)1 RelayType (org.opensmartgridplatform.domain.core.valueobjects.RelayType)1 ConfigurationDto (org.opensmartgridplatform.dto.valueobjects.ConfigurationDto)1 DaliConfiguration (org.opensmartgridplatform.oslp.Oslp.DaliConfiguration)1 IndexAddressMap (org.opensmartgridplatform.oslp.Oslp.IndexAddressMap)1 LightType (org.opensmartgridplatform.oslp.Oslp.LightType)1 LinkType (org.opensmartgridplatform.oslp.Oslp.LinkType)1 Message (org.opensmartgridplatform.oslp.Oslp.Message)1 RelayConfiguration (org.opensmartgridplatform.oslp.Oslp.RelayConfiguration)1 SetConfigurationRequest (org.opensmartgridplatform.oslp.Oslp.SetConfigurationRequest)1