Junit matchers

Per release notes JUnitMatchers have been deprecated. Please use org.hamcrest.CoreMatchers directly.

Contains both elements

@SuppressWarnings("deprecation")
@Test
public void test_string_contains_two_elements () {
    
    assertThat("B-double E double R U-N beer run", 
            both(containsString("beer"))
            .and(containsString("run")));
}

Contains string

@SuppressWarnings("deprecation")
@Test
public void test_string_contains () {
    
    assertThat("Meet the press",
            containsString("press"));
}

Contains either or

@SuppressWarnings("deprecation")
@Test
public void test_string_either_or () {

    assertThat("the simpsons",
            either(containsString("the")).or(containsString("simpsons")));
}

Every item contains

@SuppressWarnings("deprecation")
@Test
public void test_every_item_contains () {
    
    List<String> movies = Lists.newArrayList(
            "the matrix", 
            "the lord of the rings", 
            "the lion king", 
            "the dark knight");
    assertThat(movies, everyItem(containsString("the")));
}

Each has item

@SuppressWarnings("deprecation")
@Test
public void test_list_has_items () {

    List<String> websites = Lists.newArrayList(
            "leveluplunch.com", 
            "www.leveluplunch.com" );

    assertThat(websites, hasItems("leveluplunch.com"));
}