@@ -1903,6 +1903,108 @@ examples:
19031903 language: java
19041904 ---
19051905type : specs.openrewrite.org/v1beta/example
1906+ recipeName : org.openrewrite.java.testing.hamcrest.HamcrestEveryItemToAssertJ
1907+ examples :
1908+ - description : ' `HamcrestEveryItemToAssertJTest#everyItemInstanceOf`'
1909+ sources :
1910+ - before : |
1911+ import java.util.List;
1912+ import org.junit.jupiter.api.Test;
1913+
1914+ import static org.hamcrest.MatcherAssert.assertThat;
1915+ import static org.hamcrest.Matchers.everyItem;
1916+ import static org.hamcrest.Matchers.instanceOf;
1917+
1918+ class MyTest {
1919+ @Test
1920+ void testMethod() {
1921+ List<Object> list = List.of("a", "b");
1922+ assertThat(list, everyItem(instanceOf(String.class)));
1923+ }
1924+ }
1925+ after: |
1926+ import java.util.List;
1927+ import org.junit.jupiter.api.Test;
1928+
1929+ import static org.assertj.core.api.Assertions.assertThat;
1930+
1931+ class MyTest {
1932+ @Test
1933+ void testMethod() {
1934+ List<Object> list = List.of("a", "b");
1935+ assertThat(list).hasOnlyElementsOfType(String.class);
1936+ }
1937+ }
1938+ language: java
1939+ ---
1940+ type : specs.openrewrite.org/v1beta/example
1941+ recipeName : org.openrewrite.java.testing.hamcrest.HamcrestHasItemMatcherToAssertJ
1942+ examples :
1943+ - description : ' `HamcrestHasItemMatcherToAssertJTest#hasItemInstanceOf`'
1944+ sources :
1945+ - before : |
1946+ import java.util.List;
1947+ import org.junit.jupiter.api.Test;
1948+
1949+ import static org.hamcrest.MatcherAssert.assertThat;
1950+ import static org.hamcrest.Matchers.hasItem;
1951+ import static org.hamcrest.Matchers.instanceOf;
1952+
1953+ class MyTest {
1954+ @Test
1955+ void testMethod() {
1956+ List<Object> list = List.of("a", 1, 2.0);
1957+ assertThat(list, hasItem(instanceOf(String.class)));
1958+ }
1959+ }
1960+ after: |
1961+ import java.util.List;
1962+ import org.junit.jupiter.api.Test;
1963+
1964+ import static org.assertj.core.api.Assertions.assertThat;
1965+
1966+ class MyTest {
1967+ @Test
1968+ void testMethod() {
1969+ List<Object> list = List.of("a", 1, 2.0);
1970+ assertThat(list).hasAtLeastOneElementOfType(String.class);
1971+ }
1972+ }
1973+ language: java
1974+ ---
1975+ type : specs.openrewrite.org/v1beta/example
1976+ recipeName : org.openrewrite.java.testing.hamcrest.HamcrestHasPropertyToAssertJ
1977+ examples :
1978+ - description : ' `HamcrestHasPropertyToAssertJTest#hasPropertyName`'
1979+ sources :
1980+ - before : |
1981+ import org.junit.jupiter.api.Test;
1982+
1983+ import static org.hamcrest.MatcherAssert.assertThat;
1984+ import static org.hamcrest.Matchers.hasProperty;
1985+
1986+ class MyTest {
1987+ @Test
1988+ void testMethod() {
1989+ Object obj = new Object();
1990+ assertThat(obj, hasProperty("class"));
1991+ }
1992+ }
1993+ after: |
1994+ import org.junit.jupiter.api.Test;
1995+
1996+ import static org.assertj.core.api.Assertions.assertThat;
1997+
1998+ class MyTest {
1999+ @Test
2000+ void testMethod() {
2001+ Object obj = new Object();
2002+ assertThat(obj).hasFieldOrProperty("class");
2003+ }
2004+ }
2005+ language: java
2006+ ---
2007+ type : specs.openrewrite.org/v1beta/example
19062008recipeName : org.openrewrite.java.testing.hamcrest.HamcrestInstanceOfToJUnit5
19072009examples :
19082010- description : ' `HamcrestInstanceOfToJUnit5Test#instanceOf`'
0 commit comments