few improvements
This commit is contained in:
@@ -1,13 +1,43 @@
|
||||
package _11.asktpk.artisanconnectbackend;
|
||||
|
||||
import _11.asktpk.artisanconnectbackend.Model.Notice;
|
||||
import _11.asktpk.artisanconnectbackend.Service.PostgresDatabase;
|
||||
import okhttp3.*;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SpringBootTest
|
||||
class ArtisanConnectBackendApplicationTests {
|
||||
private static final Logger logger = LogManager.getLogger(ArtisanConnectBackendApplicationTests.class);
|
||||
|
||||
@Autowired
|
||||
PostgresDatabase postgresDatabase;
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
void testPostgresDatabase() {
|
||||
postgresDatabase.add(new Notice("Test Notice", "Username", "Test Description"));
|
||||
Boolean isRecordAvailable = postgresDatabase.get().size() > 0;
|
||||
if(isRecordAvailable) {
|
||||
logger.info("The record is available in the database");
|
||||
} else {
|
||||
logger.error("The record is not available in the database");
|
||||
}
|
||||
assert isRecordAvailable;
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAllNotices() throws IOException {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("text/plain");
|
||||
Request request = new Request.Builder()
|
||||
.url("http://localhost:8080/api/v1/notices/all")
|
||||
.build();
|
||||
Response response = client.newCall(request).execute();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user