use of org.eclipse.smarthome.core.thing.firmware.FirmwareUpdateResultInfoEvent in project smarthome by eclipse.
the class FirmwareUpdateServiceTest method assertCancellationMessage.
private void assertCancellationMessage(String messageKey, String expectedEnglishMessage, Locale locale, int expectedEventCount) {
when(mockLocaleProvider.getLocale()).thenReturn(locale);
when(mockTranslationProvider.getText(any(Bundle.class), eq(messageKey), any(), eq(locale), any())).thenReturn(expectedEnglishMessage);
Exception exception = new RuntimeException();
doThrow(exception).when(handler3).cancel();
firmwareUpdateService.updateFirmware(THING4_UID, FW111_EN.getVersion(), locale);
firmwareUpdateService.cancelFirmwareUpdate(THING4_UID);
AtomicReference<FirmwareUpdateResultInfoEvent> resultEvent = new AtomicReference<FirmwareUpdateResultInfoEvent>();
waitForAssert(() -> {
ArgumentCaptor<FirmwareUpdateResultInfoEvent> eventCaptor = ArgumentCaptor.forClass(FirmwareUpdateResultInfoEvent.class);
verify(mockPublisher, times(expectedEventCount)).post(eventCaptor.capture());
assertEquals(expectedEventCount, eventCaptor.getAllValues().size());
resultEvent.set(eventCaptor.getAllValues().get(eventCaptor.getAllValues().size() - 1));
});
assertThat(resultEvent.get().getFirmwareUpdateResultInfo().getThingUID(), is(THING4_UID));
assertThat(resultEvent.get().getFirmwareUpdateResultInfo().getResult(), is(FirmwareUpdateResult.ERROR));
assertThat(resultEvent.get().getFirmwareUpdateResultInfo().getErrorMessage(), is(expectedEnglishMessage));
}
use of org.eclipse.smarthome.core.thing.firmware.FirmwareUpdateResultInfoEvent in project smarthome by eclipse.
the class ProgressCallbackTest method assertThatCallingCancelResultsInAFirmwareUpdateResultInfoEvent.
@Test
public void assertThatCallingCancelResultsInAFirmwareUpdateResultInfoEvent() {
sut.defineSequence(ProgressStep.DOWNLOADING, ProgressStep.TRANSFERRING);
sut.canceled();
assertThat(postedEvents.size(), is(1));
assertThat(postedEvents.get(0), is(instanceOf(FirmwareUpdateResultInfoEvent.class)));
FirmwareUpdateResultInfoEvent resultEvent = (FirmwareUpdateResultInfoEvent) postedEvents.get(0);
assertThat(resultEvent.getFirmwareUpdateResultInfo().getThingUID(), is(expectedThingUID));
assertThat(resultEvent.getFirmwareUpdateResultInfo().getResult(), is(FirmwareUpdateResult.CANCELED));
assertThat(usedMessagedKey, is(cancelMessageKey));
}
use of org.eclipse.smarthome.core.thing.firmware.FirmwareUpdateResultInfoEvent in project smarthome by eclipse.
the class FirmwareUpdateServiceTest method assertFailedFirmwareUpdate.
private void assertFailedFirmwareUpdate(ThingUID thingUID, Event event, String expectedErrorMessage) {
assertThat(event, is(instanceOf(FirmwareUpdateResultInfoEvent.class)));
FirmwareUpdateResultInfoEvent firmwareUpdateResultInfoEvent = (FirmwareUpdateResultInfoEvent) event;
assertThat(firmwareUpdateResultInfoEvent.getTopic(), containsString(THING1_UID.getAsString()));
assertThat(firmwareUpdateResultInfoEvent.getFirmwareUpdateResultInfo().getThingUID(), is(THING1_UID));
assertThat(firmwareUpdateResultInfoEvent.getFirmwareUpdateResultInfo().getResult(), is(FirmwareUpdateResult.ERROR));
assertThat(firmwareUpdateResultInfoEvent.getFirmwareUpdateResultInfo().getErrorMessage(), is(expectedErrorMessage));
}
use of org.eclipse.smarthome.core.thing.firmware.FirmwareUpdateResultInfoEvent in project smarthome by eclipse.
the class ProgressCallbackTest method assertThatUpdateResultEventIsValid.
private void assertThatUpdateResultEventIsValid(Event event, String expectedMessageKey, FirmwareUpdateResult expectedResult) {
assertThat(event, is(instanceOf(FirmwareUpdateResultInfoEvent.class)));
FirmwareUpdateResultInfoEvent fpiEvent = (FirmwareUpdateResultInfoEvent) event;
assertThat(usedMessagedKey, is(expectedMessageKey));
assertThat(fpiEvent.getFirmwareUpdateResultInfo().getThingUID(), is(expectedThingUID));
assertThat(fpiEvent.getFirmwareUpdateResultInfo().getResult(), is(expectedResult));
}
Aggregations