### Question:
MapNotificationProviderRegistry implements NotificationProviderRegistry { @Override public NotificationProvider getInstanceForProvider(NotificationMethod method) throws NoSuchProviderException { if (method == null) { throw new IllegalArgumentException("Notification method cannot be null."); } NotificationProvider providerInstance = providerRegistry.get(method.toString()); if (providerInstance == null) { throw new NoSuchProviderException("No notification provider registered with the name: " + method); } return providerInstance; }  @Override NotificationProvider getInstanceForProvider(NotificationMethod method);  }### Answer:
@Test public void shouldReturnInstanceForValidProvider() throws Exception { assertEquals(logProvider, uut.getInstanceForProvider(NotificationMethod.LOG)); assertEquals(webhookProvider, uut.getInstanceForProvider(NotificationMethod.WEBHOOK)); }
@Test (expected=IllegalArgumentException.class) public void shouldThrowExceptionForNullProvider() throws NoSuchProviderException { uut.getInstanceForProvider(null); }
@Test (expected=IllegalArgumentException.class) public void shouldThrowExceptionForEmptyProvider() throws NoSuchProviderException { uut.getInstanceForProvider(null); }
@Test (expected=NoSuchProviderException.class) public void shouldThrowExceptionForUnknownProvider() throws NoSuchProviderException { uut.getInstanceForProvider(NotificationMethod.EMAIL); }
@Test public void shouldReturnExistantProvider() throws Exception { NotificationProvider expectedProvider = Mockito.mock(NotificationProvider.class); Mockito.when(providers.get("APNS")).thenReturn(expectedProvider); assertEquals(expectedProvider, uut.getInstanceForProvider(NotificationMethod.APNS)); }
@Test(expected = NoSuchProviderException.class) public void shouldThrowExceptionForNonExistantProvider() throws Exception { uut.getInstanceForProvider(NotificationMethod.APNS); }