added unit test
This commit is contained in:
@@ -47,7 +47,7 @@ public class PictureResource {
|
|||||||
@Path("evaluation/{id}")
|
@Path("evaluation/{id}")
|
||||||
@Operation(summary = "Update evaluation for picture data to database")
|
@Operation(summary = "Update evaluation for picture data to database")
|
||||||
@ApiResponse(responseCode = "200", description = "Task successfully updated")
|
@ApiResponse(responseCode = "200", description = "Task successfully updated")
|
||||||
public Response doUpdateTask(@PathParam("id") Long id, @QueryParam("evaluation") Integer value) {
|
public Response doUpdateEvaluation(@PathParam("id") Long id, @QueryParam("evaluation") Integer value) {
|
||||||
if(value == null || value < 1 || value >3) {
|
if(value == null || value < 1 || value >3) {
|
||||||
return Response.status(Status.BAD_REQUEST).build();
|
return Response.status(Status.BAD_REQUEST).build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class PictureResourceTest extends AbstractRestTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1)
|
@Order(3)
|
||||||
public void doDelete() throws IOException {
|
public void doDelete() throws IOException {
|
||||||
LOG.info("doDelete");
|
LOG.info("doDelete");
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ public class PictureResourceTest extends AbstractRestTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1)
|
@Order(2)
|
||||||
public void doDeleteNotFound() throws IOException {
|
public void doDeleteNotFound() throws IOException {
|
||||||
LOG.info("doDeleteNotFound");
|
LOG.info("doDeleteNotFound");
|
||||||
|
|
||||||
@@ -69,4 +69,37 @@ public class PictureResourceTest extends AbstractRestTest {
|
|||||||
assertEquals(5, pictureCount());
|
assertEquals(5, pictureCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(1)
|
||||||
|
public void doEvaluation() throws IOException {
|
||||||
|
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")
|
||||||
|
.addHeader("Authorization", getAuthorization());
|
||||||
|
|
||||||
|
HttpResponse httpResponse = executeRequest(request);
|
||||||
|
int code = httpResponse.getStatusLine().getStatusCode();
|
||||||
|
assertEquals(200, code);
|
||||||
|
|
||||||
|
assertEquals(1, getCount("select count(*) from picture where picture_id = 1 and evaluation = 3"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(1)
|
||||||
|
public void doEvaluationNotFound() throws IOException {
|
||||||
|
LOG.info("doEvaluationNotFound");
|
||||||
|
|
||||||
|
String path = deploymentURL + PATH + "/evaluation/6000?evaluation=3";
|
||||||
|
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(404, code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user