11package de .envite .proa .rest ;
22
3+ import de .envite .proa .util .ResourceLoader ;
4+ import jakarta .ws .rs .core .Response ;
35import org .junit .jupiter .api .BeforeEach ;
6+ import org .junit .jupiter .api .Test ;
47import org .mockito .InjectMocks ;
8+ import org .mockito .Mock ;
59import org .mockito .MockitoAnnotations ;
610
11+ import java .io .ByteArrayInputStream ;
12+ import java .io .InputStream ;
13+
14+ import static org .junit .jupiter .api .Assertions .assertEquals ;
15+ import static org .mockito .Mockito .*;
16+
717public class RedirectionResourceTest {
818
19+ @ Mock
20+ private ResourceLoader resourceLoader ;
21+
922 @ InjectMocks
1023 private RedirectionResource redirectionResource ;
1124
@@ -14,12 +27,28 @@ public void setUp() {
1427 MockitoAnnotations .openMocks (this );
1528 }
1629
17- /* @Test
30+ @ Test
1831 public void testServeVueApp () {
32+ InputStream mockStream = new ByteArrayInputStream ("<html>Test</html>" .getBytes ());
33+ when (resourceLoader .loadResource ("META-INF/resources/index.html" )).thenReturn (mockStream );
34+
1935 Response response = redirectionResource .serveVueApp ();
2036
21- assertEquals(Response.Status.SEE_OTHER.getStatusCode(), response.getStatus());
37+ assertEquals (Response .Status .OK .getStatusCode (), response .getStatus ());
38+
39+ verify (resourceLoader , times (1 )).loadResource ("META-INF/resources/index.html" );
40+ verifyNoMoreInteractions (resourceLoader );
41+ }
2242
23- assertEquals("/", response.getHeaderString("Location"));
24- }*/
43+ @ Test
44+ public void testServeVueApp_NotFound () {
45+ when (resourceLoader .loadResource ("META-INF/resources/index.html" )).thenReturn (null );
46+
47+ Response response = redirectionResource .serveVueApp ();
48+
49+ assertEquals (Response .Status .NOT_FOUND .getStatusCode (), response .getStatus ());
50+
51+ verify (resourceLoader , times (1 )).loadResource ("META-INF/resources/index.html" );
52+ verifyNoMoreInteractions (resourceLoader );
53+ }
2554}
0 commit comments