use of org.eclipse.smarthome.config.discovery.inbox.events.InboxAddedEvent in project smarthome by eclipse.
the class PersistentInboxTest method testEmittedAddedResultIsReadFromStorage.
@Test
public void testEmittedAddedResultIsReadFromStorage() {
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(//
null).thenReturn(DiscoveryResultBuilder.create(THING_UID).withProperty("foo", "bar").build());
inbox.add(result);
// 1st call checks existence of the result in the storage (returns null)
// 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<InboxAddedEvent> eventCaptor = ArgumentCaptor.forClass(InboxAddedEvent.class);
verify(eventPublisher).post(eventCaptor.capture());
assertThat(eventCaptor.getValue().getDiscoveryResult().properties, hasEntry("foo", "bar"));
}
Aggregations