From f428cd4b8e0a8225a16817759e026805ae78f092 Mon Sep 17 00:00:00 2001
From: Ahmad Arslan <arslan0157@gmail.com>
Date: Sat, 21 May 2022 17:57:14 +0200
Subject: [PATCH] Test Implementation of the methods

---
 .../rwth/swc/sqa/api/CustomerController.java  | 45 +++++++++++++++++++
 .../de/rwth/swc/sqa/api/TicketController.java |  2 +
 2 files changed, 47 insertions(+)

diff --git a/src/main/java/de/rwth/swc/sqa/api/CustomerController.java b/src/main/java/de/rwth/swc/sqa/api/CustomerController.java
index 6038813..22f6ba2 100644
--- a/src/main/java/de/rwth/swc/sqa/api/CustomerController.java
+++ b/src/main/java/de/rwth/swc/sqa/api/CustomerController.java
@@ -1,7 +1,52 @@
 package de.rwth.swc.sqa.api;
 
+import de.rwth.swc.sqa.model.DiscountCard;
+import io.swagger.annotations.ApiParam;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.net.http.HttpResponse;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
 @Controller
+@RequestMapping("/customers")
 public class CustomerController implements CustomersApi{
+
+    @PostMapping("/{customerId}/discountcards")
+    public ResponseEntity<DiscountCard> addDiscountCardToCustomer(@ApiParam(value = "ID of customer",required = true) @PathVariable("customerId") Long customerId, @ApiParam(value = "DiscountCard object that needs to be added to the customer",required = true) @RequestBody @Valid DiscountCard body) {
+        this.getRequest().ifPresent((request) -> {
+            Iterator var1 = MediaType.parseMediaTypes(request.getHeader("Accept")).iterator();
+
+            while(var1.hasNext()) {
+                MediaType mediaType = (MediaType)var1.next();
+                if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
+                    String exampleString = "{ \"validFor\" : \"30d\", \"customerId\" : 6, \"id\" : 0, \"validFrom\" : \"1992-01-01\", \"type\" : 1 }";
+                    ApiUtil.setExampleResponse(request, "application/json", exampleString);
+                    break;
+                }
+            }
+
+        });
+        return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED);
+    }
+
+    @GetMapping("/{customerId}/discountcards")
+    public ResponseEntity<List<DiscountCard>> getCustomerDiscountCards(@ApiParam(value = "ID of customer to search for discount cards",required = true) @PathVariable("customerId") Long customerId) {
+        List<DiscountCard> customerDiscountCards = new ArrayList<DiscountCard>();
+
+        DiscountCard testCard = new DiscountCard();
+        testCard.setCustomerId(new Long(55443327));
+        testCard.setType(1);
+
+        customerDiscountCards.add(testCard);
+
+        return ResponseEntity.ok().body(customerDiscountCards);
+    }
+
 }
diff --git a/src/main/java/de/rwth/swc/sqa/api/TicketController.java b/src/main/java/de/rwth/swc/sqa/api/TicketController.java
index c2daceb..e41d626 100644
--- a/src/main/java/de/rwth/swc/sqa/api/TicketController.java
+++ b/src/main/java/de/rwth/swc/sqa/api/TicketController.java
@@ -1,7 +1,9 @@
 package de.rwth.swc.sqa.api;
 
+import de.rwth.swc.sqa.model.Customer;
 import org.springframework.stereotype.Controller;
 
 @Controller
 public class TicketController implements TicketsApi{
+    Customer customer;
 }
-- 
GitLab