package io.teiler.api.endpoint;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

import io.teiler.server.Tylr;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = Tylr.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@TestPropertySource(properties = {"local.server.port=4567"})
public class GroupEndpointTest {
    
    @LocalServerPort
    private int port;
    
    @Autowired
    private TestRestTemplate testRestTemplate;
    
    @Test
    public void shouldReturn401WhenViewingGroupWithoutValidUUID() {
        ResponseEntity<String> response = testRestTemplate.getForEntity("http://localhost:" + port + "/v1/group", String.class);
        Assert.assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode());
    }

}

@@ -239,24 +239,108 @@
 erverPort;%0D%0A
+import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;%0D%0A
 import org.s
@@ -900,16 +900,44 @@
 567%22%7D)%0D%0A
+@AutoConfigureTestDatabase%0D%0A
 public c
@@ -1253,17 +1253,15 @@
 p://
-localhost
+0.0.0.0
 :%22 +

configure unit test to use in-memory-database