@Test
public void testAutomaticDiscoveryResultApprovalIfInboxEntriesExistBeforeApprovalPredicatesAreAdded() {

    inbox.add(DiscoveryResultBuilder.create(THING_UID).build());
    inbox.add(DiscoveryResultBuilder.create(THING_UID2).build());
    inbox.add(DiscoveryResultBuilder.create(THING_UID3).build());
    // Adding this inboxAutoApprovePredicate will auto-approve the first two discovery results as they have matching
    // thing type UID.
    automaticInboxProcessor.addInboxAutoApprovePredicate(
            discoveryResult -> THING_TYPE_UID.equals(discoveryResult.getThingTypeUID()));
    verify(thingRegistry, times(1)).add(argThat(thing -> THING_UID.equals(thing.getUID())));
    verify(thingRegistry, times(1)).add(argThat(thing -> THING_UID2.equals(thing.getUID())));
    verify(thingRegistry, never()).add(argThat(thing -> THING_UID3.equals(thing.getUID())));
    // Adding this inboxAutoApprovePredicate will auto-approve the third discovery results as it has matching
    // thing type UID.
    automaticInboxProcessor.addInboxAutoApprovePredicate(
            discoveryResult -> THING_TYPE_UID3.equals(discoveryResult.getThingTypeUID()));
    verify(thingRegistry, times(1)).add(argThat(thing -> THING_UID.equals(thing.getUID())));
    verify(thingRegistry, times(1)).add(argThat(thing -> THING_UID2.equals(thing.getUID())));
    verify(thingRegistry, times(1)).add(argThat(thing -> THING_UID3.equals(thing.getUID())));
}