cleanup and unit tests
This commit is contained in:
@@ -123,7 +123,7 @@ public class CustomerResourceTest extends AbstractRestTest {
|
||||
|
||||
String authorization = getAuthorization();
|
||||
LOG.info("authorization: " + authorization);
|
||||
String path = deploymentURL + PATH+ "?query=12.01.2026";
|
||||
String path = deploymentURL + PATH + "?query=12.01.2026";
|
||||
Request request = Request.Get(path).addHeader("Accept", "application/json; charset=utf-8")
|
||||
.addHeader("Authorization", authorization);
|
||||
|
||||
@@ -135,7 +135,7 @@ public class CustomerResourceTest extends AbstractRestTest {
|
||||
String expected = fileToString(BASE_DOWNLOAD + "doGetAllQueryDate.json");
|
||||
jsonAssert(expected, text);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
public void doGetAllQueryDate2() throws IOException {
|
||||
@@ -144,7 +144,7 @@ public class CustomerResourceTest extends AbstractRestTest {
|
||||
String authorization = getAuthorization();
|
||||
LOG.info("authorization: " + authorization);
|
||||
String query = URLEncoder.encode("12 Januar 2026", Charset.forName("utf-8"));
|
||||
String path = deploymentURL + PATH+ "?query="+ query;
|
||||
String path = deploymentURL + PATH + "?query=" + query;
|
||||
Request request = Request.Get(path).addHeader("Accept", "application/json; charset=utf-8")
|
||||
.addHeader("Authorization", authorization);
|
||||
|
||||
@@ -156,7 +156,7 @@ public class CustomerResourceTest extends AbstractRestTest {
|
||||
String expected = fileToString(BASE_DOWNLOAD + "doGetAllQueryDate.json");
|
||||
jsonAssert(expected, text);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
public void doGetAllQueryDate3() throws IOException {
|
||||
@@ -165,7 +165,7 @@ public class CustomerResourceTest extends AbstractRestTest {
|
||||
String authorization = getAuthorization();
|
||||
LOG.info("authorization: " + authorization);
|
||||
String query = URLEncoder.encode("12. Januar 2026", Charset.forName("utf-8"));
|
||||
String path = deploymentURL + PATH+ "?query="+ query;
|
||||
String path = deploymentURL + PATH + "?query=" + query;
|
||||
Request request = Request.Get(path).addHeader("Accept", "application/json; charset=utf-8")
|
||||
.addHeader("Authorization", authorization);
|
||||
|
||||
@@ -197,8 +197,7 @@ public class CustomerResourceTest extends AbstractRestTest {
|
||||
String expected = fileToString(BASE_DOWNLOAD + "doGetCustomer.json");
|
||||
jsonAssert(expected, text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
public void doDownload() throws IOException {
|
||||
@@ -213,10 +212,24 @@ public class CustomerResourceTest extends AbstractRestTest {
|
||||
HttpResponse httpResponse = executeRequest(request);
|
||||
int code = httpResponse.getStatusLine().getStatusCode();
|
||||
assertEquals(200, code);
|
||||
|
||||
|
||||
byte[] text = getResponse(httpResponse);
|
||||
writeFile(text, "doDownload.pdf");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
public void doDownloadNotExist() throws IOException {
|
||||
LOG.info("doDownloadNotExist");
|
||||
|
||||
String authorization = getAuthorization();
|
||||
LOG.info("authorization: " + authorization);
|
||||
String path = deploymentURL + PATH + "/export/9999";
|
||||
Request request = Request.Get(path).addHeader("Accept", "application/pdf")
|
||||
.addHeader("Authorization", authorization);
|
||||
|
||||
HttpResponse httpResponse = executeRequest(request);
|
||||
int code = httpResponse.getStatusLine().getStatusCode();
|
||||
assertEquals(404, code);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package marketing.heyday.hartmann.fotodocumentation.rest;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -75,8 +75,6 @@ public class PictureResourceTest extends AbstractRestTest {
|
||||
LOG.info("doEvaluation");
|
||||
|
||||
assertEquals(0, getCount("select count(*) from picture where picture_id = 1 and evaluation = 3"));
|
||||
|
||||
|
||||
|
||||
String path = deploymentURL + PATH + "/evaluation/1?evaluation=3";
|
||||
Request request = Request.Put(path).addHeader("Accept", "application/json; charset=utf-8")
|
||||
@@ -102,4 +100,82 @@ public class PictureResourceTest extends AbstractRestTest {
|
||||
int code = httpResponse.getStatusLine().getStatusCode();
|
||||
assertEquals(404, code);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
public void doEvaluationWrongValue() throws IOException {
|
||||
LOG.info("doEvaluationWrongValue");
|
||||
|
||||
String path = deploymentURL + PATH + "/evaluation/1?evaluation=4";
|
||||
Request request = Request.Put(path).addHeader("Accept", "application/json; charset=utf-8")
|
||||
.addHeader("Authorization", getAuthorization());
|
||||
|
||||
HttpResponse httpResponse = executeRequest(request);
|
||||
int code = httpResponse.getStatusLine().getStatusCode();
|
||||
assertEquals(400, code);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
public void doEvaluationWrongValue2() throws IOException {
|
||||
LOG.info("doEvaluationWrongValue2");
|
||||
|
||||
String path = deploymentURL + PATH + "/evaluation/1?evaluation=0";
|
||||
Request request = Request.Put(path).addHeader("Accept", "application/json; charset=utf-8")
|
||||
.addHeader("Authorization", getAuthorization());
|
||||
|
||||
HttpResponse httpResponse = executeRequest(request);
|
||||
int code = httpResponse.getStatusLine().getStatusCode();
|
||||
assertEquals(400, code);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
public void doEvaluationNoValue() throws IOException {
|
||||
LOG.info("doEvaluationNoValue");
|
||||
|
||||
String path = deploymentURL + PATH + "/evaluation/1";
|
||||
Request request = Request.Put(path).addHeader("Accept", "application/json; charset=utf-8")
|
||||
.addHeader("Authorization", getAuthorization());
|
||||
|
||||
HttpResponse httpResponse = executeRequest(request);
|
||||
int code = httpResponse.getStatusLine().getStatusCode();
|
||||
assertEquals(400, code);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
public void doGetPicture() throws IOException {
|
||||
LOG.info("doGetPicture");
|
||||
|
||||
String authorization = getAuthorization();
|
||||
LOG.info("authorization: " + authorization);
|
||||
String path = deploymentURL + PATH + "/image/1?size=1";
|
||||
Request request = Request.Get(path).addHeader("Accept", "image/jpg")
|
||||
.addHeader("Authorization", authorization);
|
||||
|
||||
HttpResponse httpResponse = executeRequest(request);
|
||||
int code = httpResponse.getStatusLine().getStatusCode();
|
||||
assertEquals(200, code);
|
||||
|
||||
byte[] file = getResponse(httpResponse);
|
||||
assertTrue(file.length > 0);
|
||||
writeFile(file, "doGetPicture.jpg");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
public void doGetPictureNotFound() throws IOException {
|
||||
LOG.info("doGetPicture");
|
||||
|
||||
String authorization = getAuthorization();
|
||||
LOG.info("authorization: " + authorization);
|
||||
String path = deploymentURL + PATH + "/image/9999?size=1";
|
||||
Request request = Request.Get(path).addHeader("Accept", "image/jpg")
|
||||
.addHeader("Authorization", authorization);
|
||||
|
||||
HttpResponse httpResponse = executeRequest(request);
|
||||
int code = httpResponse.getStatusLine().getStatusCode();
|
||||
assertEquals(404, code);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user