/** * Name: MyObject * Date: * Description: Tests used to create an empty API for an immutable type MyObject * using test driven design (TDD). * * API Specification: * * public class MyObject { * public MyObject(Object[] objects) // a general constructor description * public int someMethod() // what someMethod does * public int[] someOtherMethod() // what someOtherMethod does * } * * Corner Cases * - Throw a java.lang.IllegalArgumentException if any argument is null. */ @DisplayName("MyObject Api") class TestMyObjectApi { @DisplayName("Verify methods") @Test void should_verify_api_methods() { List expected = expectedMethodNames(); List actual = actualMethodNames(); assertEquals(expected, actual); } List expectedMethodNames() { List names = Arrays.asList("someMethod", "someOtherMethod"); Collections.sort(names); return names; } List actualMethodNames() { return Spy.publicMethodNames(MyObject.class) .stream() .filter(s -> !s.equals("main")) .sorted() .collect(Collectors.toList()); } }