### Question:
CclResourceUploader { public static CclResourceUploader getUploader() { @SuppressWarnings("unchecked") final Enumeration<CclResourceUploader> providers = Service.providers(CclResourceUploader.class); if (!providers.hasMoreElements()) throw new IllegalStateException("No implementations found of: " + CclResourceUploader.class.getName()); return providers.nextElement(); }  static CclResourceUploader getUploader(); abstract void queueUpload(File file); abstract Map<File, URI> upload();  }### Answer:
@Test public void testGetUploader() { final CclResourceUploader uploader = mock(CclResourceUploader.class); @SuppressWarnings("unchecked") final Enumeration<CclResourceUploader> uploaders = mock(Enumeration.class); when(uploaders.hasMoreElements()).thenReturn(Boolean.TRUE, Boolean.FALSE); when(uploaders.nextElement()).thenReturn(uploader); mockStatic(Service.class); when(Service.providers(CclResourceUploader.class)).thenReturn(uploaders); assertThat(CclResourceUploader.getUploader()).isEqualTo(uploader); }
@Test public void testGetUploaderNoImplementation() { @SuppressWarnings("unchecked") final Enumeration<CclResourceUploader> uploaders = mock(Enumeration.class); mockStatic(Service.class); when(Service.providers(CclResourceUploader.class)).thenReturn(uploaders); IllegalStateException e = assertThrows(IllegalStateException.class, () -> { CclResourceUploader.getUploader(); }); assertThat(e.getMessage()).isEqualTo("No implementations found of: " + CclResourceUploader.class.getName()); }