added tests and enabled the schema validation for upload

This commit is contained in:
verboomp
2026-01-28 10:46:38 +01:00
parent 98764dc51e
commit ca514eea67
10 changed files with 228 additions and 24 deletions

View File

@@ -3,6 +3,8 @@ package marketing.heyday.hartmann.fotodocumentation.rest;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -54,6 +56,128 @@ public class CustomerResourceTest extends AbstractRestTest {
jsonAssert(expected, text);
}
@Test
@Order(1)
public void doGetAllStartWith() throws IOException {
LOG.info("doGetAllStartWith");
String authorization = getAuthorization();
LOG.info("authorization: " + authorization);
String path = deploymentURL + PATH + "?startsWith=M";
Request request = Request.Get(path).addHeader("Accept", "application/json; charset=utf-8")
.addHeader("Authorization", authorization);
HttpResponse httpResponse = executeRequest(request);
int code = httpResponse.getStatusLine().getStatusCode();
assertEquals(200, code);
String text = getResponseText(httpResponse, "doGetAllStartWith");
String expected = fileToString(BASE_DOWNLOAD + "doGetAllStartWith.json");
jsonAssert(expected, text);
}
@Test
@Order(1)
public void doGetAllQueryText() throws IOException {
LOG.info("doGetAllQueryText");
String authorization = getAuthorization();
LOG.info("authorization: " + authorization);
String path = deploymentURL + PATH + "?query=2345";
Request request = Request.Get(path).addHeader("Accept", "application/json; charset=utf-8")
.addHeader("Authorization", authorization);
HttpResponse httpResponse = executeRequest(request);
int code = httpResponse.getStatusLine().getStatusCode();
assertEquals(200, code);
String text = getResponseText(httpResponse, "doGetAllQueryText");
String expected = fileToString(BASE_DOWNLOAD + "doGetAllQueryText.json");
jsonAssert(expected, text);
}
@Test
@Order(1)
public void doGetAllQueryTextWithStart() throws IOException {
LOG.info("doGetAllQueryTextWithStart");
String authorization = getAuthorization();
LOG.info("authorization: " + authorization);
String path = deploymentURL + PATH + "?query=45&startsWith=M";
Request request = Request.Get(path).addHeader("Accept", "application/json; charset=utf-8")
.addHeader("Authorization", authorization);
HttpResponse httpResponse = executeRequest(request);
int code = httpResponse.getStatusLine().getStatusCode();
assertEquals(200, code);
String text = getResponseText(httpResponse, "doGetAllQueryTextWithStart");
String expected = fileToString(BASE_DOWNLOAD + "doGetAllQueryTextWithStart.json");
jsonAssert(expected, text);
}
@Test
@Order(1)
public void doGetAllQueryDate1() throws IOException {
LOG.info("doGetAllQueryDate");
String authorization = getAuthorization();
LOG.info("authorization: " + authorization);
String path = deploymentURL + PATH+ "?query=12.01.2026";
Request request = Request.Get(path).addHeader("Accept", "application/json; charset=utf-8")
.addHeader("Authorization", authorization);
HttpResponse httpResponse = executeRequest(request);
int code = httpResponse.getStatusLine().getStatusCode();
assertEquals(200, code);
String text = getResponseText(httpResponse, "doGetAllQueryDate");
String expected = fileToString(BASE_DOWNLOAD + "doGetAllQueryDate.json");
jsonAssert(expected, text);
}
@Test
@Order(1)
public void doGetAllQueryDate2() throws IOException {
LOG.info("doGetAllQueryDate");
String authorization = getAuthorization();
LOG.info("authorization: " + authorization);
String query = URLEncoder.encode("12 Januar 2026", Charset.forName("utf-8"));
String path = deploymentURL + PATH+ "?query="+ query;
Request request = Request.Get(path).addHeader("Accept", "application/json; charset=utf-8")
.addHeader("Authorization", authorization);
HttpResponse httpResponse = executeRequest(request);
int code = httpResponse.getStatusLine().getStatusCode();
assertEquals(200, code);
String text = getResponseText(httpResponse, "doGetAllQueryDate");
String expected = fileToString(BASE_DOWNLOAD + "doGetAllQueryDate.json");
jsonAssert(expected, text);
}
@Test
@Order(1)
public void doGetAllQueryDate3() throws IOException {
LOG.info("doGetAllQueryDate");
String authorization = getAuthorization();
LOG.info("authorization: " + authorization);
String query = URLEncoder.encode("12. Januar 2026", Charset.forName("utf-8"));
String path = deploymentURL + PATH+ "?query="+ query;
Request request = Request.Get(path).addHeader("Accept", "application/json; charset=utf-8")
.addHeader("Authorization", authorization);
HttpResponse httpResponse = executeRequest(request);
int code = httpResponse.getStatusLine().getStatusCode();
assertEquals(200, code);
String text = getResponseText(httpResponse, "doGetAllQueryDate");
String expected = fileToString(BASE_DOWNLOAD + "doGetAllQueryDate.json");
jsonAssert(expected, text);
}
@Test
@Order(1)
public void doGetCustomer() throws IOException {

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
[
{
"id": 3,
"name": "Schmidt Apotheke",
"customerNumber": "3456",
"lastUpdateDate": 1768212570000
}
]

View File

@@ -0,0 +1,8 @@
[
{
"id": 2,
"name": "Meier Apotheke",
"customerNumber": "2345",
"lastUpdateDate": 1767607770000
}
]

View File

@@ -0,0 +1,8 @@
[
{
"id": 2,
"name": "Meier Apotheke",
"customerNumber": "2345",
"lastUpdateDate": 1767607770000
}
]

View File

@@ -0,0 +1,14 @@
[
{
"id": 1,
"name": "Müller Apotheke",
"customerNumber": "1234",
"lastUpdateDate": 1767348570000
},
{
"id": 2,
"name": "Meier Apotheke",
"customerNumber": "2345",
"lastUpdateDate": 1767607770000
}
]

View File

@@ -3,18 +3,18 @@
"id": 1,
"name": "Müller Apotheke",
"customerNumber": "1234",
"lastUpdateDate": 1729764570000
"lastUpdateDate": 1767348570000
},
{
"id": 2,
"name": "Meier Apotheke",
"customerNumber": "2345",
"lastUpdateDate": 1729764570000
"lastUpdateDate": 1767607770000
},
{
"id": 3,
"name": "Schmidt Apotheke",
"customerNumber": "3456",
"lastUpdateDate": 1729764570000
"lastUpdateDate": 1768212570000
}
]