diff --git a/2-0-servlet-api/2-0-1-hello-servlet-api/src/test/java/com/bobocode/DateServletTest.java b/2-0-servlet-api/2-0-1-hello-servlet-api/src/test/java/com/bobocode/DateServletTest.java index 5ea7b3b..ba9fbdf 100644 --- a/2-0-servlet-api/2-0-1-hello-servlet-api/src/test/java/com/bobocode/DateServletTest.java +++ b/2-0-servlet-api/2-0-1-hello-servlet-api/src/test/java/com/bobocode/DateServletTest.java @@ -6,7 +6,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.reflections.Reflections; -import javax.servlet.ServletOutputStream; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -22,7 +21,6 @@ import java.util.Set; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -36,9 +34,6 @@ public class DateServletTest { @Mock private HttpServletResponse response; - @Mock - private ServletOutputStream outputStream; - private Object dateServletObject; private Class dateServletClass; @@ -56,12 +51,14 @@ public void init() throws ClassNotFoundException, IllegalAccessException, Invoca @Test @Order(1) + @DisplayName("DateServlet class exists") void dateServletClassExists() throws ClassNotFoundException { Class.forName(SERVLET_PACKAGE + "." + DATE_SERVLET); } @Test @Order(2) + @DisplayName("DateServlet class extends HttpServlet") void dateServletExtendsHttpServlet() { Set> httpServlets = @@ -76,6 +73,7 @@ void dateServletExtendsHttpServlet() { @Test @Order(3) + @DisplayName("DateServlet class is marked as @WebServlet") void dateServletIsMarkedAsWebServlet() { Set> servlets = reflections.getTypesAnnotatedWith(WebServlet.class); @@ -88,6 +86,7 @@ void dateServletIsMarkedAsWebServlet() { @Test @Order(4) + @DisplayName("DateServlet is mapped with \"/date\" path") void dateServletIsMarkedWithProperPath() throws ClassNotFoundException { String[] value = Class.forName(SERVLET_PACKAGE + "." + DATE_SERVLET) .getAnnotation(WebServlet.class).value(); @@ -96,7 +95,8 @@ void dateServletIsMarkedWithProperPath() throws ClassNotFoundException { @Test @Order(5) - void dateServletReturnsDateInResponse() throws IOException, NoSuchMethodException, InvocationTargetException, + @DisplayName("DateServlet returns current date in a response") + void dateServletReturnsDateInResponse() throws IOException, InvocationTargetException, IllegalAccessException { Method doGetMethod = getDoGetMethod(); @@ -108,7 +108,7 @@ void dateServletReturnsDateInResponse() throws IOException, NoSuchMethodExceptio assertThat(stringWriter.getBuffer().toString()).contains(LocalDate.now().toString()); } - private Method getDoGetMethod() throws NoSuchMethodException { + private Method getDoGetMethod() { var method = Arrays.stream(dateServletClass.getDeclaredMethods()) .filter(m -> m.getName().equals("doGet")) .findAny()