66import org .mockito .junit .jupiter .MockitoExtension ;
77import org .reflections .Reflections ;
88
9- import javax .servlet .ServletOutputStream ;
109import javax .servlet .annotation .WebServlet ;
1110import javax .servlet .http .HttpServlet ;
1211import javax .servlet .http .HttpServletRequest ;
2221import java .util .Set ;
2322
2423import static org .assertj .core .api .AssertionsForClassTypes .assertThat ;
25- import static org .mockito .Mockito .verify ;
2624import static org .mockito .Mockito .when ;
2725
2826
@@ -36,9 +34,6 @@ public class DateServletTest {
3634 @ Mock
3735 private HttpServletResponse response ;
3836
39- @ Mock
40- private ServletOutputStream outputStream ;
41-
4237 private Object dateServletObject ;
4338 private Class <?> dateServletClass ;
4439
@@ -56,12 +51,14 @@ public void init() throws ClassNotFoundException, IllegalAccessException, Invoca
5651
5752 @ Test
5853 @ Order (1 )
54+ @ DisplayName ("DateServlet class exists" )
5955 void dateServletClassExists () throws ClassNotFoundException {
6056 Class .forName (SERVLET_PACKAGE + "." + DATE_SERVLET );
6157 }
6258
6359 @ Test
6460 @ Order (2 )
61+ @ DisplayName ("DateServlet class extends HttpServlet" )
6562 void dateServletExtendsHttpServlet () {
6663
6764 Set <Class <? extends HttpServlet >> httpServlets =
@@ -76,6 +73,7 @@ void dateServletExtendsHttpServlet() {
7673
7774 @ Test
7875 @ Order (3 )
76+ @ DisplayName ("DateServlet class is marked as @WebServlet" )
7977 void dateServletIsMarkedAsWebServlet () {
8078 Set <Class <?>> servlets =
8179 reflections .getTypesAnnotatedWith (WebServlet .class );
@@ -88,6 +86,7 @@ void dateServletIsMarkedAsWebServlet() {
8886
8987 @ Test
9088 @ Order (4 )
89+ @ DisplayName ("DateServlet is mapped with \" /date\" path" )
9190 void dateServletIsMarkedWithProperPath () throws ClassNotFoundException {
9291 String [] value = Class .forName (SERVLET_PACKAGE + "." + DATE_SERVLET )
9392 .getAnnotation (WebServlet .class ).value ();
@@ -96,7 +95,8 @@ void dateServletIsMarkedWithProperPath() throws ClassNotFoundException {
9695
9796 @ Test
9897 @ Order (5 )
99- void dateServletReturnsDateInResponse () throws IOException , NoSuchMethodException , InvocationTargetException ,
98+ @ DisplayName ("DateServlet returns current date in a response" )
99+ void dateServletReturnsDateInResponse () throws IOException , InvocationTargetException ,
100100 IllegalAccessException {
101101 Method doGetMethod = getDoGetMethod ();
102102
@@ -108,7 +108,7 @@ void dateServletReturnsDateInResponse() throws IOException, NoSuchMethodExceptio
108108 assertThat (stringWriter .getBuffer ().toString ()).contains (LocalDate .now ().toString ());
109109 }
110110
111- private Method getDoGetMethod () throws NoSuchMethodException {
111+ private Method getDoGetMethod () {
112112 var method = Arrays .stream (dateServletClass .getDeclaredMethods ())
113113 .filter (m -> m .getName ().equals ("doGet" ))
114114 .findAny ()
0 commit comments