package annis.gui.servlets;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;

@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@ActiveProfiles("desktop")
class ResourceServletTest {

  @LocalServerPort
  private int port;

  @Autowired
  private TestRestTemplate restTemplate;

  @Test
  void emptyPath() {
    ResponseEntity<String> result =
        restTemplate.getForEntity("http://localhost:" + port + "/Resource/", String.class);
    assertEquals(HttpStatus.NOT_FOUND, result.getStatusCode());

  }

}

@@ -82,16 +82,137 @@
 tEquals;
+%0Aimport static org.junit.jupiter.api.Assertions.assertNotNull;%0Aimport static org.junit.jupiter.api.Assertions.assertTrue;
 %0A%0Aimport
@@ -956,16 +956,358 @@
 ath() %7B%0A
+    assertEquals(HttpStatus.NOT_FOUND, restTemplate%0A        .getForEntity(%22http://localhost:%22 + port + %22/Resource/%22, String.class).getStatusCode());%0A    assertEquals(HttpStatus.NOT_FOUND, restTemplate%0A        .getForEntity(%22http://localhost:%22 + port + %22/Resource%22, String.class).getStatusCode());%0A  %7D%0A%0A  @Test%0A  void dependencyResource()%0A  %7B%0A
     Resp
@@ -1360,32 +1360,45 @@
 te.getForEntity(
+%0A            
 %22http://localhos
@@ -1425,90 +1425,1342 @@
 rce/
-%22, String.class);%0A    assertEquals(HttpStatus.NOT_FOUND, result.getStatusCode());%0A
+arch_dependency/vakyartha/jquery.js%22,%0A            String.class);%0A    assertEquals(HttpStatus.OK, result.getStatusCode());%0A    assertNotNull(result.getBody());%0A    assertTrue(result.getBody()%0A        .startsWith(%22/*! jQuery v2.2.1 %7C (c) jQuery Foundation %7C jquery.org/license */%22));%0A  %7D%0A%0A%0A  @Test%0A  void unknownVis() %7B%0A    ResponseEntity%3CString%3E result = restTemplate.getForEntity(%0A        %22http://localhost:%22 + port + %22/Resource/doesnotexist/something.txt%22, String.class);%0A    assertEquals(HttpStatus.BAD_REQUEST, result.getStatusCode());%0A  %7D%0A%0A  @Test%0A  void unknownResource() %7B%0A    ResponseEntity%3CString%3E result = restTemplate.getForEntity(%0A        %22http://localhost:%22 + port + %22/Resource/arch_dependency/noththere.txt%22, String.class);%0A    assertEquals(HttpStatus.NOT_FOUND, result.getStatusCode());%0A  %7D%0A%0A  @Test%0A  void invalidPathStructure() %7B%0A    ResponseEntity%3CString%3E result = restTemplate%0A        .getForEntity(%22http://localhost:%22 + port + %22/Resource/arch_dependency%22, String.class);%0A    assertEquals(HttpStatus.NOT_FOUND, result.getStatusCode());%0A  %7D%0A%0A  @Test%0A  void invalidClassAccess() %7B%0A    ResponseEntity%3CString%3E result = restTemplate.getForEntity(%0A        %22http://localhost:%22 + port + %22/Resource/arch_dependency/VisualizerPanel.class%22,%0A        String.class);%0A    assertEquals(HttpStatus.FORBIDDEN, result.getStatusCode());
 %0A  %7D

Add more tests for ResourceServlet