use of org.eclipse.smarthome.config.discovery.inbox.events.InboxUpdatedEvent in project smarthome by eclipse.
the class PersistentInboxTest method testEmittedUpdatedResultIsReadFromStorage.
@Test
public void testEmittedUpdatedResultIsReadFromStorage() {
DiscoveryResult result = DiscoveryResultBuilder.create(THING_UID).withProperty("foo", 3).build();
EventPublisher eventPublisher = mock(EventPublisher.class);
inbox.setEventPublisher(eventPublisher);
//
when(storage.get(THING_UID.toString())).thenReturn(//
result).thenReturn(DiscoveryResultBuilder.create(THING_UID).withProperty("foo", "bar").build());
inbox.add(result);
// 1st call checks existence of the result in the storage (returns the original result)
// 2nd call retrieves the stored instance before the event gets emitted
// (modified due to storage mock configuration)
verify(storage, times(2)).get(THING_UID.toString());
ArgumentCaptor<InboxUpdatedEvent> eventCaptor = ArgumentCaptor.forClass(InboxUpdatedEvent.class);
verify(eventPublisher).post(eventCaptor.capture());
assertThat(eventCaptor.getValue().getDiscoveryResult().properties, hasEntry("foo", "bar"));
}
Aggregations