Java源码示例:org.hamcrest.collection.IsArrayWithSize

示例1
@Test
public void shouldGetEmptyArrayIfNullValue() {
    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()));
}
 
示例2
@Test
public void shouldGetEmptyArrayIfNonArrayValue() {
    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()));
}
 
示例3
@Test
public void emptySubPattern() {
  String[] patternParts = GrammarUtils.splitPattern(PREFIX, "");
  assertThat(patternParts, IsArrayWithSize.emptyArray());
}
 
示例4
@Test
public void basicSubPatternNotMatchingPrefix() {
  String[] patternParts = GrammarUtils.splitPattern("prefix", "waggle_");
  assertThat(patternParts, IsArrayWithSize.emptyArray());
}
 
示例5
@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());
}
 
示例6
@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());
}
 
示例7
@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());
}
 
示例8
@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());
}