For IntelliJ IDEA and
Android Studio


@Test(expected = NullPointerException.class) public void testSetDefault_Null() { ServiceProvider.setCurrent(null); }
/** * Tests {@link ServiceProvider#current()} and {@link ServiceProvider#setCurrent(ServiceProvider)}. The getter and setter are tested in a single * method for avoiding issues with the order in which JUnit executes tests. */ @Test public void testGetAndSetDefault() { assertEquals(0, ServiceProvider.available().size()); try { ServiceProvider.current(); fail("Expected no ServiceProvider before we set one."); } catch (IllegalStateException e) { // This is the expected exception. } TestServiceProvider testProv = new TestServiceProvider(); assertNull("Expected no ServiceProvider before we set one.", ServiceProvider.setCurrent(testProv)); assertSame("Setting the same ServiceProvider twice should be a no-op.", testProv, ServiceProvider.setCurrent(testProv)); assertSame(testProv, ServiceProvider.current()); assertArrayEquals(new ServiceProvider[] { testProv }, ServiceProvider.available().toArray()); }