@Test public void shouldGetEmptyArrayIfNullValue() throws Exception { JsonElement value = gson.toJsonTree(null); ClaimImpl claim = new ClaimImpl(value); assertThat(claim.asArray(String.class), is(notNullValue())); assertThat(claim.asArray(String.class), is(IsArrayWithSize.<String>emptyArray())); }
@Test public void shouldGetEmptyArrayIfNonArrayValue() throws Exception { JsonElement value = gson.toJsonTree(1); ClaimImpl claim = new ClaimImpl(value); assertThat(claim.asArray(String.class), is(notNullValue())); assertThat(claim.asArray(String.class), is(IsArrayWithSize.<String>emptyArray())); }
@Test public void canAssignIsArrayWithSizeMatcher() { Matcher<Phone[]> withTwoElements = IsArrayWithSize.arrayWithSize(2); assertThat(bob, is(aPersonThat().hasPhones(withTwoElements))); Matcher<Phone[]> empty = IsArrayWithSize.emptyArray(); assertThat(bill, is(aPersonThat().hasPhones(empty))); }
@Test public void isNull() throws Exception { mWhere.isNull("test"); Assert.assertThat(mWhere.toString(), IsEqual.equalTo(" WHERE test IS NULL")); Assert.assertThat(mWhere.getValues(), IsArrayWithSize.emptyArray()); }
@Test public void notNull() throws Exception { mWhere.notNull("test"); Assert.assertThat(mWhere.toString(), IsEqual.equalTo(" WHERE test NOT NULL")); Assert.assertThat(mWhere.getValues(), IsArrayWithSize.emptyArray()); }
@Test public void sortByAsc() throws Exception { mWhere.sortBy("test", SortBy.Order.ASC); Assert.assertThat(mWhere.toString(), IsEqual.equalTo(" ORDER BY test ASC")); Assert.assertThat(mWhere.getValues(), IsArrayWithSize.emptyArray()); }
@Test public void sortByDesc() throws Exception { mWhere.sortBy("test", SortBy.Order.DESC); Assert.assertThat(mWhere.toString(), IsEqual.equalTo(" ORDER BY test DESC")); Assert.assertThat(mWhere.getValues(), IsArrayWithSize.emptyArray()); }
@Test public void shouldNotRequireAndroidPermissions() throws Exception { assertThat(provider.getRequiredAndroidPermissions(), is(notNullValue())); assertThat(provider.getRequiredAndroidPermissions(), is(IsArrayWithSize.<String>emptyArray())); }