public void testNewArray_fromArray_Empty() { String[] in = new String[0]; String[] empty = ObjectArrays.newArray(in, 0); assertThat(empty).isEmpty(); }
public void testCreateTempDir() { File temp = Files.createTempDir(); assertTrue(temp.exists()); assertTrue(temp.isDirectory()); assertThat(temp.listFiles()).isEmpty(); assertTrue(temp.delete()); }
void check() { runTester(); String[] defaultArray = (String[]) getDefaultParameterValue(0); assertThat(defaultArray).isEmpty(); } }
void check() { runTester(); Object[] defaultArray = (Object[]) getDefaultParameterValue(0); assertThat(defaultArray).isEmpty(); } }
public void testInstanceMethod_typeParameters() throws Exception { Invokable<?, ?> delegate = Prepender.method("prepend", Iterable.class); assertThat(delegate.getTypeParameters()).isEmpty(); }
@GwtIncompatible // ObjectArrays.concat(Object[], Object[], Class) public void testConcatEmptyEmpty() { String[] result = ObjectArrays.concat(new String[0], new String[0], String.class); assertEquals(String[].class, result.getClass()); assertThat(result).isEmpty(); }
@GwtIncompatible // ObjectArrays.newArray(Class, int) public void testNewArray_fromClass_Empty() { String[] empty = ObjectArrays.newArray(String.class, 0); assertEquals(String[].class, empty.getClass()); assertThat(empty).isEmpty(); }
static void checkEmpty(Collection<?> collection) { assertTrue(collection.isEmpty()); assertEquals(0, collection.size()); assertFalse(collection.iterator().hasNext()); assertThat(collection.toArray()).isEmpty(); assertThat(collection.toArray(new Object[0])).isEmpty(); if (collection instanceof Set) { new EqualsTester() .addEqualityGroup(ImmutableSet.of(), collection) .addEqualityGroup(ImmutableSet.of("")) .testEquals(); } else if (collection instanceof List) { new EqualsTester() .addEqualityGroup(ImmutableList.of(), collection) .addEqualityGroup(ImmutableList.of("")) .testEquals(); } } }
@Test @Config(minSdk = LOLLIPOP) public void getAccountTypesWithManagementDisabledShouldReturnNothingWhenNoAccountIsDislabed() { // GIVEN no account type has ever been disabled // WHEN get disabled account types using // DevicePolicyManager#getAccountTypesWithManagementDisabled // THEN it should be empty assertThat(devicePolicyManager.getAccountTypesWithManagementDisabled()).isEmpty(); }
public void testInstanceMethod_parameters() throws Exception { Invokable<?, ?> delegate = Prepender.method("prepend", Iterable.class); ImmutableList<Parameter> parameters = delegate.getParameters(); assertEquals(1, parameters.size()); assertEquals(new TypeToken<Iterable<String>>() {}, parameters.get(0).getType()); assertThat(parameters.get(0).getAnnotations()).isEmpty(); new EqualsTester().addEqualityGroup(parameters.get(0)).testEquals(); }
@Test public void shouldConvertFromMethodSignature() throws Exception { InvocationProfile profile = new InvocationProfile("android/view/View/invalidate()V", false, getClass().getClassLoader()); assertThat(profile.clazz).isEqualTo(View.class); assertThat(profile.methodName).isEqualTo("invalidate"); assertThat(profile.isStatic).isEqualTo(false); assertThat(profile.paramTypes).isEmpty(); }
@Test @Config(minSdk = LOLLIPOP) public void getAllNetworks_shouldReturnNoNetworksWhenCleared() throws Exception { shadowOf(connectivityManager).clearAllNetworks(); Network[] networks = connectivityManager.getAllNetworks(); assertThat(networks).isEmpty(); }
@Test public void first() throws Exception { assertThat(WindowManagerGlobal.getInstance().getViewRootNames()).isEmpty(); Robolectric.setupActivity(Activity.class); }
@Test public void clearSystemSharedLibraryName() { shadowPackageManager.addSystemSharedLibraryName("com.foo.system_library_1"); shadowPackageManager.clearSystemSharedLibraryNames(); assertThat(packageManager.getSystemSharedLibraryNames()).isEmpty(); }
@Test public void second() throws Exception { assertThat(WindowManagerGlobal.getInstance().getViewRootNames()).isEmpty(); Robolectric.setupActivity(Activity.class); } }
public static void testSuppressingSuppressorIfPossible() throws IOException { // can't test the JDK7 suppressor when not running on JDK7 if (!Closer.SuppressingSuppressor.isAvailable()) { return; } Closer closer = new Closer(new Closer.SuppressingSuppressor()); IOException thrownException = new IOException(); IOException c1Exception = new IOException(); RuntimeException c2Exception = new RuntimeException(); TestCloseable c1 = closer.register(TestCloseable.throwsOnClose(c1Exception)); TestCloseable c2 = closer.register(TestCloseable.throwsOnClose(c2Exception)); try { try { throw thrownException; } catch (Throwable e) { throw closer.rethrow(thrownException, IOException.class); } finally { assertThat(getSuppressed(thrownException)).isEmpty(); closer.close(); } } catch (IOException expected) { assertSame(thrownException, expected); } assertTrue(c1.isClosed()); assertTrue(c2.isClosed()); ImmutableSet<Throwable> suppressed = ImmutableSet.copyOf(getSuppressed(thrownException)); assertEquals(2, suppressed.size()); assertEquals(ImmutableSet.of(c1Exception, c2Exception), suppressed); }
@Test public void arrayOfFiltersNull() { assertThat(arrayFilteringNull(null, null, null)).isEmpty(); assertThat(arrayFilteringNull("One", null, null)).asList().containsExactly("One"); assertThat(arrayFilteringNull(null, "One", null)).asList().containsExactly("One"); assertThat(arrayFilteringNull(null, null, "One")).asList().containsExactly("One"); assertThat(arrayFilteringNull("One", "Two", null)).asList().containsExactly("One", "Two"); assertThat(arrayFilteringNull("One", null, "Two")).asList().containsExactly("One", "Two"); assertThat(arrayFilteringNull(null, "One", "Two")).asList().containsExactly("One", "Two"); }
@Test public void removeAccount_does() throws Exception { Account account = new Account("name", "type"); shadowOf(am).addAccount(account); TestAccountManagerCallback<Boolean> testAccountManagerCallback = new TestAccountManagerCallback<>(); AccountManagerFuture<Boolean> future = am.removeAccount(account, testAccountManagerCallback, null); assertThat(future.getResult()).isTrue(); assertThat(am.getAccountsByType("type")).isEmpty(); assertThat(testAccountManagerCallback.accountManagerFuture).isNotNull(); }
@Test public void removeAllAccounts() throws Exception { Account account = new Account("name@gmail.com", "gmail.com"); shadowOf(am).addAccount(account); assertThat(am.getAccounts()).isNotEmpty(); shadowOf(am).removeAllAccounts(); assertThat(am.getAccounts()).isEmpty(); }