### Question:
DefaultServiceRegistry implements ServiceRegistry { @Override @SuppressWarnings("unchecked") public <T> void unregisterService(@NotNull Class<T> service, @Nullable T replacement) throws ProviderNotRegisteredException, ProviderImmutableException, ProviderNeedsReplacementException { ServiceRegistryEntry<T> entry = (ServiceRegistryEntry<T>) this.entries.get(service); if (entry == null) { throw new ProviderNotRegisteredException(service); } if (entry.isImmutable()) { throw new ProviderImmutableException(service); } if (entry.needsReplacement() && replacement == null) { throw new ProviderNeedsReplacementException(service); } this.entries.remove(service); }  @Override void setProvider(@NotNull Class<T> service, @NotNull T provider, boolean immutable, boolean needsReplacement); @NotNull @Override @SuppressWarnings("unchecked") Optional<T> getProvider(@NotNull Class<T> service); @NotNull @Override @SuppressWarnings("unchecked") Optional<ServiceRegistryEntry<T>> getRegisteredEntry(@NotNull Class<T> service); @NotNull @Override @SuppressWarnings("unchecked") T getProviderUnchecked(@NotNull Class<T> service); @NotNull @Override @UnmodifiableView Collection<ServiceRegistryEntry<?>> getRegisteredServices(); @Override @SuppressWarnings("unchecked") void unregisterService(@NotNull Class<T> service, @Nullable T replacement);  }### Answer:
@Test @Order(4) void testUnregisterService() { Assertions.assertThrows(ProviderImmutableException.class, () -> this.serviceRegistry.unregisterService(AService.class)); Assertions.assertThrows(ProviderNotRegisteredException.class, () -> this.serviceRegistry.unregisterService(DefaultServiceRegistryTest.class)); }