use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionManagerStub in project open-smart-grid-platform by OSGP.
the class GetPeriodicMeterReadsCommandExecutorIntegrationTest method setUp.
@BeforeEach
public void setUp() {
final TimeZone defaultTimeZone = TimeZone.getDefault();
final DateTimeZone defaultDateTimeZone = DateTimeZone.getDefault();
// all time based tests must use UTC time.
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
DateTimeZone.setDefault(DateTimeZone.UTC);
this.initDates();
this.dlmsHelper = new DlmsHelper();
this.amrProfileStatusCodeHelper = new AmrProfileStatusCodeHelper();
final DlmsObjectConfigConfiguration dlmsObjectConfigConfiguration = new DlmsObjectConfigConfiguration();
this.dlmsObjectConfigService = new DlmsObjectConfigService(this.dlmsHelper, dlmsObjectConfigConfiguration.getDlmsObjectConfigs());
this.executor = new GetPeriodicMeterReadsCommandExecutor(this.dlmsHelper, this.amrProfileStatusCodeHelper, this.dlmsObjectConfigService);
this.connectionStub = new DlmsConnectionStub();
this.connectionManagerStub = new DlmsConnectionManagerStub(this.connectionStub);
this.connectionStub.setDefaultReturnValue(DataObject.newArrayData(Collections.emptyList()));
// reset to original TimeZone
TimeZone.setDefault(defaultTimeZone);
DateTimeZone.setDefault(defaultDateTimeZone);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionManagerStub in project open-smart-grid-platform by OSGP.
the class GetGsmDiagnosticCommandExecutorIntegrationTest method setUp.
@BeforeEach
public void setUp() {
final DlmsHelper dlmsHelper = new DlmsHelper();
final DlmsObjectConfigConfiguration dlmsObjectConfigConfiguration = new DlmsObjectConfigConfiguration();
final DlmsObjectConfigService dlmsObjectConfigService = new DlmsObjectConfigService(dlmsHelper, dlmsObjectConfigConfiguration.getDlmsObjectConfigs());
this.executor = new GetGsmDiagnosticCommandExecutor(dlmsHelper, dlmsObjectConfigService);
this.connectionStub = new DlmsConnectionStub();
this.connectionManagerStub = new DlmsConnectionManagerStub(this.connectionStub);
this.connectionStub.setDefaultReturnValue(DataObject.newArrayData(Collections.emptyList()));
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionManagerStub in project open-smart-grid-platform by OSGP.
the class SetAlarmNotificationsCommandExecutorTest method setUp.
@BeforeEach
public void setUp() {
this.setParametersReceived = new ArrayList<>();
this.device = new DlmsDevice("SuperAwesomeHeroicRockstarDevice");
this.messageMetadata = MessageMetadata.newBuilder().withCorrelationUid("123456").build();
final DlmsObjectConfigConfiguration dlmsObjectConfigConfiguration = new DlmsObjectConfigConfiguration();
final DlmsObjectConfigService dlmsObjectConfigService = new DlmsObjectConfigService(new DlmsHelper(), dlmsObjectConfigConfiguration.getDlmsObjectConfigs()) {
@Override
public Optional<AttributeAddress> findAttributeAddress(final DlmsDevice device, final DlmsObjectType type, final Integer channel) {
switch(type) {
case ALARM_FILTER_1:
return Optional.of(new AttributeAddress(40, "0.0.97.98.10.255", 2));
case ALARM_FILTER_2:
return Optional.of(new AttributeAddress(40, "0.0.97.98.11.255", 2));
}
return Optional.empty();
}
};
this.executor = new SetAlarmNotificationsCommandExecutor(dlmsObjectConfigService);
final DlmsConnectionStub conn = new DlmsConnectionStub() {
@Override
public AccessResultCode set(final SetParameter setParameter) {
SetAlarmNotificationsCommandExecutorTest.this.setParametersReceived.add(setParameter);
return AccessResultCode.SUCCESS;
}
};
// Set the return value to 10 (0b1010):
// REPLACE_BATTERY enabled, AUXILIARY_EVENT enabled.
conn.addReturnValue(new AttributeAddress(1, "0.0.97.98.10.255", 2), DataObject.newInteger32Data(10));
conn.addReturnValue(new AttributeAddress(1, "0.0.97.98.11.255", 2), DataObject.newInteger32Data(0));
this.connMgr = new DlmsConnectionManagerStub(conn);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionManagerStub in project open-smart-grid-platform by OSGP.
the class GetPeriodicMeterReadsGasCommandExecutorIntegrationTest method setUp.
@BeforeEach
public void setUp() {
final TimeZone defaultTimeZone = TimeZone.getDefault();
final DateTimeZone defaultDateTimeZone = DateTimeZone.getDefault();
// all time based tests must use UTC time.
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
DateTimeZone.setDefault(DateTimeZone.UTC);
this.initDates();
this.dlmsHelper = new DlmsHelper();
this.amrProfileStatusCodeHelper = new AmrProfileStatusCodeHelper();
final DlmsObjectConfigConfiguration dlmsObjectConfigConfiguration = new DlmsObjectConfigConfiguration();
this.dlmsObjectConfigService = new DlmsObjectConfigService(this.dlmsHelper, dlmsObjectConfigConfiguration.getDlmsObjectConfigs());
this.executor = new GetPeriodicMeterReadsGasCommandExecutor(this.dlmsHelper, this.amrProfileStatusCodeHelper, this.dlmsObjectConfigService);
this.connectionStub = new DlmsConnectionStub();
this.connectionManagerStub = new DlmsConnectionManagerStub(this.connectionStub);
this.connectionStub.setDefaultReturnValue(DataObject.newArrayData(Collections.emptyList()));
// reset to original TimeZone
TimeZone.setDefault(defaultTimeZone);
DateTimeZone.setDefault(defaultDateTimeZone);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.stub.DlmsConnectionManagerStub in project open-smart-grid-platform by OSGP.
the class UpdateFirmwareCommandExecutorIntegrationTest method setUp.
@BeforeEach
void setUp() {
this.connectionStub = new DlmsConnectionStub();
this.connectionManagerStub = new DlmsConnectionManagerStub(this.connectionStub);
this.connectionStub.setDefaultReturnValue(DataObject.newArrayData(Collections.emptyList()));
this.connectionStub.addReturnValue(this.createAttributeAddressForImageTransfer(ImageTransferAttribute.IMAGE_TRANSFER_ENABLED), DataObject.newBoolData(true));
this.connectionStub.addReturnValue(this.createAttributeAddressForImageTransfer(ImageTransferAttribute.IMAGE_TRANSFER_STATUS), DataObject.newInteger32Data(1), 5);
this.connectionStub.addReturnValue(this.createAttributeAddressForImageTransfer(ImageTransferAttribute.IMAGE_TRANSFER_STATUS), DataObject.newInteger32Data(6));
this.connectionStub.addReturnValue(this.createAttributeAddressForImageTransfer(ImageTransferAttribute.IMAGE_BLOCK_SIZE), DataObject.newUInteger32Data(100));
this.connectionStub.addReturnValue(this.createAttributeAddressForImageTransfer(ImageTransferAttribute.IMAGE_FIRST_NOT_TRANSFERRED_BLOCK_NUMBER), DataObject.newUInteger32Data(100));
this.messageMetadata = MessageMetadata.newBuilder().withCorrelationUid("123456").build();
final MethodResult methodResult = mock(MethodResult.class);
when(methodResult.getResultCode()).thenReturn(MethodResultCode.SUCCESS);
final ImageTransferProperties imageTransferProperties = new ImageTransfer.ImageTransferProperties();
imageTransferProperties.setVerificationStatusCheckInterval(this.verificationStatusCheckInterval);
imageTransferProperties.setVerificationStatusCheckTimeout(this.verificationStatusCheckTimeout);
imageTransferProperties.setInitiationStatusCheckInterval(this.initiationStatusCheckInterval);
imageTransferProperties.setInitiationStatusCheckTimeout(this.initiationStatusCheckTimeout);
this.connectionStub.setDefaultMethodResult(methodResult);
this.commandExecutor = new UpdateFirmwareCommandExecutor(this.dlmsDeviceRepository, this.firmwareFileCachingRepository, this.firmwareImageIdentifierCachingRepository, this.macGenerationService, imageTransferProperties);
}
Aggregations