### Question:
ServiceLoaderProvider { public static <T> T getUnique(Class<T> supplier) { return getUniqueSupplier(supplier, null); } private  ServiceLoaderProvider(); static T get(Class<T> supplier); static T getUnique(Class<T> supplier); static T getUnique(Class<T> supplier, Predicate<Object> predicate); static I getUnique(Class<T> supplier, Class<I> supplierImplementation); static Stream<Object> getSupplierStream(Class<T> supplier);  }### Answer:
@Test public void shouldErrorWithMoreThanOneImplementation() { Assertions.assertThrows(NonUniqueResultException.class, () -> ServiceLoaderProvider.getUnique(Machine.class)); }
@Test public void shouldReturnUnique() { Animal animal = ServiceLoaderProvider.getUnique(Animal.class); Assertions.assertNotNull(animal); Assertions.assertTrue(animal instanceof Horse); }
@Test public void shouldReturnOneWithPredicate() { final Predicate<Object> computer = o -> o.getClass().getSimpleName().equals("Computer"); Machine machine = ServiceLoaderProvider.getUnique(Machine.class, computer); Assertions.assertNotNull(machine); Assertions.assertTrue(machine instanceof Computer); }
@Test public void shouldReturnOneWithClass() { Mobile machine = ServiceLoaderProvider.getUnique(Machine.class, Mobile.class); Assertions.assertNotNull(machine); Assertions.assertTrue(machine instanceof Mobile); }