From db58ae079f86ef47ca719a9c348d0d51a013f182 Mon Sep 17 00:00:00 2001 From: verboomp Date: Thu, 19 Feb 2026 12:09:43 +0100 Subject: [PATCH] unit test --- .../service/QuestionnaireCustomerService.java | 7 +- .../rest/AbstractFotoTest.java | 20 ++ .../rest/AbstractQuestionnaireTest.java | 20 ++ .../rest/AbstractRestTest.java | 8 - .../rest/CustomerPictureResourceTest.java | 8 +- .../rest/PictureResourceTest.java | 2 +- .../QuestionnaireCustomerResourceTest.java | 233 ++++++++++++++++++ .../QuestionnairePublishResourceTest.java | 95 +++++++ .../rest/QuestionnaireResourceTest.java | 145 +++++++++++ .../src/test/resources/datasets/dataset.xml | 17 ++ ...ustomerResourceTest-doGetAllQueryDate.json | 8 + ...ustomerResourceTest-doGetAllQueryText.json | 8 + ...sourceTest-doGetAllQueryTextWithStart.json | 8 + ...ustomerResourceTest-doGetAllStartWith.json | 14 ++ ...ireCustomerResourceTest-doGetCustomer.json | 25 ++ ...ionnaireCustomerResourceTest-dogetAll.json | 20 ++ ...ler.dart => foto_customer_controller.dart} | 4 +- .../customer/foto_customer_list_widget.dart | 4 +- .../foto/customer/foto_customer_widget.dart | 4 +- .../foto/customer/foto_picture_widget.dart | 4 +- .../lib/utils/di_container.dart | 4 +- ...art => foto_customer_controller_test.dart} | 4 +- ...t.dart => foto_login_controller_test.dart} | 0 ...uestionnaire_customer_controller_test.dart | 128 ++++++++++ .../customer/customer_list_widget_test.dart | 4 +- .../foto/customer/customer_widget_test.dart | 8 +- .../foto/customer/picture_widget_test.dart | 4 +- .../test/testing/test_utils.dart | 4 +- .../test/testing/test_utils.mocks.dart | 4 +- 29 files changed, 769 insertions(+), 45 deletions(-) create mode 100644 hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/AbstractFotoTest.java create mode 100644 hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/AbstractQuestionnaireTest.java create mode 100644 hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/QuestionnaireCustomerResourceTest.java create mode 100644 hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/QuestionnairePublishResourceTest.java create mode 100644 hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/QuestionnaireResourceTest.java create mode 100644 hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetAllQueryDate.json create mode 100644 hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetAllQueryText.json create mode 100644 hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetAllQueryTextWithStart.json create mode 100644 hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetAllStartWith.json create mode 100644 hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetCustomer.json create mode 100644 hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-dogetAll.json rename hartmann-foto-documentation-frontend/lib/controller/{customer_controller.dart => foto_customer_controller.dart} (89%) rename hartmann-foto-documentation-frontend/test/controller/{customer_controller_test.dart => foto_customer_controller_test.dart} (96%) rename hartmann-foto-documentation-frontend/test/controller/{login_controller_test.dart => foto_login_controller_test.dart} (100%) create mode 100644 hartmann-foto-documentation-frontend/test/controller/questionnaire_customer_controller_test.dart diff --git a/hartmann-foto-documentation-app/src/main/java/marketing/heyday/hartmann/fotodocumentation/core/service/QuestionnaireCustomerService.java b/hartmann-foto-documentation-app/src/main/java/marketing/heyday/hartmann/fotodocumentation/core/service/QuestionnaireCustomerService.java index da4b14a..bde3e94 100644 --- a/hartmann-foto-documentation-app/src/main/java/marketing/heyday/hartmann/fotodocumentation/core/service/QuestionnaireCustomerService.java +++ b/hartmann-foto-documentation-app/src/main/java/marketing/heyday/hartmann/fotodocumentation/core/service/QuestionnaireCustomerService.java @@ -14,9 +14,6 @@ import marketing.heyday.hartmann.fotodocumentation.core.model.Questionnaire; import marketing.heyday.hartmann.fotodocumentation.core.model.QuestionnaireCustomer; import marketing.heyday.hartmann.fotodocumentation.core.utils.CalendarUtil; import marketing.heyday.hartmann.fotodocumentation.core.utils.ExcelUtils; -import marketing.heyday.hartmann.fotodocumentation.core.utils.PdfUtils; -import marketing.heyday.hartmann.fotodocumentation.rest.vo.CustomerListValue; -import marketing.heyday.hartmann.fotodocumentation.rest.vo.CustomerValue; import marketing.heyday.hartmann.fotodocumentation.rest.vo.QuestionnaireCustomerListValue; import marketing.heyday.hartmann.fotodocumentation.rest.vo.QuestionnaireCustomerValue; @@ -65,11 +62,11 @@ public class QuestionnaireCustomerService extends AbstractService { Date startOfDay = calendarUtil.getStartOfDay(date); Date endOfDay = calendarUtil.getEndOfDay(date); - Fetch picturesFetch = customerRoot.fetch("pictures", JoinType.LEFT); + Fetch picturesFetch = customerRoot.fetch("questionnaires", JoinType.LEFT); @SuppressWarnings("unchecked") Join pictures = (Join) picturesFetch; - var predicateDate = builder.between(pictures.get("pictureDate"), startOfDay, endOfDay); + var predicateDate = builder.between(pictures.get("questionnaireDate"), startOfDay, endOfDay); predicates.add(predicateDate); } else { diff --git a/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/AbstractFotoTest.java b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/AbstractFotoTest.java new file mode 100644 index 0000000..5cdf0f7 --- /dev/null +++ b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/AbstractFotoTest.java @@ -0,0 +1,20 @@ +package marketing.heyday.hartmann.fotodocumentation.rest; + +/** + * + *

Copyright: Copyright (c) 2024

+ *

Company: heyday Marketing GmbH

+ * @author Patrick Verboom + * @version 1.0 + * + * created: 13 Nov 2024 + */ +public abstract class AbstractFotoTest extends AbstractRestTest { + protected int customerCount() { + return getCount("select count(*) from customer"); + } + + protected int pictureCount() { + return getCount("select count(*) from picture"); + } +} diff --git a/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/AbstractQuestionnaireTest.java b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/AbstractQuestionnaireTest.java new file mode 100644 index 0000000..19fac84 --- /dev/null +++ b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/AbstractQuestionnaireTest.java @@ -0,0 +1,20 @@ +package marketing.heyday.hartmann.fotodocumentation.rest; + +/** + * + *

Copyright: Copyright (c) 2024

+ *

Company: heyday Marketing GmbH

+ * @author Patrick Verboom + * @version 1.0 + * + * created: 13 Nov 2024 + */ +public abstract class AbstractQuestionnaireTest extends AbstractRestTest { + protected int customerCount() { + return getCount("select count(*) from questionnaire_customer"); + } + + protected int questionnaireCount() { + return getCount("select count(*) from questionnaire"); + } +} diff --git a/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/AbstractRestTest.java b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/AbstractRestTest.java index 88fc8ea..e661c65 100644 --- a/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/AbstractRestTest.java +++ b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/AbstractRestTest.java @@ -112,12 +112,4 @@ public abstract class AbstractRestTest extends AbstractTest { String className = this.getClass().getName(); return getResponseText(httpResponse, () -> className + "-" + name + ".json"); } - - protected int customerCount() { - return getCount("select count(*) from customer"); - } - - protected int pictureCount() { - return getCount("select count(*) from picture"); - } } diff --git a/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/CustomerPictureResourceTest.java b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/CustomerPictureResourceTest.java index 1788cdb..5dca22a 100644 --- a/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/CustomerPictureResourceTest.java +++ b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/CustomerPictureResourceTest.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.TestMethodOrder; * created: 14 Nov 2024 */ @TestMethodOrder(OrderAnnotation.class) -public class CustomerPictureResourceTest extends AbstractRestTest { +public class CustomerPictureResourceTest extends AbstractFotoTest { private static final Log LOG = LogFactory.getLog(CustomerPictureResourceTest.class); private static final String PATH = "api/customer-picture"; private static final String BASE_UPLOAD = "src/test/resources/upload/"; @@ -64,11 +64,8 @@ public class CustomerPictureResourceTest extends AbstractRestTest { assertEquals(3, customerCount()); assertEquals(6, pictureCount()); - String authorization = getBasicHeader(); - LOG.info("authorization: " + authorization); String path = deploymentURL + PATH; Request request = Request.Post(path).addHeader("Accept", "application/json; charset=utf-8") - .addHeader("Authorization", authorization) .bodyFile(new File(BASE_UPLOAD + "addNewCustomer.json"), ContentType.APPLICATION_JSON); HttpResponse httpResponse = executeRequest(request); @@ -84,11 +81,8 @@ public class CustomerPictureResourceTest extends AbstractRestTest { public void doAddCustomerPictureWrongJson() throws IOException { LOG.info("doAddCustomerPictureWrongJson"); - String authorization = getBasicHeader(); - LOG.info("authorization: " + authorization); String path = deploymentURL + PATH; Request request = Request.Post(path).addHeader("Accept", "application/json; charset=utf-8") - .addHeader("Authorization", authorization) .bodyFile(new File(BASE_UPLOAD + "addWrong.json"), ContentType.APPLICATION_JSON); HttpResponse httpResponse = executeRequest(request); diff --git a/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/PictureResourceTest.java b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/PictureResourceTest.java index cbee8bf..5513159 100644 --- a/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/PictureResourceTest.java +++ b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/PictureResourceTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.TestMethodOrder; * created: 14 Nov 2024 */ @TestMethodOrder(OrderAnnotation.class) -public class PictureResourceTest extends AbstractRestTest { +public class PictureResourceTest extends AbstractFotoTest { private static final Log LOG = LogFactory.getLog(PictureResourceTest.class); private static final String PATH = "api/picture"; diff --git a/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/QuestionnaireCustomerResourceTest.java b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/QuestionnaireCustomerResourceTest.java new file mode 100644 index 0000000..febc070 --- /dev/null +++ b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/QuestionnaireCustomerResourceTest.java @@ -0,0 +1,233 @@ +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; +import org.apache.http.HttpResponse; +import org.apache.http.client.fluent.Request; +import org.junit.jupiter.api.*; +import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; + +/** + * + *

Copyright: Copyright (c) 2024

+ *

Company: heyday Marketing GmbH

+ * @author Patrick Verboom + * @version 1.0 + * + * created: 14 Nov 2024 + */ +@TestMethodOrder(OrderAnnotation.class) +public class QuestionnaireCustomerResourceTest extends AbstractRestTest { + private static final Log LOG = LogFactory.getLog(QuestionnaireCustomerResourceTest.class); + private static final String PATH = "api/questionnairecustomer"; + private static final String BASE_DOWNLOAD = "json/QuestionnaireCustomerResourceTest-"; + + @BeforeAll + public static void init() { + initDB(); + } + + @Test + @Order(1) + public void doGetAll() throws IOException { + LOG.info("doGetAll"); + + String authorization = getAuthorization(); + LOG.info("authorization: " + authorization); + String path = deploymentURL + PATH; + 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, "doGetAll"); + String expected = fileToString(BASE_DOWNLOAD + "doGetAll.json"); + 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 { + LOG.info("doGetCustomer"); + + String authorization = getAuthorization(); + LOG.info("authorization: " + authorization); + String path = deploymentURL + PATH + "/1"; + 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, "doGetCustomer"); + String expected = fileToString(BASE_DOWNLOAD + "doGetCustomer.json"); + jsonAssert(expected, text); + } + + @Test + @Order(1) + @Disabled // FIXME: enable when we have implemented excel download + public void doDownload() throws IOException { + LOG.info("doDownload"); + + String authorization = getAuthorization(); + LOG.info("authorization: " + authorization); + String path = deploymentURL + PATH + "/export/1"; + Request request = Request.Get(path).addHeader("Accept", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") + .addHeader("Authorization", authorization); + + 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/vnd.openxmlformats-officedocument.spreadsheetml.sheet") + .addHeader("Authorization", authorization); + + HttpResponse httpResponse = executeRequest(request); + int code = httpResponse.getStatusLine().getStatusCode(); + assertEquals(404, code); + } +} diff --git a/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/QuestionnairePublishResourceTest.java b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/QuestionnairePublishResourceTest.java new file mode 100644 index 0000000..8bfef83 --- /dev/null +++ b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/QuestionnairePublishResourceTest.java @@ -0,0 +1,95 @@ +package marketing.heyday.hartmann.fotodocumentation.rest; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.File; +import java.io.IOException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpResponse; +import org.apache.http.client.fluent.Request; +import org.apache.http.entity.ContentType; +import org.junit.jupiter.api.*; +import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; + +/** + * + *

Copyright: Copyright (c) 2024

+ *

Company: heyday Marketing GmbH

+ * @author Patrick Verboom + * @version 1.0 + * + * created: 14 Nov 2024 + */ +@TestMethodOrder(OrderAnnotation.class) +public class QuestionnairePublishResourceTest extends AbstractQuestionnaireTest { + private static final Log LOG = LogFactory.getLog(QuestionnairePublishResourceTest.class); + private static final String PATH = "api/questionnaire-publish"; + private static final String BASE_UPLOAD = "src/test/resources/upload/"; + + @BeforeAll + public static void init() { + initDB(); + } + + @Test + @Order(2) + @Disabled // FIXME: enable when implemented + public void doAddCustomerdoAddQuestionniare() throws IOException { + LOG.info("doAddCustomerdoAddQuestionniare"); + + assertEquals(3, customerCount()); + assertEquals(5, questionnaireCount()); + + String path = deploymentURL + PATH; + Request request = Request.Post(path).addHeader("Accept", "application/json; charset=utf-8") + .bodyFile(new File(BASE_UPLOAD + "add.json"), ContentType.APPLICATION_JSON); + + HttpResponse httpResponse = executeRequest(request); + int code = httpResponse.getStatusLine().getStatusCode(); + assertEquals(200, code); + + assertEquals(3, customerCount()); + assertEquals(6, questionnaireCount()); + } + + @Test + @Order(3) + @Disabled // FIXME: enable when implemented + public void doAddCustomerWithQuestionnaire() throws IOException { + LOG.info("doAddCustomerWithQuestionnaire"); + + assertEquals(3, customerCount()); + assertEquals(6, questionnaireCount()); + + String path = deploymentURL + PATH; + Request request = Request.Post(path).addHeader("Accept", "application/json; charset=utf-8") + .bodyFile(new File(BASE_UPLOAD + "addNewCustomer.json"), ContentType.APPLICATION_JSON); + + HttpResponse httpResponse = executeRequest(request); + int code = httpResponse.getStatusLine().getStatusCode(); + assertEquals(200, code); + + assertEquals(4, customerCount()); + assertEquals(7, questionnaireCount()); + } + + @Test + @Order(1) + @Disabled // FIXME: enable when implemented + public void doAddCustomerWithQuestionnaireWrongJson() throws IOException { + LOG.info("doAddCustomerWithQuestionnaireWrongJson"); + + String path = deploymentURL + PATH; + Request request = Request.Post(path).addHeader("Accept", "application/json; charset=utf-8") + .bodyFile(new File(BASE_UPLOAD + "addWrong.json"), ContentType.APPLICATION_JSON); + + HttpResponse httpResponse = executeRequest(request); + int code = httpResponse.getStatusLine().getStatusCode(); + assertEquals(400, code); + + String text = getResponseText(httpResponse, "doGetAll"); + System.out.println(text); + } +} diff --git a/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/QuestionnaireResourceTest.java b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/QuestionnaireResourceTest.java new file mode 100644 index 0000000..efa2edf --- /dev/null +++ b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/QuestionnaireResourceTest.java @@ -0,0 +1,145 @@ +package marketing.heyday.hartmann.fotodocumentation.rest; + +import static org.junit.jupiter.api.Assertions.*; + +import java.io.IOException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpResponse; +import org.apache.http.client.fluent.Request; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; + +/** + * + *

Copyright: Copyright (c) 2024

+ *

Company: heyday Marketing GmbH

+ * @author Patrick Verboom + * @version 1.0 + * + * created: 14 Nov 2024 + */ +@TestMethodOrder(OrderAnnotation.class) +public class QuestionnaireResourceTest extends AbstractQuestionnaireTest { + private static final Log LOG = LogFactory.getLog(QuestionnaireResourceTest.class); + private static final String PATH = "api/questionnaire"; + + @BeforeAll + public static void init() { + initDB(); + } + + @Test + @Order(3) + public void doDelete() throws IOException { + LOG.info("doDelete"); + + assertEquals(5, questionnaireCount()); + + String path = deploymentURL + PATH + "/1"; + Request request = Request.Delete(path).addHeader("Accept", "application/json; charset=utf-8") + .addHeader("Authorization", getAuthorization()); + + HttpResponse httpResponse = executeRequest(request); + int code = httpResponse.getStatusLine().getStatusCode(); + assertEquals(200, code); + + assertEquals(4, questionnaireCount()); + } + + @Test + @Order(2) + public void doDeleteNotFound() throws IOException { + LOG.info("doDeleteNotFound"); + + assertEquals(5, questionnaireCount()); + + String path = deploymentURL + PATH + "/6000"; + Request request = Request.Delete(path).addHeader("Accept", "application/json; charset=utf-8") + .addHeader("Authorization", getAuthorization()); + + HttpResponse httpResponse = executeRequest(request); + int code = httpResponse.getStatusLine().getStatusCode(); + assertEquals(404, code); + + assertEquals(5, questionnaireCount()); + } + + @Test + @Order(1) + public void doEvaluation() throws IOException { + LOG.info("doEvaluation"); + + assertEquals(0, getCount("select count(*) from questionnaire where questionnaire_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 questionnaire where questionnaire_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); + } + + @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); + } +} diff --git a/hartmann-foto-documentation-docker/src/test/resources/datasets/dataset.xml b/hartmann-foto-documentation-docker/src/test/resources/datasets/dataset.xml index 9519088..d5329b5 100644 --- a/hartmann-foto-documentation-docker/src/test/resources/datasets/dataset.xml +++ b/hartmann-foto-documentation-docker/src/test/resources/datasets/dataset.xml @@ -29,4 +29,21 @@ + + + + + + + + + + + + diff --git a/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetAllQueryDate.json b/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetAllQueryDate.json new file mode 100644 index 0000000..995021b --- /dev/null +++ b/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetAllQueryDate.json @@ -0,0 +1,8 @@ +[ + { + "id": 3, + "name": "Schmidt Apotheke", + "customerNumber": "3456", + "lastUpdateDate": 1768212570000 + } +] \ No newline at end of file diff --git a/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetAllQueryText.json b/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetAllQueryText.json new file mode 100644 index 0000000..97783c2 --- /dev/null +++ b/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetAllQueryText.json @@ -0,0 +1,8 @@ +[ + { + "id": 2, + "name": "Meier Apotheke", + "customerNumber": "2345", + "lastUpdateDate": 1767607770000 + } +] \ No newline at end of file diff --git a/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetAllQueryTextWithStart.json b/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetAllQueryTextWithStart.json new file mode 100644 index 0000000..97783c2 --- /dev/null +++ b/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetAllQueryTextWithStart.json @@ -0,0 +1,8 @@ +[ + { + "id": 2, + "name": "Meier Apotheke", + "customerNumber": "2345", + "lastUpdateDate": 1767607770000 + } +] \ No newline at end of file diff --git a/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetAllStartWith.json b/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetAllStartWith.json new file mode 100644 index 0000000..19040a9 --- /dev/null +++ b/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetAllStartWith.json @@ -0,0 +1,14 @@ +[ + { + "id": 1, + "name": "Müller Apotheke", + "customerNumber": "1234", + "lastUpdateDate": 1767348570000 + }, + { + "id": 2, + "name": "Meier Apotheke", + "customerNumber": "2345", + "lastUpdateDate": 1767607770000 + } +] \ No newline at end of file diff --git a/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetCustomer.json b/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetCustomer.json new file mode 100644 index 0000000..2e4ef75 --- /dev/null +++ b/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-doGetCustomer.json @@ -0,0 +1,25 @@ +{ + "id": 1, + "name": "Müller Apotheke", + "customerNumber": "1234", + "city": "Hannover", + "zip": "12345", + "questionnaires": [ + { + "id": 1, + "comment": "good looking picture 1", + "category": null, + "questionnaireDate": 1767262170000, + "username": "verboomp", + "evaluation": 1 + }, + { + "id": 2, + "comment": "good looking picture 2", + "category": null, + "questionnaireDate": 1767348570000, + "username": "verboomp", + "evaluation": 1 + } + ] +} \ No newline at end of file diff --git a/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-dogetAll.json b/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-dogetAll.json new file mode 100644 index 0000000..5a5bd88 --- /dev/null +++ b/hartmann-foto-documentation-docker/src/test/resources/json/QuestionnaireCustomerResourceTest-dogetAll.json @@ -0,0 +1,20 @@ +[ + { + "id": 1, + "name": "Müller Apotheke", + "customerNumber": "1234", + "lastUpdateDate": 1767348570000 + }, + { + "id": 2, + "name": "Meier Apotheke", + "customerNumber": "2345", + "lastUpdateDate": 1767607770000 + }, + { + "id": 3, + "name": "Schmidt Apotheke", + "customerNumber": "3456", + "lastUpdateDate": 1768212570000 + } +] \ No newline at end of file diff --git a/hartmann-foto-documentation-frontend/lib/controller/customer_controller.dart b/hartmann-foto-documentation-frontend/lib/controller/foto_customer_controller.dart similarity index 89% rename from hartmann-foto-documentation-frontend/lib/controller/customer_controller.dart rename to hartmann-foto-documentation-frontend/lib/controller/foto_customer_controller.dart index ec8fe00..9c358da 100644 --- a/hartmann-foto-documentation-frontend/lib/controller/customer_controller.dart +++ b/hartmann-foto-documentation-frontend/lib/controller/foto_customer_controller.dart @@ -1,7 +1,7 @@ import 'package:fotodocumentation/controller/base_controller.dart'; import 'package:fotodocumentation/dto/customer_dto.dart'; -abstract interface class CustomerController { +abstract interface class FotoCustomerController { Future> getAll(String query, String startsWith); Future get({required int id}); @@ -9,7 +9,7 @@ abstract interface class CustomerController { Future> export({required int customerId, int? pictureId}); } -class CustomerControllerImpl extends BaseController implements CustomerController { +class FotoCustomerControllerImpl extends BaseController implements FotoCustomerController { final String path = "customer"; @override diff --git a/hartmann-foto-documentation-frontend/lib/pages/foto/customer/foto_customer_list_widget.dart b/hartmann-foto-documentation-frontend/lib/pages/foto/customer/foto_customer_list_widget.dart index 9a28985..20024c0 100644 --- a/hartmann-foto-documentation-frontend/lib/pages/foto/customer/foto_customer_list_widget.dart +++ b/hartmann-foto-documentation-frontend/lib/pages/foto/customer/foto_customer_list_widget.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:fotodocumentation/controller/base_controller.dart'; -import 'package:fotodocumentation/controller/customer_controller.dart'; +import 'package:fotodocumentation/controller/foto_customer_controller.dart'; import 'package:fotodocumentation/dto/customer_dto.dart'; import 'package:fotodocumentation/l10n/app_localizations.dart'; import 'package:fotodocumentation/pages/ui_utils/component/general_error_widget.dart'; @@ -21,7 +21,7 @@ class FotoCustomerListWidget extends StatefulWidget { } class _FotoCustomerListWidgetState extends State { - CustomerController get _customerController => DiContainer.get(); + FotoCustomerController get _customerController => DiContainer.get(); GeneralStyle get _generalStyle => DiContainer.get(); final _searchController = TextEditingController(); diff --git a/hartmann-foto-documentation-frontend/lib/pages/foto/customer/foto_customer_widget.dart b/hartmann-foto-documentation-frontend/lib/pages/foto/customer/foto_customer_widget.dart index d6636c1..928eb93 100644 --- a/hartmann-foto-documentation-frontend/lib/pages/foto/customer/foto_customer_widget.dart +++ b/hartmann-foto-documentation-frontend/lib/pages/foto/customer/foto_customer_widget.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:fotodocumentation/controller/base_controller.dart'; -import 'package:fotodocumentation/controller/customer_controller.dart'; +import 'package:fotodocumentation/controller/foto_customer_controller.dart'; import 'package:fotodocumentation/controller/picture_controller.dart'; import 'package:fotodocumentation/dto/customer_dto.dart'; import 'package:fotodocumentation/dto/picture_dto.dart'; @@ -26,7 +26,7 @@ class FotoCustomerWidget extends StatefulWidget { } class _FotoCustomerWidgetState extends State { - CustomerController get _customerController => DiContainer.get(); + FotoCustomerController get _customerController => DiContainer.get(); PictureController get _pictureController => DiContainer.get(); GeneralStyle get _generalStyle => DiContainer.get(); diff --git a/hartmann-foto-documentation-frontend/lib/pages/foto/customer/foto_picture_widget.dart b/hartmann-foto-documentation-frontend/lib/pages/foto/customer/foto_picture_widget.dart index 3668730..3f28b76 100644 --- a/hartmann-foto-documentation-frontend/lib/pages/foto/customer/foto_picture_widget.dart +++ b/hartmann-foto-documentation-frontend/lib/pages/foto/customer/foto_picture_widget.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:fotodocumentation/controller/base_controller.dart'; -import 'package:fotodocumentation/controller/customer_controller.dart'; +import 'package:fotodocumentation/controller/foto_customer_controller.dart'; import 'package:fotodocumentation/controller/picture_controller.dart'; import 'package:fotodocumentation/dto/customer_dto.dart'; import 'package:fotodocumentation/dto/picture_dto.dart'; @@ -26,7 +26,7 @@ class FotoPictureWidget extends StatefulWidget { class _FotoPictureWidgetState extends State { GeneralStyle get _generalStyle => DiContainer.get(); - CustomerController get _customerController => DiContainer.get(); + FotoCustomerController get _customerController => DiContainer.get(); PictureController get _pictureController => DiContainer.get(); late CustomerDto _customerDto; diff --git a/hartmann-foto-documentation-frontend/lib/utils/di_container.dart b/hartmann-foto-documentation-frontend/lib/utils/di_container.dart index 504e6d4..d52705a 100644 --- a/hartmann-foto-documentation-frontend/lib/utils/di_container.dart +++ b/hartmann-foto-documentation-frontend/lib/utils/di_container.dart @@ -1,4 +1,4 @@ -import 'package:fotodocumentation/controller/customer_controller.dart'; +import 'package:fotodocumentation/controller/foto_customer_controller.dart'; import 'package:fotodocumentation/controller/login_controller.dart'; import 'package:fotodocumentation/controller/picture_controller.dart'; import 'package:fotodocumentation/controller/questionnaire_controller.dart'; @@ -26,7 +26,7 @@ class DiContainer { DiContainer.instance.put(HttpClientUtils, HttpCLientUtilsImpl()); DiContainer.instance.put(UrlUtils, UrlUtilsImpl()); DiContainer.instance.put(LoginController, LoginControllerImpl()); - DiContainer.instance.put(CustomerController, CustomerControllerImpl()); + DiContainer.instance.put(FotoCustomerController, FotoCustomerControllerImpl()); DiContainer.instance.put(PictureController, PictureControllerImpl()); DiContainer.instance.put(QuestionnaireCustomerController, QuestionnaireCustomerControllerImpl()); diff --git a/hartmann-foto-documentation-frontend/test/controller/customer_controller_test.dart b/hartmann-foto-documentation-frontend/test/controller/foto_customer_controller_test.dart similarity index 96% rename from hartmann-foto-documentation-frontend/test/controller/customer_controller_test.dart rename to hartmann-foto-documentation-frontend/test/controller/foto_customer_controller_test.dart index 0298f74..49fdce4 100644 --- a/hartmann-foto-documentation-frontend/test/controller/customer_controller_test.dart +++ b/hartmann-foto-documentation-frontend/test/controller/foto_customer_controller_test.dart @@ -1,6 +1,6 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:fotodocumentation/controller/base_controller.dart'; -import 'package:fotodocumentation/controller/customer_controller.dart'; +import 'package:fotodocumentation/controller/foto_customer_controller.dart'; import 'package:fotodocumentation/dto/customer_dto.dart'; import 'package:fotodocumentation/utils/di_container.dart'; import 'package:fotodocumentation/utils/http_client_utils.dart'; @@ -17,7 +17,7 @@ void main() { when(jwtTokenStorage.getAccessToken()).thenAnswer((_) => null); DiContainer.instance.put(JwtTokenStorage, jwtTokenStorage); - CustomerController controller = CustomerControllerImpl(); + FotoCustomerController controller = FotoCustomerControllerImpl(); group('PictureControllerTest', () { test('returns a list of customers', () async { diff --git a/hartmann-foto-documentation-frontend/test/controller/login_controller_test.dart b/hartmann-foto-documentation-frontend/test/controller/foto_login_controller_test.dart similarity index 100% rename from hartmann-foto-documentation-frontend/test/controller/login_controller_test.dart rename to hartmann-foto-documentation-frontend/test/controller/foto_login_controller_test.dart diff --git a/hartmann-foto-documentation-frontend/test/controller/questionnaire_customer_controller_test.dart b/hartmann-foto-documentation-frontend/test/controller/questionnaire_customer_controller_test.dart new file mode 100644 index 0000000..2a82055 --- /dev/null +++ b/hartmann-foto-documentation-frontend/test/controller/questionnaire_customer_controller_test.dart @@ -0,0 +1,128 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:fotodocumentation/controller/base_controller.dart'; +import 'package:fotodocumentation/controller/questionnaire_customer_controller.dart'; +import 'package:fotodocumentation/dto/questionnaire_customer_dto.dart'; +import 'package:fotodocumentation/utils/di_container.dart'; +import 'package:fotodocumentation/utils/http_client_utils.dart'; +import 'package:fotodocumentation/utils/jwt_token_storage.dart'; +import 'package:http/http.dart' as http; +import 'package:mockito/mockito.dart'; + +import '../testing/test_http_client_utils.dart'; +import '../testing/test_utils.mocks.dart'; + +void main() { + DiContainer.instance.initState(); + var jwtTokenStorage = MockJwtTokenStorage(); + when(jwtTokenStorage.getAccessToken()).thenAnswer((_) => null); + DiContainer.instance.put(JwtTokenStorage, jwtTokenStorage); + + QuestionnaireCustomerController controller = QuestionnaireCustomerControllerImpl(); + + group('PictureControllerTest', () { + test('returns a list of customers', () async { + final client = MockClient(); + DiContainer.instance.put(HttpClientUtils, TestHttpCLientUtilsImpl(client)); + when(client.get(Uri.parse('http://localhost:8080/api/questionnairecustomer?query=&startsWith='), headers: {"Accept-Language": "en-US"})).thenAnswer((_) async => http.Response(_customersJson, 200)); + + var dtos = await controller.getAll("", ""); + expect(dtos, isA>()); + expect(dtos.length, 3); + }); + + test('throws an exception if the http call completes with an error', () async { + final client = MockClient(); + DiContainer.instance.put(HttpClientUtils, TestHttpCLientUtilsImpl(client)); + + when(client.get(Uri.parse('http://localhost:8080/api/questionnairecustomer?query=&startsWith='), headers: {"Accept-Language": "en-US"})).thenAnswer((_) async => http.Response('Not Found', 404)); + + expect(() async => await controller.getAll("", ""), throwsA(isA())); + }); + }); + + + test('returns a customer', () async { + final client = MockClient(); + DiContainer.instance.put(HttpClientUtils, TestHttpCLientUtilsImpl(client)); + + when(client.get(Uri.parse('http://localhost:8080/api/questionnairecustomer/4'), headers: {"Accept-Language": "en-US"})) + .thenAnswer((_) async => http.Response(_customerJson, 200)); + + var dto = await controller.get(id: 4); + expect(dto, isA()); + }); + + test('export a customer', () async { + final client = MockClient(); + DiContainer.instance.put(HttpClientUtils, TestHttpCLientUtilsImpl(client)); + + when(client.get(Uri.parse('http://localhost:8080/api/questionnairecustomer/export/4'), headers: {"Accept-Language": "en-US"})) + .thenAnswer((_) async => http.Response(_customerJson, 200)); + + var dto = await controller.export(customerId: 4); + expect(dto, isA>()); + }); + + test('export a customer picture', () async { + final client = MockClient(); + DiContainer.instance.put(HttpClientUtils, TestHttpCLientUtilsImpl(client)); + + when(client.get(Uri.parse('http://localhost:8080/api/questionnairecustomer/export/4?picture=1'), headers: {"Accept-Language": "en-US"})) + .thenAnswer((_) async => http.Response(_customerJson, 200)); + + var dto = await controller.export(customerId: 4, questionnaireId: 1); + expect(dto, isA>()); + }); +} + +String _customersJson = '''[ + { + "id": 1, + "name": "Müller Apotheke", + "customerNumber": "1234", + "lastUpdateDate": 1729764570000 + }, + { + "id": 2, + "name": "Meier Apotheke", + "customerNumber": "2345", + "lastUpdateDate": 1729764570000 + }, + { + "id": 3, + "name": "Schmidt Apotheke", + "customerNumber": "3456", + "lastUpdateDate": 1729764570000 + } +]'''; + +String _customerJson = '''{ + "id": 1, + "name": "Müller Apotheke", + "customerNumber": "1234", + "pictures": [ + { + "id": 1, + "comment": "good looking picture 1", + "category": null, + "pictureDate": 1729764570000, + "evaluation": 1, + "username": "verboomp", + "imageUrl": "", + "normalSizeUrl": "", + "thumbnailSizeUrl": "" + }, + { + "id": 2, + "comment": "good looking picture 2", + "category": null, + "pictureDate": 1729764570000, + "evaluation": 1, + "username": "verboomp", + "imageUrl": "", + "normalSizeUrl": "", + "thumbnailSizeUrl": "" + } + ] +}'''; + diff --git a/hartmann-foto-documentation-frontend/test/pages/foto/customer/customer_list_widget_test.dart b/hartmann-foto-documentation-frontend/test/pages/foto/customer/customer_list_widget_test.dart index 8baaa52..5f70708 100644 --- a/hartmann-foto-documentation-frontend/test/pages/foto/customer/customer_list_widget_test.dart +++ b/hartmann-foto-documentation-frontend/test/pages/foto/customer/customer_list_widget_test.dart @@ -6,7 +6,7 @@ import 'package:fotodocumentation/utils/global_router.dart'; import 'package:fotodocumentation/utils/login_credentials.dart'; import 'package:mockito/mockito.dart'; -import 'package:fotodocumentation/controller/customer_controller.dart'; +import 'package:fotodocumentation/controller/foto_customer_controller.dart'; import 'package:fotodocumentation/dto/customer_dto.dart'; import 'package:fotodocumentation/utils/di_container.dart'; @@ -31,7 +31,7 @@ Future _searchtest(WidgetTester tester) async { String searchText = 'Henk'; var controller = MockCustomerController(); - DiContainer.instance.put(CustomerController, controller); + DiContainer.instance.put(FotoCustomerController, controller); when(controller.getAll("", "")).thenAnswer((_) async => _list); when(controller.getAll(searchText, "")).thenAnswer((_) async => [_list.first]); diff --git a/hartmann-foto-documentation-frontend/test/pages/foto/customer/customer_widget_test.dart b/hartmann-foto-documentation-frontend/test/pages/foto/customer/customer_widget_test.dart index 1fb1ae0..a1f43c1 100644 --- a/hartmann-foto-documentation-frontend/test/pages/foto/customer/customer_widget_test.dart +++ b/hartmann-foto-documentation-frontend/test/pages/foto/customer/customer_widget_test.dart @@ -8,7 +8,7 @@ import 'package:fotodocumentation/utils/global_router.dart'; import 'package:fotodocumentation/utils/login_credentials.dart'; import 'package:mockito/mockito.dart'; -import 'package:fotodocumentation/controller/customer_controller.dart'; +import 'package:fotodocumentation/controller/foto_customer_controller.dart'; import 'package:fotodocumentation/controller/picture_controller.dart'; import 'package:fotodocumentation/dto/customer_dto.dart'; import 'package:fotodocumentation/utils/di_container.dart'; @@ -28,7 +28,7 @@ void main() { var controller = MockCustomerController(); var pictureController = MockPictureController(); DiContainer.instance.put(PictureController, pictureController); - DiContainer.instance.put(CustomerController, controller); + DiContainer.instance.put(FotoCustomerController, controller); when(controller.get(id: 1)).thenAnswer((_) async => _dto); when(controller.getAll("", "")).thenAnswer((_) async => _list); @@ -51,7 +51,7 @@ void main() { var controller = MockCustomerController(); var pictureController = MockPictureController(); DiContainer.instance.put(PictureController, pictureController); - DiContainer.instance.put(CustomerController, controller); + DiContainer.instance.put(FotoCustomerController, controller); when(controller.get(id: 1)).thenAnswer((_) async => _dto); when(controller.getAll("", "")).thenAnswer((_) async => _list); @@ -83,7 +83,7 @@ void main() { var controller = MockCustomerController(); var pictureController = MockPictureController(); DiContainer.instance.put(PictureController, pictureController); - DiContainer.instance.put(CustomerController, controller); + DiContainer.instance.put(FotoCustomerController, controller); when(controller.get(id: 1)).thenAnswer((_) async => _dto); when(controller.getAll("", "")).thenAnswer((_) async => _list); diff --git a/hartmann-foto-documentation-frontend/test/pages/foto/customer/picture_widget_test.dart b/hartmann-foto-documentation-frontend/test/pages/foto/customer/picture_widget_test.dart index 2af1068..90b8bd0 100644 --- a/hartmann-foto-documentation-frontend/test/pages/foto/customer/picture_widget_test.dart +++ b/hartmann-foto-documentation-frontend/test/pages/foto/customer/picture_widget_test.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_image_test_utils/image_test/image_test_io.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:fotodocumentation/controller/customer_controller.dart'; +import 'package:fotodocumentation/controller/foto_customer_controller.dart'; import 'package:fotodocumentation/dto/customer_dto.dart' show CustomerDto, CustomerListDto; import 'package:fotodocumentation/dto/picture_dto.dart'; import 'package:fotodocumentation/pages/foto/customer/foto_picture_fullscreen_dialog.dart'; @@ -69,7 +69,7 @@ void main() { ); mockCustomerController = MockCustomerController(); - DiContainer.instance.put(CustomerController, mockCustomerController); + DiContainer.instance.put(FotoCustomerController, mockCustomerController); }); group('PictureWidget', () { diff --git a/hartmann-foto-documentation-frontend/test/testing/test_utils.dart b/hartmann-foto-documentation-frontend/test/testing/test_utils.dart index 20f3956..171ac39 100644 --- a/hartmann-foto-documentation-frontend/test/testing/test_utils.dart +++ b/hartmann-foto-documentation-frontend/test/testing/test_utils.dart @@ -6,7 +6,7 @@ import 'package:http/http.dart' as http; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; -import 'package:fotodocumentation/controller/customer_controller.dart'; +import 'package:fotodocumentation/controller/foto_customer_controller.dart'; import 'package:fotodocumentation/controller/login_controller.dart'; import 'package:fotodocumentation/controller/picture_controller.dart'; import 'package:fotodocumentation/l10n/app_localizations.dart'; @@ -63,7 +63,7 @@ Future pumpAppConfig(WidgetTester tester, String initialLocation) async { @GenerateMocks([ LoginCredentials, LoginController, - CustomerController, + FotoCustomerController, PictureController, JwtTokenStorage, http.Client, diff --git a/hartmann-foto-documentation-frontend/test/testing/test_utils.mocks.dart b/hartmann-foto-documentation-frontend/test/testing/test_utils.mocks.dart index f94e93d..e9ca159 100644 --- a/hartmann-foto-documentation-frontend/test/testing/test_utils.mocks.dart +++ b/hartmann-foto-documentation-frontend/test/testing/test_utils.mocks.dart @@ -8,7 +8,7 @@ import 'dart:convert' as _i14; import 'dart:typed_data' as _i15; import 'dart:ui' as _i5; -import 'package:fotodocumentation/controller/customer_controller.dart' as _i9; +import 'package:fotodocumentation/controller/foto_customer_controller.dart' as _i9; import 'package:fotodocumentation/controller/login_controller.dart' as _i6; import 'package:fotodocumentation/controller/picture_controller.dart' as _i11; import 'package:fotodocumentation/dto/customer_dto.dart' as _i10; @@ -188,7 +188,7 @@ class MockLoginController extends _i1.Mock implements _i6.LoginController { /// /// See the documentation for Mockito's code generation for more information. class MockCustomerController extends _i1.Mock - implements _i9.CustomerController { + implements _i9.FotoCustomerController { MockCustomerController() { _i1.throwOnMissingStub(this); }